Robobuilder

(Difference between revisions)
Jump to: navigation, search
m (Using the RBC controller)
m (Using the RBC controller)
Line 27: Line 27:
 
puts "Serial number: #{robot.serial_number}"
 
puts "Serial number: #{robot.serial_number}"
 
acceleration = Vector[ *robot.accelerometer ]
 
acceleration = Vector[ *robot.accelerometer ]
if acceleration.inner_product( Vector[ 0, 0, 1 ] ) > acceleration.norm / 2
+
if acceleration.inner_product( Vector[ 0, 0, 1 ] ) >
 +
    acceleration.norm * 0.97
 
   robot.basic
 
   robot.basic
 
   robot.a
 
   robot.a
elsif acceleration.inner_product( Vector[ 0, 0, 1 ] ) < -acceleration.norm / 2
+
elsif acceleration.inner_product( Vector[ 0, 0, 1 ] ) <
 +
    -acceleration.norm * 0.97
 
   robot.basic
 
   robot.basic
 
   robot.b
 
   robot.b
 
end
 
end
 
acceleration = Vector[ *robot.accelerometer ]
 
acceleration = Vector[ *robot.accelerometer ]
if acceleration.inner_product( Vector[ 0, 1, 0 ] ) > acceleration.norm / 2
+
if acceleration.inner_product( Vector[ 0, 1, 0 ] ) >
 +
    acceleration.norm * 0.97
 
   robot.run 1
 
   robot.run 1
 
end
 
end

Revision as of 17:16, 2 October 2009

Assembled Robobuilder "Huno"
The Robobuilder Kit contains components for assembling a humanoid robot

Working.gif

Ruby Examples

Using the RBC controller

New.gif You can download the Ruby-extension for controlling the Robobuilder using a GNU+Linux PC here:

robobuilder-0.2.1.tar.bz2

Here is a small example program which makes the robot get up if it's lying on its back or its front.

#!/usr/bin/env ruby
require 'robobuilder'
require 'matrix'
class Vector
  def norm
    Math.sqrt inner_product( self )
  end
end
robot = Robobuilder.new '/dev/ttyUSB0'
puts "Robobuilder"
puts "Serial number: #{robot.serial_number}"
acceleration = Vector[ *robot.accelerometer ]
if acceleration.inner_product( Vector[ 0, 0, 1 ] ) >
    acceleration.norm * 0.97
  robot.basic
  robot.a
elsif acceleration.inner_product( Vector[ 0, 0, 1 ] ) <
    -acceleration.norm * 0.97
  robot.basic
  robot.b
end
acceleration = Vector[ *robot.accelerometer ]
if acceleration.inner_product( Vector[ 0, 1, 0 ] ) >
    acceleration.norm * 0.97
  robot.run 1
end
robot.close

External Links

Bookmark and Share

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox