ros / ros_tutorials

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

[ros2 turtlesim] turtle.cpp needs to validate float32/float64 input variables #129

Open squizz617 opened 3 years ago

squizz617 commented 3 years ago

There are many places in the code that assume control inputs (i.e., x, y, and theta) are valid floating point numbers. As a result, when one of nan, -nan, inf or -inf is given, the turtle's position becomes infeasible (e.g., x being nan), sometimes even become rendering it uncontrollable.

I suggest adding checks before using these variables, e.g., std::isnan and std::isinf, to prevent unexpected input values from polluting the turtle's state.

audrow commented 2 years ago

Hi @squizz617, thanks for making this issue. Feel free to make a PR with some or all of these fixes. If you do, you can @ me for a review.