Project

rosruby

0.01
No commit activity in last 3 years
No release in over 3 years
ROS Ruby Client: rosruby ======= [ROS](http://ros.org) is Robot Operating System developed by [Willow Garage](http://www.willowgarage.com/) and open source communities. This project supports ruby ROS client. You can program robots by ruby, very easily. **Homepage**: http://otl.github.com/rosruby **Git**: http://github.com/OTL/rosruby **Author**: Takashi Ogura **Copyright**: 2012 **License**: new BSD License **Latest Version**: 0.2.0 Requirements ---------- - ruby (1.8.x/1.9.x) - ROS (electric/fuerte) - ROS requires python2.7 or more libraries Let's start --------------- Install ROS and ruby first. ROS document is [http://ros.org/wiki/ROS/Installation](http://ros.org/wiki/ROS/Installation) . You can install ruby by apt. ```bash $ sudo apt-get install ruby ``` Download rosruby into your ROS_PACKAGE_PATH. ````bash $ git clone git://github.com/OTL/rosruby.git ``` please add RUBYLIB environment variable, like below (if you are using bash). ```bash $ echo "export RUBYLIB=`rospack find rosruby`/lib" >> ~/.bashrc $ source ~/.bashrc ``` To use with precompiled electric release ----------------------- If you are using precompiled ROS distro, use the msg/srv generation script (rosruby_genmsg.py) If you are using ROS from source, it requires just recompile the msg/srv packages by rosmake rosruby. ```bash $ rosrun rosruby rosruby_genmsg.py ``` This converts msg/srv to .rb which is needed by sample programs. If you want to make other packages, add package names for args. For example, ```bash $ rosrun rosruby rosruby_genmsg.py geometry_msgs nav_msgs ``` Sample Source -------------- ## Subscriber ```ruby #!/usr/bin/env ruby require 'ros' require 'std_msgs/String' node = ROS::Node.new('/rosruby/sample_subscriber') node.subscribe('/chatter', Std_msgs::String) do |msg| puts "message come! = \'#{msg.data}\'" end while node.ok? node.spin_once sleep(1) end ``` ## Publisher ```ruby #!/usr/bin/env ruby require 'ros' require 'std_msgs/String' node = ROS::Node.new('/rosruby/sample_publisher') publisher = node.advertise('/chatter', Std_msgs::String) msg = Std_msgs::String.new i = 0 while node.ok? msg.data = "Hello, rosruby!: #{i}" publisher.publish(msg) sleep(1.0) i += 1 end ``` Note ---------------- Ruby requires 'Start with Capital letter' for class or module names. So please use **S**td_msgs::String class instead of **s**td_msgs::String. Try Publish and Subscribe ---------------------- You needs three terminal as it is often for ROS users. Then you run roscore if is not running. ```bash $ roscore ``` run publisher sample ```bash $ rosrun rosruby sample_publisher.rb ``` run subscription sample ```bash $ rosrun rosruby sample_subscriber.rb ``` you can check publication by using rostopic. ```bash $ rostopic list $ rostopic echo /chatter ``` Try Service? ---------------------- ```bash $ rosrun rosruby add_two_ints_server.rb ``` run client with args ('a' and 'b' for roscpp_tutorials/TwoInts) ```bash $ rosrun rosruby add_two_ints_client.rb 10 20 ``` and more... ---------------------- You need more tools for testing, generating documentations. ```bash $ sudo apt-get install rake gem $ sudo gem install yard redcarpet simplecov ``` do all tests ------------------------- run roscore if is not running. ```bash $ roscore ``` and run the unit tests. ```bash $ roscd rosruby $ rake test ``` documents -------------------------- you can generate API documents using yard. Document generation needs yard and redcarpet. You can install these by gem command like this. ```bash $ gem install yard redcarpet ``` Then try to generate documentds. ```bash $ rake yard ``` You can access to the generated documents from [here](http://otl.github.com/rosruby/doc/).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

ROS Ruby Client: rosruby

ROS is Robot Operating System developed by OSRF and open source communities.

This project supports ruby ROS client. You can program intelligent robots by ruby, very easily.

Homepage: http://otl.github.com/rosruby Git: http://github.com/OTL/rosruby Author: Takashi Ogura Copyright: 2012 License: new BSD License Latest Version: 0.4.3

Requirements

  • ruby (1.8.7/1.9.3)
  • ROS (hydro/groovy)

electric/fuerte

If you are using electric or fuerte, please use v0.2.1.

Install (binary)

sudo apt-get install ros-hydro-rosruby

then you have to source /opt/ros/hydro/setup.bash for ruby library path.

Install from source

Install ROS and ruby first. ROS document is http://ros.org/wiki/ROS/Installation . rosruby uses genrb for message generation. After install genrb, .rb message files are automatically compiled if there are message source package exists in your catkin_ws/src directory.

rosruby uses catkin. If you have not catkin_ws yet, please read this wiki.

$ cd ~/catkin_ws/src
$ git clone https://github.com/OTL/genrb.git
$ git clone https://github.com/OTL/rosruby.git
$ cd ~/catkin_ws
$ catkin_make
```

Install from source (indigo/jade)
----------------------------
Try indigo-devel branch.

```bash
$ cd ~/catkin_ws/src/rosruby
$ git checkout indigo-devel
$ cd ~/catkin_ws
$ catkin_make
```

Message generation
-----------------------
You must generate ROS msg/srv files for rosruby if the msg/srv packages are not compiled from source.
If you are using catkin package, it is easy.
Please add below to your package CMakeLists.txt.

    find_package(rosruby)
    rosruby_generate_messages(message_pkg1 message_pkg2 ...)


Or, you can generate it manually.
Please use the msg/srv generation script (rosruby_genmsg.py) in order to
generage rosruby messages.

For example, (please replace `catkin_ws` to your catkin workspace)

```bash
$ rosrun rosruby rosruby_genmsg.py geometry_msgs nav_msgs -d ~/catkin_ws/devel/lib/ruby/vendor_ruby/
```

If you want to generate msg/srv files from source (for example your project), it is automatically
generated by [genrb](http://github.com/OTL/genrb).

Sample Source
--------------
You can get rosruby sample programs from [rosruby_tutorials](https://github.com/OTL/rosruby_common) package.

## Subscriber

```ruby
#!/usr/bin/env ruby

require 'ros'
require 'std_msgs/String'

node = ROS::Node.new('/rosruby_sample_subscriber')
node.subscribe('/chatter', Std_msgs::String) do |msg|
  puts "message come! = \'#{msg.data}\'"
end

while node.ok?
  node.spin_once
  sleep(1)
end

```

## Publisher

```ruby
#!/usr/bin/env ruby

require 'ros'
require 'std_msgs/String'

node = ROS::Node.new('/rosruby_sample_publisher')
publisher = node.advertise('/chatter', Std_msgs::String)

msg = Std_msgs::String.new

i = 0
while node.ok?
  msg.data = "Hello, rosruby!: #{i}"
  publisher.publish(msg)
  sleep(1.0)
  i += 1
end
```

Note
----------------
Ruby requires 'Start with Capital letter' for class or module names.
So please use **S**td_msgs::String class instead of **s**td_msgs::String.
rosruby message compiler automatically generates messages by the rule.


Samples
----------------------
There are [rosruby_common](https://github.com/OTL/rosruby_common) that contains actionlib and tutorials.

Do all tests
-------------------------

[![Build Status](https://secure.travis-ci.org/OTL/rosruby.png)](http://travis-ci.org/OTL/rosruby)

Install some packages for tests.

```bash
$ sudo apt-get install rake gem
$ sudo gem install yard redcarpet simplecov
```

run tests.

```bash
$ rake test
```

Documents
--------------------------
you can generate API documents using yard.
Document generation needs yard and redcarpet.
You can install these by gem command like this.

```bash
$ gem install yard redcarpet
```

Then try to generate documentds.

```bash
$ rake yard
```

You can access to the generated documents from [here](http://otl.github.com/rosruby/doc/).


catkin and CMakeLists.txt
-----------------------------

rosruby's CMakeLists.txt defines some macros for your package that uses rosruby.
you can use these if you add `find_package(rosruby)` to CMakeLists.txt.

* rosruby_setup() : setup some macros and variables for rosruby
* rosruby_generate_messages(message_pkg1 message_okg2 ...) : generates rosruby msg/srv files
* rosruby_add_libraries(files or dirs) : install lib files for devel environment.