Webots Ruby Bindings

This small library provides ruby bindings for the webots robot simulator. The library makes it really easy to develop robot controllers in ruby, in the same convenient way as webots provides itself through the python bindings, but now with the power of ruby.

Download

You can find the latest version of the bindings at the Download page.

How it works

Because you can't extend webots to really understand the ruby bindings, the idea is to create a very small C controller, wich only task is to run the ruby controller. The ruby controller will get the argc/argv arguments provided to the C controller and expects the name of the ruby script where the ruby controller resides as the first command argument. The whole thing then looks like this:

C code

#include <webots-ruby/webots-ruby.h> 

int 
main(int argc, char *argv[])
{
    return webots_ruby_main (argc, argv);
}

Ruby code

class Controller < Webots::DifferentialWheels
    STEP = 64

    def run(ms)
        set_speed(100, 100)
        return STEP
    end

    def reset
        # Do some reset actions here 
    end
end 

It's as simple as that. The webots-ruby library looks for a class named Controller. The class needs to descend from the Webots::Robot class (either directly, or indirectly through Webots::DifferentialWheels or Webots::CustomRobot). That's all there is to it! To link against ruby-webots you need to add something like the following to the standard webots controller Makefile:

CFLAGS=`pkg-config --cflags webots-ruby-0.2`
LIBRARIES=`pkg-config --libs webots-ruby-0.2` -lruby1.8