Robobuilder
(Difference between revisions)
m (→Using the RBC controller) |
m (→Ruby Examples) |
||
Line 10: | Line 10: | ||
=Ruby Examples= | =Ruby Examples= | ||
==Using the RBC controller== | ==Using the RBC controller== | ||
− | You | + | [[Image:New.gif]] You can download the Ruby-extension for controlling the Robobuilder here: [http://vision.eng.shu.ac.uk/jan/robobuilder-0.1.tar.bz2 robobuilder-0.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. | ||
<pre> | <pre> | ||
#!/usr/bin/env ruby | #!/usr/bin/env ruby | ||
− | + | require 'robobuilder' | |
− | + | require 'matrix' | |
− | + | class Vector | |
− | + | def norm | |
− | class | + | Math.sqrt inner_product( self ) |
− | def | + | |
− | + | ||
end | end | ||
end | end | ||
− | + | robot = Robobuilder.new '/dev/ttyS1' | |
− | + | puts "Robobuilder" | |
− | + | puts "Serial number: #{robot.serial_number}" | |
− | + | acceleration = Vector[ *robot.accelerometer ] | |
− | + | if acceleration.inner_product( Vector[ 0, 0, 1 ] ) > acceleration.norm / 2 | |
− | + | robot.basic | |
− | + | robot.a | |
− | + | elsif acceleration.inner_product( Vector[ 0, 0, 1 ] ) < -acceleration.norm / 2 | |
− | + | robot.basic | |
− | + | robot.b | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
end | end | ||
− | + | acceleration = Vector[ *robot.accelerometer ] | |
− | + | if acceleration.inner_product( Vector[ 0, 1, 0 ] ) > acceleration.norm / 2 | |
− | robot | + | robot.run 1 |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | robot. | + | |
− | + | ||
end | end | ||
− | + | robot.close | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
</pre> | </pre> | ||
Revision as of 18:36, 1 October 2009
Contents |
Gallery
Ruby Examples
Using the RBC controller
You can download the Ruby-extension for controlling the Robobuilder here: robobuilder-0.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/ttyS1' puts "Robobuilder" puts "Serial number: #{robot.serial_number}" acceleration = Vector[ *robot.accelerometer ] if acceleration.inner_product( Vector[ 0, 0, 1 ] ) > acceleration.norm / 2 robot.basic robot.a elsif acceleration.inner_product( Vector[ 0, 0, 1 ] ) < -acceleration.norm / 2 robot.basic robot.b end acceleration = Vector[ *robot.accelerometer ] if acceleration.inner_product( Vector[ 0, 1, 0 ] ) > acceleration.norm / 2 robot.run 1 end robot.close
External Links
- Robobuilder Ltd. (Korean manufacturer)
- Robosavvy (UK distributor)