# Revision history [back]

Based on nkoenig's suggestion and an answer by AndreiHaidu to another question (see http://answers.gazebosim.org/question/2341/set-and-get-position-of-gazebo-model-using-ros-plugin/) my solution that seems to work so far is:

• created a PID object for each joint I want to control
• created an Update method for the controller (based on link above and the Update method in JointController.cc of Gazebo-7 source code) , code snippet given below
• finally, in the the OnUpdate step of my plugin class i set my desired steering angle set-point (m_setpoint) via a different function and call the Update method I implemented for all my joints' PIDs.

void PID_JointController::Update(){

common::Time currTime = this->m_model->GetWorld()->GetSimTime();
common::Time stepTime = currTime - this->m_prevUpdateTime;
this->m_prevUpdateTime = currTime;

if ( stepTime > 0 ) {
m_cmd_force = this->m_PositionPID.Update(
this->m_setpoint, stepTime);
this->m_JointPtr->SetForce(m_axis_index, m_cmd_force);
}


Based on nkoenig's suggestion and an answer by AndreiHaidu to another question (see http://answers.gazebosim.org/question/2341/set-and-get-position-of-gazebo-model-using-ros-plugin/) my solution that seems to work so far is:

• created a PID object for each joint I want to control
• created an Update method for the controller (based on link above and the Update method in JointController.cc of Gazebo-7 source code) , code snippet given below
• finally, in the the OnUpdate step of my plugin class i set my desired steering angle set-point (m_setpoint) via a different function and call the Update method I implemented for all my joints' PIDs.

void PID_JointController::Update(){

common::Time currTime = this->m_model->GetWorld()->GetSimTime();
common::Time stepTime = currTime - this->m_prevUpdateTime;
this->m_prevUpdateTime = currTime;

if ( stepTime > 0 ) {
m_cmd_force = this->m_PositionPID.Update(