Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The controller cannot stop the joint if the PID gains are set to common::PID(0, 0, 0).

The gains control how much torque the controller will apply. All zeros means everything in the equation used to calculate the torque applied by the controller is being multiplied by zero. Some torque needs to be applied to stop a moving joint.

Often the gains on the controller are set once at startup.

if (update_num == 0)
{
  // Initialize the controller with the gains to use
  this->jointController->SetPositionPID(name, common::PID(100, 0, 0));
}
else if (update_num == X)
{
  // time to tell the joint to go to position 1.57
  this->jointController->SetPositionTarget(name, 1.57);
}
else if (update_num == Y)
{
  // time to tell the joint to go back to position 0
  this->jointController->SetPositionTarget(name, 0);
}
// The controller applies torque when it is updated.
// This must be called every update that the controller should be controlling the joint position
this->jointController->Update();

You might be interested in reading https://en.wikipedia.org/wiki/PID_controller#Mathematical_form