Home | Tutorials | Wiki | Issues
Ask Your Question
2

Joint created in runtime is not working properly

asked 2015-01-16 10:27:09 -0500

Trmotta gravatar image

Hello everyone!

I recently had a problem where I needed to edit a robot in runtime, adding new joints and links to it. After asking this question in this thread the way to go was to create a new Model and attach both models, which is working. However, whenever a link is attached to a different model, I end up loosing the last link in that model, so it was needed to recreate it everytime an attachment was made. The problem here is that this is giving me some overhead, so in order to get a better performance I tried the previous thread suggestion like this:

std::string modelNameStr( parentModelName );

gazebo::physics::ModelPtr model = GetModelPtr(modelNameStr);
gazebo::physics::LinkPtr model1Link = model->GetLink("Rope_Segment_2");

LOGGER.Write(Log::INFO,"Model jointCount : %d \n", model->GetJointCount() );

gazebo::physics::ModelPtr model2 = GetModelPtr("Bola");
gazebo::physics::LinkPtr model2Link = model2->GetLink("Link0");

newJoint = world->GetPhysicsEngine()->CreateJoint( "revolute", model );
newJoint->SetName("Joint3");
newJoint->SetModel( model );

newJoint->Load(model1Link, model2Link, model2Link->GetWorldPose() );
newJoint->Attach(model1Link, model2Link);

newJoint->SetAxis(0,  gazebo::math::Vector3(0.0f,1.0f,0.0f) );
newJoint->SetLowerLimit( 0, gazebo::math::Angle( 0.0f ) );
newJoint->SetUpperLimit( 0, gazebo::math::Angle( 0.2f ) );

LOGGER.Write(Log::INFO,"Model jointCount : %d \n", model->GetJointCount() );

if( model->GetJoint("Joint3") == NULL )
    LOGGER.Write(Log::INFO,"Model GetJoint : FALSE \n" );
else
    LOGGER.Write(Log::INFO,"Model GetJoint : OK \n" );

And the result is that both Logger.Write gives me the same number and the last If also returns FALSE. In the other hand, if I keep the reference to this newly created Joint Im still able to access it and make it work like a normal joint would. So for me it seems that this new Joint is created somewhere but its just not being added to the joint list or something like it.

Anyone know what am I doing wrong?

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-01-17 14:01:51 -0500

AndreiHaidu gravatar image

Hi,

there is an issue report on this here. When joints are created dynamically the Joints vector doesn't get updated in Gazebo, that's the reason you cannot visualise the new joints or in your case to get the correct size of the list.

Cheers, Andrei

edit flag offensive delete link more

Comments

Thank you once again, Andrei. Ill be hoping for it to be fixed by the end of the month with the new release of Gazebo 5.0.

Trmotta gravatar imageTrmotta ( 2015-01-19 07:07:35 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-01-16 10:27:09 -0500

Seen: 2,173 times

Last updated: Jan 17 '15