Visualizing dynamically created joints

Create issue
Issue #1077 new
Andrei Haidu created an issue

When creating dynamic joints, adding the possibility to visualize them (adding them to the Joint_V joints vector from Model.cc) https://bitbucket.org/osrf/gazebo/src/343a987165afa45e5c8e3877b0078f97a1b12e3e/gazebo/physics/Model.cc?at=default#cl-645

Maybe adding a public method to Model.cc, something like:

myModel->LoadJoint(JointPtr _joint);

Or the methods from Joint.cc:

myJoint->SetModel(ModelPtr _model)

myJoint->Load(Joint::Load(LinkPtr _parent, LinkPtr _child, const math::Pose &_pose)

should update the V_Joint from Model.cc

Comments (13)

  1. Steve Peters

    Let's write a test for this.

    Can you supply an example for how you create the joints dynamically?

    Then we can write an expectation that the dynamic joint is contained in a Model::joints vector.

  2. Andrei Haidu reporter

    Here is an example of creating dynamic joints from a plugin:

    void CreateDynamicJoint(physics::LinkPtr _parent_link,
                     physics::LinkPtr _child_link)
    {
            physics::JointPtr joint;
    
            joint = this->world->GetPhysicsEngine()->CreateJoint("revolute", this->myModel);
    
            joint->Load(_parent_link,_child_link, _parent_link->GetWorldPose());
    
            joint->Attach(_parent_link, _child_link);
    
            joint->SetModel(this->myModel);
    
            joint->Init();
    
            joint->SetHighStop(0, 0.1);
            joint->SetLowStop(0, -0.1);
            [...]
    }
    

    None of the used methods will update the V_Joint vector, only if the private method Model::LoadJoint(sdf::ElementPtr _sdf) is called, which takes as argument an SDF element. The later is called from the public method Model::LoadJoints()

    I am not sure where would be the best place to add this, or to create another method?

  3. Steve Peters

    I added your code to a test in 63851ee4a73b (branch issue_1077). It currently fails because it expects the joint to be found in the Model::joints returned by GetJoints. Does this test encapsulate what you're looking for?

  4. Andrei Haidu reporter

    Yes, it should do the job, if the test passes it means the joint is in the Model::joints vector. However in order for it to be visualized the model needs to be reinitialized using `Model::Init" since the visualization msg is created there .

    .

  5. Steve Peters

    Ok, so perhaps the test should also subscribe to the ~/joint topic and look for a message containing the information about the new joint.

  6. Steve Peters

    I just created a new branch off of gazebo5 that uses Model::LoadJoint(sdf::ElementPtr) and msgs::JointToSDF to dynamically create the joint. I think it should now be in the Model::GetJoints vector, but I don't think it will be published on ~/joint. That will take a little more work.

  7. Steve Peters

    We made some progress in pull request #1938 and pull request #2431 in making sure that there the API's for dynamically loaded joints will insert the joint pointer into the Model's joints vector, so that GetJoint can be used properly.

    We still need to publish information about dynamically created joints to gzclient so that they can be rendered. I believe this is currently only published in Model::Init, so we would have to find a different place to publish that.

  8. Log in to comment