Programming Robobuilder with Ruby

Korean company maker of Robot kits and servos designed for of articulated robots. Re-incarnation of Megarobotics.
8 postsPage 1 of 1
8 postsPage 1 of 1

Programming Robobuilder with Ruby

Post by wedesoft » Wed Sep 30, 2009 9:03 pm

Post by wedesoft
Wed Sep 30, 2009 9:03 pm

<table>
<tr valign="top"><td>
Hi, just got a Robobuilder this Monday and I managed to write a small Ruby program to communicate with the RBC module (Ruby programs are always small :wink:). If I find more time to work on it, I will publish the results on the Wiki of our research laboratory. Unfortunately ruby-serialport hasn't been maintained recently and there are problems with using it under 64bit GNU+Linux (AFAIK there are also some issues under MS Windows). The communication also occationally hangs (every couple of 1000 packets or so). Maybe it's because I am not using asynchronous communication. However if everything goes well, it should be fairly easy to write a really good GUI usingRichard Dale's Qt4-QtRuby Ruby-extension.

Update: I am now developing a Ruby-extension which communicates with the serial port using the termios-library. I tested it under GNU+Linux only. At some point I will try to port it to Windows with MinGW. The example program lets the robot get up using method "A" or "B" depending on the readout of the accelerometer. Let me know what you think about it or if you have any suggestions!

Update: Added a demo video of an interactive Ruby session below.
</td><td>
Image
</td>
</tr>
</table>

Code: Select all
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


One can control the Robobuilder from within an interactive Ruby session. Here is a demo video (also available as 15.5 MByte DivX3 video or as Youtube video):
<table align="center">
<tr><td><embed id="VideoPlayback" type="application/x-shockwave-flash" src="http://vision.eng.shu.ac.uk/jan/flv/flvplayer.swf" width="480" height="360" flashvars="file=http://vision.eng.shu.ac.uk/jan/flv/robobuilder1.flv&image=http://vision.eng.shu.ac.uk/jan/flv/robobuilder1.jpg&displayheight=360" pluginspage="http://www.macromedia.com/go/getflashplayer"></td></tr></table>
<table>
<tr valign="top"><td>
Hi, just got a Robobuilder this Monday and I managed to write a small Ruby program to communicate with the RBC module (Ruby programs are always small :wink:). If I find more time to work on it, I will publish the results on the Wiki of our research laboratory. Unfortunately ruby-serialport hasn't been maintained recently and there are problems with using it under 64bit GNU+Linux (AFAIK there are also some issues under MS Windows). The communication also occationally hangs (every couple of 1000 packets or so). Maybe it's because I am not using asynchronous communication. However if everything goes well, it should be fairly easy to write a really good GUI usingRichard Dale's Qt4-QtRuby Ruby-extension.

Update: I am now developing a Ruby-extension which communicates with the serial port using the termios-library. I tested it under GNU+Linux only. At some point I will try to port it to Windows with MinGW. The example program lets the robot get up using method "A" or "B" depending on the readout of the accelerometer. Let me know what you think about it or if you have any suggestions!

Update: Added a demo video of an interactive Ruby session below.
</td><td>
Image
</td>
</tr>
</table>

Code: Select all
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


One can control the Robobuilder from within an interactive Ruby session. Here is a demo video (also available as 15.5 MByte DivX3 video or as Youtube video):
<table align="center">
<tr><td><embed id="VideoPlayback" type="application/x-shockwave-flash" src="http://vision.eng.shu.ac.uk/jan/flv/flvplayer.swf" width="480" height="360" flashvars="file=http://vision.eng.shu.ac.uk/jan/flv/robobuilder1.flv&image=http://vision.eng.shu.ac.uk/jan/flv/robobuilder1.jpg&displayheight=360" pluginspage="http://www.macromedia.com/go/getflashplayer"></td></tr></table>
wedesoft offline
Newbie
Newbie
Posts: 2
Joined: Wed Jun 24, 2009 6:37 pm

Post by PedroR » Mon Jan 04, 2010 4:35 pm

Post by PedroR
Mon Jan 04, 2010 4:35 pm

Hi

I noticed you mentioned here http://vision.eng.shu.ac.uk/mmvlwiki/in ... obobuilder that you have some broken gears and talk about elastic actuators for protecting them.

Indeed, even the RX servos from ROBOTIS (which are all metal gears) experience broken gears when the complaince settings are too tight on the servos.

So the solution to your issue comes in two parts:
1) Yes, you can upgrade to all metal gears and have the improved strength of metal
(while you're at it you may also want to get some Metal Joints http://robosavvy.com/store/product_info ... cts_id/609 or just keep the plastic joints as the weak link, so that they are the first to break... after all they are cheap and easy to replace)

2) The biggest solution comes from tweaking not only the compliance but specially the PID gains on the servos.

This is something that can't be done on ROBOTIS servos (they don't have PID) but a good tuning of these gains will give you a true, elastic feel to the servos, just like the thesis you were mentioning.

This is done using the wCK Programmer. You will notice that it may be a bit tricky to get the values right (sometimes small adjustments cause huge differences) but getting them right should give you a true elastic feel.

Elasticity is especially important on the shoulders (and maybe knees) but all in all a good elastic setup will help protect your gears.

I tried to send you an email with this information but your WiKi does not have any "Contacts" section...

Regards
Pedro
Hi

I noticed you mentioned here http://vision.eng.shu.ac.uk/mmvlwiki/in ... obobuilder that you have some broken gears and talk about elastic actuators for protecting them.

Indeed, even the RX servos from ROBOTIS (which are all metal gears) experience broken gears when the complaince settings are too tight on the servos.

So the solution to your issue comes in two parts:
1) Yes, you can upgrade to all metal gears and have the improved strength of metal
(while you're at it you may also want to get some Metal Joints http://robosavvy.com/store/product_info ... cts_id/609 or just keep the plastic joints as the weak link, so that they are the first to break... after all they are cheap and easy to replace)

2) The biggest solution comes from tweaking not only the compliance but specially the PID gains on the servos.

This is something that can't be done on ROBOTIS servos (they don't have PID) but a good tuning of these gains will give you a true, elastic feel to the servos, just like the thesis you were mentioning.

This is done using the wCK Programmer. You will notice that it may be a bit tricky to get the values right (sometimes small adjustments cause huge differences) but getting them right should give you a true elastic feel.

Elasticity is especially important on the shoulders (and maybe knees) but all in all a good elastic setup will help protect your gears.

I tried to send you an email with this information but your WiKi does not have any "Contacts" section...

Regards
Pedro
PedroR offline
Savvy Roboteer
Savvy Roboteer
Posts: 1199
Joined: Mon Jun 16, 2008 11:07 pm

Post by PedroR » Mon Jan 04, 2010 4:37 pm

Post by PedroR
Mon Jan 04, 2010 4:37 pm

As a final note we may be able to supply some plastic replacement gears to you free of charge.
I believe your robot should have come with a few already but if not let me know and we can send them to you.

Regards
Pedro.
As a final note we may be able to supply some plastic replacement gears to you free of charge.
I believe your robot should have come with a few already but if not let me know and we can send them to you.

Regards
Pedro.
PedroR offline
Savvy Roboteer
Savvy Roboteer
Posts: 1199
Joined: Mon Jun 16, 2008 11:07 pm

Servos and cogwheels

Post by wedesoft » Thu Jan 07, 2010 1:44 pm

Post by wedesoft
Thu Jan 07, 2010 1:44 pm

Hi. Thanks for your reply. You can find my e-mail on my private homepage. In the Wiki I tend to avoid putting my name into the foreground.
I have ordered metal gears some time ago but I guess the order got stuck in our university's finance department. I hope they will get the order out at some point so that I can try them. Until then I will focus on machine vision (HornetsEye) and other things.
Hi. Thanks for your reply. You can find my e-mail on my private homepage. In the Wiki I tend to avoid putting my name into the foreground.
I have ordered metal gears some time ago but I guess the order got stuck in our university's finance department. I hope they will get the order out at some point so that I can try them. Until then I will focus on machine vision (HornetsEye) and other things.
wedesoft offline
Newbie
Newbie
Posts: 2
Joined: Wed Jun 24, 2009 6:37 pm

Post by scarab » Thu Mar 25, 2010 2:10 pm

Post by scarab
Thu Mar 25, 2010 2:10 pm

Hi there!

I'm a Ruby developer and a fan of Robotics which has been limited to LEGO Mindstorms. I only recently discovered Robobuilder and more importantly the 5710k. I wanted to find out how the Ruby code get's delivered to the 5710k. I understand that you're using serial comms but I'm more interested to here how the code get's deployed. Does it only operate as an interactive session or can you code, deploy and have the robot walk around etc.

