Resolving issue#1007 Visualizing dynamically created joints. Create a callback function.

asked 2015-03-12 00:09:18 -0600

Ratnesh Madaan gravatar image

updated 2015-03-12 13:16:44 -0600

scpeters gravatar image

I want to start contribute to Gazebo development by starting with this issue : Visualizing dynamically created joints

I have some (silly) doubts. If I add this in the test created for this issue


// Create dynamic joint

  std::string name = "dynamic_joint_unique";
  physics::JointPtr joint;
  joint = physics->CreateJoint("revolute", model);
  joint->Load(parent, child, math::Pose(0, 0, 0.5, 0, 0, 0));
  joint->Attach(parent, child);
  joint->SetModel(model);
  joint->Init();
  joint->SetName(name);

  //Reinitialize model

  model->Init();

  //Subscribe to the ~/joints topic.

  transport::SubscriberPtr sub = node->Subscribe("~/joints", ?? )

What method to call (as a parameter for the subscriber)?

1 transport::Node::Subscribe

The SubscriberPtr, which is a pointer to Subscriber object (3) has member functions "getcallbackid", "view topic", etc. It doesn't seem to be useful. How to use the info obtained by the subscriber and transfer it to Model?

Or I am wrong in my concepts. As far as I understood, the ~/joints topic will contain info about the new, dynamically created joint after reinitializing the model, which is publishing a msg of type Joint. We subscribe to it. Model->GetJoints is returning the vector model::joints.

I also was going through this pull request for some help in creating the callback function https://bitbucket.org/osrf/gazebo/pull-request/1413/allow-multiple-contact-sensors-per-link/diff#chg-test/integration/contact_sensor.cc

References:

4 Joint Class

5 Model Class

edit retag flag offensive close merge delete

Comments

As I look at the code, it looks like Model::LoadJoint(sdf::ElementPtr) might be the best function to call. We could recommend using the msgs::JointToSDF functions added in pull request 1419.

scpeters gravatar imagescpeters ( 2015-03-12 13:30:48 -0600 )edit
scpeters gravatar imagescpeters ( 2015-03-12 13:34:22 -0600 )edit

I just modified the test to use Model::LoadJoint and JointToSDF in https://bitbucket.org/osrf/gazebo/commits/7279e99d9d2b825ce447eae5603803095e272d5f

scpeters gravatar imagescpeters ( 2015-03-12 13:42:45 -0600 )edit

Model::LoadJoint won't work because it's a private function...

scpeters gravatar imagescpeters ( 2015-03-12 14:14:43 -0600 )edit