Revision: 8737
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8737&view=rev
Author:   natepak
Date:     2010-05-29 20:50:41 +0000 (Sat, 29 May 2010)

Log Message:
-----------
Added better contact callback

Modified Paths:
--------------
    code/gazebo/branches/simpar/plugins/pioneer_spiral.cc
    code/gazebo/branches/simpar/plugins/pioneer_spiral.hh
    
code/gazebo/branches/simpar/server/controllers/gripper/pioneer2/Pioneer2_Gripper.cc
    code/gazebo/branches/simpar/server/physics/Geom.cc
    code/gazebo/branches/simpar/server/physics/Geom.hh
    code/gazebo/branches/simpar/server/physics/ode/ODEPhysics.cc

Modified: code/gazebo/branches/simpar/plugins/pioneer_spiral.cc
===================================================================
--- code/gazebo/branches/simpar/plugins/pioneer_spiral.cc       2010-05-29 
20:08:58 UTC (rev 8736)
+++ code/gazebo/branches/simpar/plugins/pioneer_spiral.cc       2010-05-29 
20:50:41 UTC (rev 8737)
@@ -39,6 +39,17 @@
     this->leftWheel = (Body*)this->robot->GetChild("left_wheel");
     this->rightWheel = (Body*)this->robot->GetChild("right_wheel");
 
+    Geom *leftWheelGeom = this->leftWheel->GetGeom("left_wheel_geom");
+    Geom *rightWheelGeom = this->rightWheel->GetGeom("right_wheel_geom");
+
+    leftWheelGeom->SetContactsEnabled(true);
+    rightWheelGeom->SetContactsEnabled(true);
+
+    leftWheelGeom->ConnectContactCallback(
+        boost::bind(&PioneerSpiral::LeftContactCB, this, _1));
+    rightWheelGeom->ConnectContactCallback(
+        boost::bind(&PioneerSpiral::RightContactCB, this, _1));
+
     World::Instance()->ConnectWorldUpdateStartSignal(
         boost::bind(&PioneerSpiral::UpdateCB, this));
   }
@@ -50,3 +61,25 @@
 {
   this->leftWheel->SetTorque(Vector3(0,0,0.5));
 }
+
+void PioneerSpiral::LeftContactCB(const Contact &contact)
+{
+  std::cout << "Left contact\n";
+  for (unsigned int i=0; i < contact.positions.size(); i++)
+  {
+    std::cout << "  Pos[" << contact.positions[i] << "] "
+              << "Norm[" << contact.normals[i] << "] "
+              << "Depth[" << contact.depths[i] << "]\n";
+  }
+}
+
+void PioneerSpiral::RightContactCB(const Contact &contact)
+{
+  std::cout << "Right contact\n";
+  for (unsigned int i=0; i < contact.positions.size(); i++)
+  {
+    std::cout << "  Pos[" << contact.positions[i] << "] "
+              << "Norm[" << contact.normals[i] << "] "
+              << "Depth[" << contact.depths[i] << "]\n";
+  }
+}

Modified: code/gazebo/branches/simpar/plugins/pioneer_spiral.hh
===================================================================
--- code/gazebo/branches/simpar/plugins/pioneer_spiral.hh       2010-05-29 
20:08:58 UTC (rev 8736)
+++ code/gazebo/branches/simpar/plugins/pioneer_spiral.hh       2010-05-29 
20:50:41 UTC (rev 8737)
@@ -16,6 +16,9 @@
 
     public: void UpdateCB();
 
+    public: void LeftContactCB(const Contact &contact);
+    public: void RightContactCB(const Contact &contact);
+
     private: Model *robot;
     private: Body *leftWheel;
     private: Body *rightWheel;

Modified: 
code/gazebo/branches/simpar/server/controllers/gripper/pioneer2/Pioneer2_Gripper.cc
===================================================================
--- 
code/gazebo/branches/simpar/server/controllers/gripper/pioneer2/Pioneer2_Gripper.cc
 2010-05-29 20:08:58 UTC (rev 8736)
+++ 
code/gazebo/branches/simpar/server/controllers/gripper/pioneer2/Pioneer2_Gripper.cc
 2010-05-29 20:50:41 UTC (rev 8737)
@@ -62,6 +62,9 @@
 // Destructor
 Pioneer2_Gripper::~Pioneer2_Gripper()
 {
+  
this->paddles[LEFT]->DisconnectContactCallback(boost::bind(&Pioneer2_Gripper::LeftPaddleCB,
 this));
+  
this->paddles[RIGHT]->DisconnectContactCallback(boost::bind(&Pioneer2_Gripper::RightPaddleCB,
 this));
+
   if (this->holdJoint)
     delete this->holdJoint;
   this->holdJoint = NULL;
@@ -191,8 +194,10 @@
   this->holdJoint = 
World::Instance()->GetPhysicsEngine()->CreateJoint(Joint::SLIDER);
   this->holdJoint->SetName(this->GetName() + "_Hold_Joint");
 
-  this->paddles[LEFT]->ContactCallback(&Pioneer2_Gripper::LeftPaddleCB, this);
-  this->paddles[RIGHT]->ContactCallback(&Pioneer2_Gripper::RightPaddleCB, 
this);
+  this->paddles[LEFT]->ConnectContactCallback(
+      boost::bind(&Pioneer2_Gripper::LeftPaddleCB, this, _1));
+  this->paddles[RIGHT]->ConnectContactCallback(
+      boost::bind(&Pioneer2_Gripper::RightPaddleCB, this, _1));
 }
 
 
////////////////////////////////////////////////////////////////////////////////

Modified: code/gazebo/branches/simpar/server/physics/Geom.cc
===================================================================
--- code/gazebo/branches/simpar/server/physics/Geom.cc  2010-05-29 20:08:58 UTC 
(rev 8736)
+++ code/gazebo/branches/simpar/server/physics/Geom.cc  2010-05-29 20:50:41 UTC 
(rev 8737)
@@ -489,6 +489,7 @@
   if (this->GetShapeType() == Shape::RAY || this->GetShapeType() == 
Shape::PLANE)
     return;
 
+  std::cout << "Contact\n";
   this->contacts.push_back( contact.Clone() );
   this->contactSignal( contact );
 }

Modified: code/gazebo/branches/simpar/server/physics/Geom.hh
===================================================================
--- code/gazebo/branches/simpar/server/physics/Geom.hh  2010-05-29 20:08:58 UTC 
(rev 8736)
+++ code/gazebo/branches/simpar/server/physics/Geom.hh  2010-05-29 20:50:41 UTC 
(rev 8737)
@@ -180,12 +180,14 @@
     /// \brief Get the angular acceleration of the model
     public: virtual Vector3 GetAngularAccel() const;
  
-    public: template< typename C>
-            void ContactCallback( void (C::*func)(const Contact&), C *c )
-            {
-              contactSignal.connect( boost::bind(func, c, _1) );
-            }
+    public: template< typename T>
+            boost::signals::connection ConnectContactCallback( T subscriber )
+            { return contactSignal.connect(subscriber); }
+    public: template< typename T>
+            void DisconnectContactCallback( T subscriber )
+            { contactSignal.disconnect(subscriber); }
 
+
     /// \brief Enable callback: Called when the body changes
     private: void EnabledCB(bool enabled);
 

Modified: code/gazebo/branches/simpar/server/physics/ode/ODEPhysics.cc
===================================================================
--- code/gazebo/branches/simpar/server/physics/ode/ODEPhysics.cc        
2010-05-29 20:08:58 UTC (rev 8736)
+++ code/gazebo/branches/simpar/server/physics/ode/ODEPhysics.cc        
2010-05-29 20:50:41 UTC (rev 8737)
@@ -758,10 +758,8 @@
           contact.surface.slip2 = 0.1;
         }
 
-        contact.surface.bounce =  0;
-        /*contact.surface.bounce = std::min(geom1->surface->bounce, 
+        contact.surface.bounce = std::min(geom1->surface->bounce, 
                                      geom2->surface->bounce);
-                                     */
         contact.surface.bounce_vel = std::min(geom1->surface->bounceVel, 
                                          geom2->surface->bounceVel);
         dJointID c = dJointCreateContact (self->worldId,


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

------------------------------------------------------------------------------

_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to