Cheers!
Hi there!

I'm a Ruby developer and a fan of Robotics which has been limited to LEGO Mindstorms. I only recently discovered Robobuilder and more importantly the 5710k. I wanted to find out how the Ruby code get's delivered to the 5710k. I understand that you're using serial comms but I'm more interested to here how the code get's deployed. Does it only operate as an interactive session or can you code, deploy and have the robot walk around etc.

Cheers!
scarab offline
Robot Builder
Robot Builder
Posts: 10
Joined: Thu Mar 25, 2010 2:04 pm

Post by l3v3rz » Fri Apr 16, 2010 12:16 am

Post by l3v3rz
Fri Apr 16, 2010 12:16 am

For those ruby fans who want to work on a .NET platform and use RobobuilderLib.dll - you can use IronRuby - free download from here http://ironruby.net/Download. Just put http://robobuildervc.googlecode.com/fil ... derLib.dll in the same directory you start the IronRuby console (ir.exe). Here is the above example modded to use my library to get you started:

Code: Select all
require "RobobuilderLib"
require 'matrix'
class Vector
  def norm
    Math.sqrt inner_product( self )
  end
end

serial = System::IO::Ports::SerialPort.new
serial.PortName = "COM3"
serial.BaudRate = 115200
serial.open

robot = RobobuilderLib::PCremote.new serial
puts "Robobuilder"
puts "Serial number: #{robot.readSN}"
acceleration = Vector[ *robot.readXYZ ]
if acceleration.inner_product( Vector[ 0, 0, 1 ] ) > acceleration.norm / 2
  robot.runMotion 7
  robot.runMotion 1
elsif -acceleration.inner_product( Vector[ 0, 0, 1 ] ) > acceleration.norm / 2
  robot.runMotion 7
  robot.runMotion 2
end
acceleration = Vector[ *robot.readXYZ ]
if acceleration.inner_product( Vector[ 0, 1, 0 ] ) > acceleration.norm / 2
  robot.runMotion 1
end
serial.close


As you can see - very similar - For the future I'll look to add support to my library so we can have platform independent ruby code.


l3v3rz
For those ruby fans who want to work on a .NET platform and use RobobuilderLib.dll - you can use IronRuby - free download from here http://ironruby.net/Download. Just put http://robobuildervc.googlecode.com/fil ... derLib.dll in the same directory you start the IronRuby console (ir.exe). Here is the above example modded to use my library to get you started:

Code: Select all
require "RobobuilderLib"
require 'matrix'
class Vector
  def norm
    Math.sqrt inner_product( self )
  end
end

serial = System::IO::Ports::SerialPort.new
serial.PortName = "COM3"
serial.BaudRate = 115200
serial.open

robot = RobobuilderLib::PCremote.new serial
puts "Robobuilder"
puts "Serial number: #{robot.readSN}"
acceleration = Vector[ *robot.readXYZ ]
if acceleration.inner_product( Vector[ 0, 0, 1 ] ) > acceleration.norm / 2
  robot.runMotion 7
  robot.runMotion 1
elsif -acceleration.inner_product( Vector[ 0, 0, 1 ] ) > acceleration.norm / 2
  robot.runMotion 7
  robot.runMotion 2
end
acceleration = Vector[ *robot.readXYZ ]
if acceleration.inner_product( Vector[ 0, 1, 0 ] ) > acceleration.norm / 2
  robot.runMotion 1
end
serial.close


As you can see - very similar - For the future I'll look to add support to my library so we can have platform independent ruby code.


l3v3rz
l3v3rz offline
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by sdertsr6 » Wed May 12, 2010 11:30 am

Post by sdertsr6
Wed May 12, 2010 11:30 am

awesome...thanks for posting..
awesome...thanks for posting..
sdertsr6 offline
Newbie
Newbie
Posts: 1
Joined: Wed May 12, 2010 11:25 am

Post by jbo123 » Tue Aug 16, 2011 6:51 am

Post by jbo123
Tue Aug 16, 2011 6:51 am

this is amazing, great job!
this is amazing, great job!
jbo123 offline
Newbie
Newbie
Posts: 1
Joined: Tue Aug 16, 2011 6:51 am


8 postsPage 1 of 1
8 postsPage 1 of 1
cron