You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi.
In turtle.cpp for ros2 turtlesim, normalizeAngle takes a float as an argument.
However, the data passed into the function is of size double when the function is called, and gets truncated to become nan.
...
ang_vel_ = vel->angular.z; // type of geometry_msgs::msg::Twist.angular.z is float64 (double)
...
orient_ = orient_ + ang_vel_ * dt; // orient_ is of type qreal, which is double
orient_ = normalizeAngle(orient_); // double-sized data gets truncated to nan
When a control program publishes to /cmd_vel a Twist message in which angular.z is set to a double-sized value, normalizeAngle ends up returning nan. As a result, orient_ becomes nan, and accordingly, theta, x, y of the turtle's Pose becomes nan in the subsequent lines. This effectively removes the turtle from the frame. The "clamping" logic fails to put the turtle back in the frame, as it compares nan with integers.
Hi.
In
turtle.cpp
for ros2 turtlesim,normalizeAngle
takes afloat
as an argument.However, the data passed into the function is of size
double
when the function is called, and gets truncated to becomenan
.When a control program publishes to
/cmd_vel
a Twist message in whichangular.z
is set to adouble
-sized value,normalizeAngle
ends up returningnan
. As a result,orient_
becomesnan
, and accordingly,theta
,x
,y
of the turtle's Pose becomesnan
in the subsequent lines. This effectively removes the turtle from the frame. The "clamping" logic fails to put the turtle back in the frame, as it comparesnan
with integers.e.g., Published message:
Result:
Tested and confirmed on the
foxy-devel
branch, but this problem affects all ros2 branches.The text was updated successfully, but these errors were encountered: