Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby On Robots

Ruby On Robots

In the past few years robots have started to invade our lives, as toys or tools for around the home or at work. These robots are often much more user friendly and more importantly, hackable, than traditional industrial robots, which has lowered the barrier to writing software to control robots.

We’ll look at one particular ruby library, Artoo, a micro-framework for robotics that lets you connect to multiple different hardware devices and robots at the same time with some live demos as well.

Presented at: http://lrug.org/meetings/2013/10/30/november-2013-meeting/

Andrew Nesbitt

November 11, 2013
Tweet

More Decks by Andrew Nesbitt

Other Decks in Programming

Transcript

  1. require 'artoo' connection :arduino, :adaptor => :firmata, :port => '/dev/cu.usbmodemfd121'

    device :led, driver: :led, pin: 9 work do loop do led.toggle sleep 1 end end Hello World
  2. require 'artoo' require 'curses' Curses.noecho # do not show typed

    keys Curses.init_screen Curses.stdscr.keypad(true) # enable arrow keys (required for pageup/down) keys = { 260 => :left, 261 => :right, 259 => :up, 258 => :down, 'x' => :exit, ' ' => :stop } connection :arduino, :adaptor => :firmata, :port => '/dev/cu.usbmodemfd121' device :board, :driver => :device_info device :left_motor, :driver => :motor, :forward_pin => 6, # hack! :backward_pin => 8, :speed_pin => 10 device :right_motor, :driver => :motor, :forward_pin => 6, # hack! :backward_pin => 7, :speed_pin => 9 MAX_SPEED = 60
  3. work do loop do key = keys[Curses.getch] case key when

    :left left_motor.backward MAX_SPEED right_motor.forward MAX_SPEED when :right left_motor.forward MAX_SPEED right_motor.backward MAX_SPEED when :up left_motor.forward MAX_SPEED right_motor.forward MAX_SPEED when :down left_motor.backward MAX_SPEED right_motor.backward MAX_SPEED when :stop left_motor.stop right_motor.stop when :exit Curses.close_screen exit! end end end
  4. require 'artoo' connection :ardrone, :adaptor => :ardrone, :port => '192.168.1.1:5556'

    device :drone, :driver => :ardrone, :connection => :ardrone work do drone.start drone.take_off after(10.seconds) { drone.hover.land } after(15.seconds) { drone.stop } end AR DRONE