ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

Best guess - because you initialize dt_front and dt_rear as 0, until those get updated by the callbacks, you're dividing by 0, causing NaN to be stored in x.

After the callbacks, your velocities will be processed properly, however x = NaN + delta_x will always be NaN.

The key with NaNs is to think - where could you have divided by 0?


This code could use some rearchitecting on the whole, it's not a good idea to be running the loop separately from the callbacks, as you have the significant chance of either dropping odometry information (getting callbacks faster than your code is looping), or looping over stale data (no data update between two loops - how does this affect your estimate?).

Your best bet may be to look at odometry models for 4 wheel robots, it's definitely not trivial.