Artoo is a micro-framework for robotics using Ruby.
Artoo provides a simple, yet powerful Domain-Specific Language (DSL) for robotics and physical computing.
Want to use JavaScript on robots? Check out our sister project Cylon.js (http://cylonjs.com)
Want to use the Go programming language to power your robots? Check out our sister project Gobot (http://gobot.io).
require 'artoo'
connection :arduino, :adaptor => :firmata, :port => '/dev/ttyACM0'
device :led, :driver => :led, :pin => 13
device :button, :driver => :button, :pin => 2
work do
on button, :push => proc {led.toggle}
end
require 'artoo'
connection :ardrone, :adaptor => :ardrone
device :drone, :driver => :ardrone
work do
drone.start
drone.take_off
after(25.seconds) { drone.hover.land }
after(30.seconds) { drone.stop }
end
You can also write more modular class-oriented code, that allows you to control swarms of robots:
require 'artoo/robot'
SPHEROS = ["4567", "4568", "4569", "4570", "4571"]
class SpheroRobot < Artoo::Robot
connection :sphero, :adaptor => :sphero
device :sphero, :driver => :sphero
work do
every(3.seconds) do
sphero.roll 90, rand(360)
end
end
end
robots = []
SPHEROS.each {|p|
robots << SpheroRobot.new(:connections =>
{:sphero =>
{:port => p}})
}
SpheroRobot.work!(robots)
Ruby versions supported: Ruby 2.1, Ruby 2.0, Ruby 1.9.3, JRuby 1.7.4+, and Rubinius 2.1+
Rubinius requires 1.9 mode, to install Rubinius in 1.9 mode using rvm
rvm get head && rvm install rbx-2.1.1 --1.9
Artoo is conceptualy influenced by Sinatra as well as borrowing some code from it.
Artoo provides a robust actor-based messaging architecture, that can support fully multi-threaded operation and high-concurrency, as long as it is supported by the Ruby version in which it is executing. This means you will need to use JRuby or Rubinius for maximum concurrency.
To a large extent, this is due to being built on top of Celluloid, Celluloid::IO, and Reel.
Artoo has a extensible system for connecting to hardware devices. The following robotics and physical computing platforms are currently supported:
- Arduino <=> Adaptor
- ARDrone <=> Adaptor
- BeagleBone <=> Adaptor
- Crazyflie <=> Adaptor
- Digispark <=> Adaptor
- Joystick <=> Adaptor
- Keyboard <=> Adaptor
- Leap Motion <=> Adaptor
- OpenCV <=> Adaptor
- Pebble <=> Adaptor
- Raspberry Pi <=> Adaptor
- Roomba <=> Adaptor
- Spark Core <=> Adaptor
- Sphero <=> Adaptor
More platforms are coming soon!
Artoo also has support for devices that can work across multiple hardware platforms.
Do you have some hardware that is not yet supported by Artoo? We want to help you, help us, help them! Get in touch...
gem install artoo
Then install the gems required by the hardware you want to use. For example, if you wanted to integrate a PS3 controller to fly your ARDrone:
gem install artoo-joystick
gem install artoo-ardrone
If you will be using socket to serial commuication (required if you will use JRuby or Rubinius), you are ready to start programming your hardware.
If you want to connect via serial port directly, and are using MRI, install the hybridgroup-serialport gem:
gem install hybridgroup-serialport
Now you are ready to write your own code. Take a look at the examples directory for a whole bunch of code you can use to help get started. We recommend using TDR (Test-Driven Robotics) with your preferred test frameworks.
< 8000 div class="highlight highlight-source-ruby notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="ruby myrobot.rb">ruby myrobot.rb