ros / ros_tutorials

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

Fixing issue #43, with [-pi, pi) scope for theta #46

Closed zhoulaifu closed 6 years ago

zhoulaifu commented 6 years ago

The fix proposed by jarvisschultz (#45) is nice but it introduces two new functions in draw_square.cpp, which, IMHO, makes the tutorial code unnecessarily more complicated. Besides, its newly introduced functions use the built-in constant M_PI (3.14159265358979323846264338327950288), rather than PI defined in draw_square.cpp (3.141592) -- the inconsistency would make the tutorial harder to understand, which could potentially trigger hard-to-detect, floating-point-related bugs later on (e.g. when the turtle moves for longer time).

Therefore, I have proposed a simpler, one-line solution that avoids the aforementioned issues. Given that the convention is to have the angle of a turtlesim/Pose to be within [-pi,pi), the fix just added one line in draw_square.cpp that follows this convention.

dirk-thomas commented 6 years ago

Thanks for the patch.