ros / ros_tutorials

Code used in tutorials found on ROS wiki
http://wiki.ros.org/ros_tutorials
805 stars 540 forks source link

Added a check to make sure orientation is not zero. Fixes #47. #49

Closed betab0t closed 5 years ago

betab0t commented 5 years ago

Prevent the turtle from moving on the y-axis when orientation / angular velocity is zero as described in #47.

dirk-thomas commented 5 years ago

@betab0t Thank you for the patch.

@zhoulaifu Can you please try if this patch resolves your problem and comment here. Thanks.

dirk-thomas commented 5 years ago

@zhoulaifu Friendly ping.

dirk-thomas commented 5 years ago

After reviewing the original ticket as well as the patch I don't think this case should be worked around like this. With these extreme input data you will experience inaccuracies due to floating point rounding. Just handling this single case differently doesn't make much sense - the same problem would appear for other orientations. Most visibly for multiples of PI/2 but at the end of the day this happens for every angle.

E.g. imagine the turtle moves straight with an arbitrary orientation when moving repeatedly forward in small steps the resulting segments will form a straight line but as soon as it moves a long step and the turtle moves out of the visible area it will be clamped back into a visible range - and for large steps that will move the turtle into a corner. That last segment would not form a straight line with the previous segments.

Anyway I also commented on the original ticket and think this PR as well as the ticket can be closed without changing the behavior. Please feel free to continue commenting.