I want to set a joint to a certain angle properly and get its torque using Joint::GetForceTorque() in the process.
So I follow [this](http://gazebosim.org/tutorials?tut=set_velocity&cat=) tutorials try to control a joint,
I try SetPositionPID() and SetPositionTarget() to contorl a joint ,but when I do this the joint cannt
stop even its force be set to zero by SetForce(0, 0).
P.S. I am using Gazebo-8, WITHOUT ROS. I have added (part of) the code from my plugin below.
public: void Update(const common::UpdateInfo &_info)
{
if (update_num == 0)
{
this->jointController.reset(new physics::JointController(
this->model));
float leftTargetAngle = 1.57;
float leftP = leftTargetAngle - this->model->GetJoint("purple_joint")->GetAngle(0).Radian();
leftP *= 10;
this->model->GetJoint("purple_joint")->SetForce(0, leftP);
this->model->GetJointController()->SetPositionPID(this->model->GetJoint("purple_joint")->GetScopedName(), common::PID(100, 0, 0));
this->model->GetJointController()->SetPositionTarget(this->model->GetJoint("purple_joint")->GetScopedName(), leftTargetAngle);
this->jointController->Update();
}
update_num++;
if(update_num==500)
{
this->model->GetJoint("purple_joint")->SetForce(0, 0);
}
return ;
}
Is there something wrong and why?
How to set a joint to a certain angle properly and get its torque using Joint::GetForceTorque() in this process?
Best Regards!
xinaxjm
↧