# Revision history [back]

### Joint created in runtime is not working properly

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);

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

gazebo::physics::ModelPtr model2 = GetModelPtr("Bola");

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

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!