0
$\begingroup$

Rosanswers logo

Hi I am trying to make a plugin in gazebo to control a 1 joint urdf model. I am able to give it tourque by this command -

 this->only_joint_->SetForce(0,(-10*(this->only_joint_->GetAngle(0)));

but if i try giving a different command like-

this->only_joint_->SetForce(0,(-3*this->only_joint_->GetVelocity(0)+10*(this->only_joint_->GetAngle(0)));

it isn't willing to compile. any idea?

Thanks Nachum


Originally posted by Nachum on ROS Answers with karma: 208 on 2012-10-17

Post score: 0


Original comments

Comment by Stefan Kohlbrecher on 2012-10-17:
For questions like this, it is very helpful if you add the actual error message you encounter. (You can edit your post to do that)

Comment by hsu on 2012-10-18:
GetAngle(0) returns a gazebo::math::Angle object, you need to invoke the GetAngle().GetAsRadian() member function as you did in your own answer below.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

O.k I just put it in 2 different lines and it works nicely.

this->only_joint_->SetForce(0,-2*this->only_joint_->GetAngle(0).GetAsRadian());
 this->only_joint_->SetForce(0,-2*this->only_joint_->GetVelocity(0));

Originally posted by Nachum with karma: 208 on 2012-10-18

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Nachum on 2012-10-18:
for what do i need the zero in GetAngle(0)?

Comment by hsu on 2012-10-18:
for some joints such as Hinge2Joint and Universal joints, there are two states per joint.

Comment by Nachum on 2012-10-20:
what are the two states?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.