How correctly move joints by SetPositionPID() and SetPositionTarget()
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 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 PID be set to zero by SetPositionPID(name, common::PID(0, 0, 0)).
P.S. I am using Gazebo-8, WITHOUT ROS. I have added (part of) the code from my plugin below.
std::string name;
if (update_num == 0)
{
//Joint velocity using PID controller
this->jointController.reset(new physics::JointController(this->model));
this->jointController->AddJoint(model->GetJoint("purple_joint"));
name = model->GetJoint("purple_joint")->GetScopedName();
// this->jointController->SetVelocityPID(name, common::PID(100, 0, 0));
this->jointController->SetPositionPID(name, common::PID(100, 0, 0));
this->jointController->SetPositionTarget(name,1.57);
// this->jointController->SetVelocityTarget(name, 1.0);
}
else if (update_num < 200)
{
// Must update PID controllers so they apply forces
this->jointController->Update();
}
else if (update_num >= 200)
{
name = model->GetJoint("purple_joint")->GetScopedName();
this->jointController->SetPositionPID(name, common::PID(0, 0, 0));
this->jointController->SetPositionTarget(name,0);
}
update_num++;
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