localizationgpsrosimurviz

ROS2 Node Publishing GPS Data Drifts Out of Bounds After Several Seconds


ROS2 Node: GPS and IMU Data Publishing - Position Drift Issue After Initial Accuracy

I'm developing a ROS2 node that reads GPS and IMU data from a file and publishes it to various ROS2 topics (sensor_msgs::msg::NavSatFix, geometry_msgs::msg::PoseWithCovarianceStamped, and sensor_msgs::msg::Imu). The node performs as expected at startup, with accurate data and correct pose behavior. However, after a few seconds, the published data starts to drift out of bounds, and the system begins displaying incorrect positions.

Problem Description:

Code Overview:

Below is a simplified version of my node. The full node reads from a file, converts latitude/longitude to UTM coordinates, and publishes GPS, pose, and IMU data to the respective topics.

CODE: https://codefile.io/f/d0yZrBEtTL

Troubleshooting Attempted:

Specific Questions:

  1. Why does the system appear to function correctly at the beginning but starts drifting out of bounds after a few seconds?
  2. Could there be a cumulative timing or precision error in my loop that's causing this drift? How can I mitigate it?
  3. What are some best practices to ensure the GPS and pose data remain accurate over time when processing and publishing data in a loop like this?

Additional Context:

Any insights or suggestions on how to debug or resolve this issue would be greatly appreciated!


Solution

  • GPS gives accurate results at low frequency, while IMU gives results at high frequency and the amount of error increases over time, so I think the reason for the drift is due to the IMU.

    Possible causes and solutions:

    1. There may be a timestep error. Check the GPS and IMU timestamps and make sure they are in the same time range.

    2. The IMU may not be properly calibrated. Review the IMU outputs and update your Bias values.

    3. Try running gyro and acceleration data through the Mahony orientation filter and using Kalman in a way that is compatible with GPS. This will allow the accumulated errors to be tolerated by GPS.

    Note: Gyroscope data may cause drift, reduce Gyroscope confidence to avoid this

    In this section you can find sample codes for IMU filtering.