Robotics StackExchange | Archived questions

How to set rotation axis for Hinge Joint in Gazebo created from source?

Hi there,

I am creating dynamically a Hinge Joint between two bodies via a controller in Gazebo (with ROS electric). The bodies belong to the same model. The Joint gets created, its upper and lower angle limit work fine, the problem is that I cannot set the rotation axis for it.

The code looks something like this:

Vector3 anchorPos3,rotAxis3;

Joint *j;

j = World::Instance()->GetPhysicsEngine()->CreateJoint(gazebo::Joint::HINGE);

j->body1 = dynamiccast(this->sphereBodies[body1indice]);

j->body2 = dynamiccast(this->sphereBodies[body2indice]);

j->anchorBody = j->body1;

j->SetAttribute(gazebo::Joint::HI_STOP,0,0.5);

j->SetAttribute(gazebo::Joint::LO_STOP,0,-0.5);

//next two functions don't work as expected, after I call j->GetAxis(0) and j->GetAnchor(0) , both positions are 0, 0, 0;

j->SetAxis(0, rotAxis3); // NOT WORKING

j->anchorPos = anchorPos3; // NOT WORKING

j->Attach(j->body1, j->body2);

Thanks, Andrei

Asked by Andrei Haidu on 2012-06-18 02:01:53 UTC

Comments

Please ask gazebo questions at http://answers.gazebosim.org

Asked by tfoote on 2015-03-03 02:55:16 UTC

Answers