Revision: 7962
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7962&view=rev
Author:   robotos
Date:     2009-07-09 14:40:27 +0000 (Thu, 09 Jul 2009)

Log Message:
-----------
Ruby position and bumper examples

Added Paths:
-----------
    code/gazebo/trunk/examples/ruby/
    code/gazebo/trunk/examples/ruby/bumper.rb
    code/gazebo/trunk/examples/ruby/position.rb

Added: code/gazebo/trunk/examples/ruby/bumper.rb
===================================================================
--- code/gazebo/trunk/examples/ruby/bumper.rb                           (rev 0)
+++ code/gazebo/trunk/examples/ruby/bumper.rb   2009-07-09 14:40:27 UTC (rev 
7962)
@@ -0,0 +1,31 @@
+#TODO:test this
+require 'gazeboc'
+
+begin
+  client = Gazeboc::Client.new 
+  bumperIface = Gazeboc::BumperIface.new
+rescue Exception => e  
+  puts "Gazebo exceptions can be catched on Ruby"
+  raise "initialization impossible, bindings installed?"
+end
+
+client.Connect 0
+
+posIface.Open client, "PUT_BUMPER_IFACE_HERE"
+posIface.Lock 1
+posIface.data.cmdEnableMotors = 1
+posIface.Unlock
+
+10.times do
+
+  bumIface.Lock 1
+  count = bumperIface.data.bumper_count
+  
+  count.times do |i]
+    puts bumberIface.data.bumpers[i].to_s
+  end
+  bumIface.Unlock
+  sleep(0.1
+end
+
+bumperIface.Close

Added: code/gazebo/trunk/examples/ruby/position.rb
===================================================================
--- code/gazebo/trunk/examples/ruby/position.rb                         (rev 0)
+++ code/gazebo/trunk/examples/ruby/position.rb 2009-07-09 14:40:27 UTC (rev 
7962)
@@ -0,0 +1,36 @@
+#based on pioneer2d world
+#equivalent to the libgazebo/position example
+
+require 'gazeboc'
+
+begin
+  client = Gazeboc::Client.new 
+  simIface = Gazeboc::SimulationIface.new 
+  posIface = Gazeboc::PositionIface.new
+rescue Exception => e  
+  puts "Gazebo exceptions can be catched on Ruby"
+  raise "initialization impossible, bindings installed?"
+end
+
+client.Connect 0
+
+posIface.Open client, "pioneer2dx_model1::position_iface_0"
+posIface.Lock 1
+posIface.data.cmdEnableMotors = 1
+posIface.Unlock
+
+
+while true
+
+  posIface.Lock 1
+  posIface.data.cmdVelocity.pos.x = 0.2
+  posIface.data.cmdVelocity.yaw = -0.1
+  posIface.Unlock
+  sleep 1
+  pose = posIface.data.pose.pos
+  puts "position: (%.3f, %.3f, %.3f)" % [pose.x, pose.y, pose.z]
+
+end
+
+posIface.Close
+simIface.Close


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to