Ask Your Question
0

How do I turn an exact angle using Twist messages?

asked 2012-08-15 16:53:09 -0500

Clefairy gravatar image

updated 2014-01-28 17:13:20 -0500

ngrennan gravatar image

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?

edit retag flag offensive close merge delete

Comments

@joq How would I check that it's reached the desired heading though? That's the part I'm having trouble with.

Clefairy gravatar imageClefairy ( 2012-08-15 17:23:47 -0500 )edit

@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?

Clefairy gravatar imageClefairy ( 2012-08-16 04:28:03 -0500 )edit

Because while (currentAngle != desiredHeading) does not work since the angular velocity can cause it to overshoot it.

Clefairy gravatar imageClefairy ( 2012-08-16 04:33:24 -0500 )edit

It probably will overshoot. You need a feedback control loop, something like a PID controller: http://en.wikipedia.org/wiki/PID_controller

joq gravatar imagejoq ( 2012-08-16 12:11:25 -0500 )edit

@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?

Clefairy gravatar imageClefairy ( 2012-08-16 17:59:36 -0500 )edit

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

Rydel gravatar imageRydel ( 2012-08-17 09:32:12 -0500 )edit

Did you find solution?

q8wwe gravatar imageq8wwe ( 2019-08-11 05:41:47 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2012-08-15 17:17:35 -0500

joq gravatar image

Duplicate of this question.

edit flag offensive delete link more

Comments

0

answered 2012-08-15 20:04:00 -0500

weiin gravatar image

This should help.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-08-15 16:53:09 -0500

Seen: 5,966 times

Last updated: Aug 16 '12