Revision: 7592
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7592&view=rev
Author:   natepak
Date:     2009-04-10 14:55:29 +0000 (Fri, 10 Apr 2009)

Log Message:
-----------
Updated the laser examples

Modified Paths:
--------------
    code/gazebo/trunk/examples/player/laser/laser.cc

Added Paths:
-----------
    code/gazebo/trunk/examples/libgazebo/laser/
    code/gazebo/trunk/examples/libgazebo/laser/SConstruct
    code/gazebo/trunk/examples/libgazebo/laser/laser.cc

Added: code/gazebo/trunk/examples/libgazebo/laser/SConstruct
===================================================================
--- code/gazebo/trunk/examples/libgazebo/laser/SConstruct                       
        (rev 0)
+++ code/gazebo/trunk/examples/libgazebo/laser/SConstruct       2009-04-10 
14:55:29 UTC (rev 7592)
@@ -0,0 +1,16 @@
+
+# 3rd party packages
+parseConfigs=['pkg-config --cflags --libs libgazebo']
+
+env = Environment (
+  CC = 'g++',
+
+  CCFLAGS = Split ('-pthread -pipe  -W -Wall -O2'),
+)
+
+
+# Parse all the pacakge configurations
+for cfg in parseConfigs:
+  env.ParseConfig(cfg)
+
+env.Program('laser','laser.cc')

Added: code/gazebo/trunk/examples/libgazebo/laser/laser.cc
===================================================================
--- code/gazebo/trunk/examples/libgazebo/laser/laser.cc                         
(rev 0)
+++ code/gazebo/trunk/examples/libgazebo/laser/laser.cc 2009-04-10 14:55:29 UTC 
(rev 7592)
@@ -0,0 +1,67 @@
+#include <string.h>
+#include <iostream>
+#include <math.h>
+#include <boost/bind.hpp>
+#include <gazebo/gazebo.h>
+
+int main()
+{
+  gazebo::Client *client = new gazebo::Client();
+  gazebo::SimulationIface *simIface = new gazebo::SimulationIface();
+  gazebo::LaserIface *laserIface = new gazebo::LaserIface();
+
+  int serverId = 0;
+
+  /// Connect to the libgazebo server
+  try
+  {
+    client->ConnectWait(serverId, GZ_CLIENT_ID_USER_FIRST);
+  }
+  catch (std::string e)
+  {
+    std::cout << "Gazebo error: Unable to connect\n" << e << "\n";
+    return -1;
+  }
+
+  /// Open the Simulation Interface
+  try
+  {
+    simIface->Open(client, "default");
+  }
+  catch (std::string e)
+  {
+    std::cout << "Gazebo error: Unable to connect to the sim interface\n" << e 
<< "\n";
+    return -1;
+  }
+
+  /// Open the Simulation Interface
+  try
+  {
+    laserIface->Open(client, "laser_iface_0");
+  }
+  catch (std::string e)
+  {
+    std::cout << "Gazebo error: Unable to connect to the laser interface\n" << 
e << "\n";
+    return -1;
+  }
+
+  while (true)
+  {
+    float maxRange = 0;
+    for (int i = 0; i < laserIface->data->range_count; i++)
+    {
+      if (laserIface->data->ranges[i] > maxRange)
+        maxRange = laserIface->data->ranges[i];
+    }
+    printf("Max Range[%f]\n",maxRange);
+    usleep(10000);
+  }
+
+  laserIface->Close();
+  simIface->Close();
+
+  delete laserIface;
+  delete simIface;
+  return 0;
+}
+

Modified: code/gazebo/trunk/examples/player/laser/laser.cc
===================================================================
--- code/gazebo/trunk/examples/player/laser/laser.cc    2009-04-09 22:51:12 UTC 
(rev 7591)
+++ code/gazebo/trunk/examples/player/laser/laser.cc    2009-04-10 14:55:29 UTC 
(rev 7592)
@@ -29,7 +29,7 @@
     std::cout << "Laser Pose[" << laserPose.px << " " <<
       laserPose.py << " " << laserPose.pyaw << "]\n";
 
-    /*for (;;)
+    for (;;)
     {
       // This blocks until new data comes
       robot.Read();
@@ -39,7 +39,7 @@
         printf("[%f %d]", lp.GetRange(i), lp.GetIntensity(i) );
       }
       printf("\n");
-    }*/
+    }
   }
   catch (PlayerCc::PlayerError e)
   {


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

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to