I want to turn a position model in stageros a set angle. So I would need to publish Twist messages with an angular velocity to make it turn.
Say I want to turn a robot 180 degrees (or pi radians). How would I write something in C++ to make it stop turning with angular velocity after it turns 180 degrees. I know that I need to send the Twist messages in a loop but I don't know what the condition would be.
How would I check that the robot has reached the desired heading?
Originally posted by Clefairy on ROS Answers with karma: 11 on 2012-08-15
Post score: 0
Original comments
Comment by Clefairy on 2012-08-15:
@joq How would I check that it's reached the desired heading though? That's the part I'm having trouble with.
Comment by Clefairy on 2012-08-16:
@joq I already have the heading of the robot and the heading it needs to reach. I have a while loop that sends Twist messages with angular velocity. How do I get out of that loop once it reaches the desired heading or what should the condition for the while loop be?
Comment by Clefairy on 2012-08-16:
Because while (currentAngle != desiredHeading)
does not work since the angular velocity can cause it to overshoot it.
Comment by joq on 2012-08-16:
It probably will overshoot. You need a feedback control loop, something like a PID controller: http://en.wikipedia.org/wiki/PID_controller
Comment by Clefairy on 2012-08-16:
@joq I'm sorry I'm not that familiar with PID controllers and using feedback control loops. I've read through the Wikipedia page but don't really understand what I need to do. Is there an example somewhere for roscpp?
Comment by Rydel on 2012-08-17:
I think a PID controller is a little to advanced for this problem, basically you need a feedback loop; i.e. the robot needs to look at its orientation first from odom, then start turning, while its turning continually keep checking odom for the new orientation until you have turned the desired angle
Comment by q8wwe on 2019-08-11:
Did you find solution?