Rosanswers logo

Hi guys!

I got a robot simulated in Gazebo which i'd like to control easily. I made 3 controllers (thanks to the tutorials) : one to control the head and a controller for each wheel. I should mention that the robot stands on a 3rd wheel (it's just a ball actually), it might cause a problem but if so, I don't know which one.

By setting the effort applied on the wheel joints, it works "ok". It's not perfect (zigzags and slidings) but if the applied effort is not to high, it's ok. So, I tried to add a PID to these controllers. The head controller works just fine with it. But when I did the same with the left wheel, I got some very strange results : the robot starts jumping/flying before landing far away when the wheel comes to the position I asked.

I first thought to change the PID parameters, but the problem remains : the effort applied by the pid_controller_.updatePid(current_pos-desired_pos, dt) function is lower than the one I apply on the wheel "by myself" to make it move without "jumping", but the robot still "jumps" (see the update loop in the .cpp file in the "add a pid" tutorial).

I also tried changing the weight of the wheels and the body in the URDF file , and I set the contact coefficient using the following code :

 <gazebo reference="lefttire">
    <mu1 value="100.0" />
    <mu2 value="100.0" />
    <kp  value="1000000.0" />
    <kd  value="1.0" />

("lefttire" is the name of the link)


Should I add a PID controller for the wheel speed? Or should I look at this 3rd wheel?

Any help appreciated! Thanks!

UPDATE : "Please, help!"

Originally posted by arzhed on ROS Answers with karma: 143 on 2012-10-04

Post score: 2

Original comments

Comment by hsu on 2012-10-18:
can you share your model and code? thanks.


1 Answer 1


Rosanswers logo

Hello , think of your system(dc motors) as a lineer system which is not xdot = A(t)x + B(t)u y = C(t)x + D(t)u

x is your state vectors and u is your inputs. When you apply inputs( such as a step function) to your system, you can't get same output because of system dynamics, etc..

So you have to implement a PID controller( because it is the easiest one to implement) to follow your inputs. If you have 2 wheels actuated by dc motor, you have to apply pid controller for both of them. If third wheel is a castor wheel, you can't apply pid control for it because it doesn't have any actuator.

Jumping stuff occurs maybe because of your pid gains or damping ratio of the joints in gazebo, have you added SimpleTransmission to your joints in your xacro file such as shown below?

<transmission type="pr2_mechanism_model/SimpleTransmission" name="righwheeljoint">
            <actuator name="rightwheelmotor" />
            <joint name="rightWheelJoint" />

Here is a great tutorial about dc motor modeling and controlling for continuous time

modeling controlling

don't forget you apply your control algorithm in discrete time.

Hope it helps, good luck

Originally posted by cagatay with karma: 1850 on 2012-10-11

This answer was ACCEPTED on the original site

Post score: 2

Original comments

Comment by arzhed on 2012-10-11:
Well, as I said, I already tried changing my pid gains following the classic empirical method ("first set "p", then "i", then...") but i never got better results with any configuration. I didn't take much care of damping ratio since it's a pid controller. Should I?

Comment by arzhed on 2012-10-11:
And what do mechanicalReduction and motorTorqueConstant represent? I thought those were for the pr2 and it had nothing to do with any robot in gazebo...

Comment by cagatay on 2012-10-11:
mechanicalreduction for gearboxes, motortorqueconstant is the torque constant of the actuator that you are trying to control. generally motor controllers use PI for velocity control. Maybe your problem is not about pi controller, are you using differential drive plugin for gazebo ?

Comment by arzhed on 2012-10-11:
No I dont, I use a realtime joint controllers for each wheels, and I only added a pid controller and a service to communicate with. I have no actuator in my model, its a basic urdf model (though i added the element in which I specified the joint name, but the other values dont matter)

Comment by arzhed on 2012-10-11:
Concerning the 3rd wheel, i thought it might cause some problem because of friction, for instance...


Your Answer

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