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.

Author: Takashi Ogura
Copyright: 2012
License: new BSD License
Latest Version: 0.3.0



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

Install (binary)

If you want to use groovy,

sudo apt-get install ros-groovy-rosruby

and add RUBYLIB environmental variable.

$ echo "export RUBYLIB=/opt/ros/groovy/lib/ruby/vendor_ruby" >> ~/.bashrc
$ source ~/.bashrc

Install from source

Install ROS and ruby first. ROS document is .

Please use catkin to install rosruby. If you have not catkin_ws yet, please read this wiki.

$ cd ~/catkin_ws/src
$ git clone git://
$ cd ~/catkin_ws
$ catkin_make

please add RUBYLIB environment variable, like below (if you are using bash).

$ echo "export RUBYLIB=~/catkin_ws/devel/lib/ruby/vendor_ruby" >> ~/.bashrc
$ source ~/.bashrc

if you want to use install environment, please edit develop -> install

export RUBYLIB=~/catkin_ws/install/lib/ruby/vendor_ruby

Message generation

You must generate ROS msg/srv files for rosruby manually. Please use the msg/srv generation script ( in order to generage rosruby messages.

For example,

$ rosrun rosruby geometry_msgs nav_msgs -d ~/catkin_ws/devel/lib/ruby/vendor_ruby/

Sample Source


#!/usr/bin/env ruby

require 'ros'
require 'std_msgs/String'

node ='/rosruby/sample_subscriber')
node.subscribe('/chatter', Std_msgs::String) do |msg|
  puts "message come! = \'#{}\'"

while node.ok?


#!/usr/bin/env ruby

require 'ros'
require 'std_msgs/String'

node ='/rosruby/sample_publisher')
publisher = node.advertise('/chatter', Std_msgs::String)

msg =

i = 0
while node.ok? = "Hello, rosruby!: #{i}"
  i += 1


Ruby requires 'Start with Capital letter' for class or module names. So please use Std_msgs::String class instead of std_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.

$ roscore

run publisher sample

$ rosrun rosruby sample_publisher.rb

run subscription sample

$ rosrun rosruby sample_subscriber.rb

you can check publication by using rostopic.

$ rostopic list
$ rostopic echo /chatter

Try Service?

$ rosrun rosruby add_two_ints_server.rb

run client with args ('a' and 'b' for roscpp_tutorials/TwoInts)

$ rosrun rosruby add_two_ints_client.rb 10 20

And more...

There are rosruby_common stack that contains actionlib and tf (highly under development).

Do all tests

Build Status

Install some packages for tests.

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

run tests.

$ roscd rosruby
$ rake test


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

$ gem install yard redcarpet

Then try to generate documentds.

$ rake yard

You can access to the generated documents from here.

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.