swri-robotics / mapviz

Modular ROS visualization tool for 2D data.
BSD 3-Clause "New" or "Revised" License
371 stars 144 forks source link

[Foxy] Path-Plugin points are drawn inaccurately #732

Closed spam-12345 closed 3 years ago

spam-12345 commented 3 years ago

Hello,

I want to use the Path-Plugin for visualization some GPS points. So I created a publisher for the data (nav_msgs/msg/Path, header_id: map) - no problem.

However, when the points are drawn in mapviz, they deviate by 40-80m. For example: published point: 10.62379365716494, 47.81859718119835 what mapviz displays: 10.6238062955368, 47.8187538394427 (zoomed in map and read off) Have I overlooked the possibility of setting the precision? For accuracy in the centimeter range I would probably need double. Or could it be a problem with the different transformations?

The fixed frame in mapviz is map.

I'm using ROS2 (foxy) and mapviz on dashing-devel with Ubuntu 20.04.

malban commented 3 years ago

It looks like nav_msgs/Path already uses float64, so that's probably not the issue. Truncating GPS to float32 results in ~meter accuracy I think, anyway, so that wouldn't explain the 40+ meter error.

If you are publishing the nav_msgs/Path with lat/lon data, as opposed to meters, then it should be in the /wgs84 frame, that is used by mapviz to distinguish it from a normal cartesian tf frame.

To display GPS data in a ROS/tf context, it needs to be projected to a cartesian coordinate system that is tied to a ROS tf frame. Mapviz uses a local plane defined with a GPS origin point to do this. If that origin point is a large distance from the data being visualized, the data can be distorted.

In the default launch file, the origin is defined here and the local plane is associated with the map tf frame. You'll want to make sure the local origin is somewhere in the vicinity (within ~100 miles) of your data to minimize distortion from the projection.

spam-12345 commented 3 years ago

The /wgs84 frame solved the problem. Thanks!