cartographer-project / cartographer_ros

Provides ROS integration for Cartographer.
Apache License 2.0
1.62k stars 1.2k forks source link

Extracting trajectory/poses #332

Closed struncp closed 7 years ago

struncp commented 7 years ago

Short version: I haven't found anything adressing this topic, so: Is there a way how to get robots trajectory from Cartographer with ROS?

Long version: Hello, I am comparing SLAM algorithms based on their poses throughout their trajectory in my thesis and I can't come up with a way to get a trajectory from cartographer. I use .bag data with ground truth from MIT Stata center (link below). Currently I'm obtaining trajectory via hector trajectory server and it worked fine with both Hector SLAM and gMapping but Cartographers trajectory is quite off

cartographer_offset

This is from run at 0.2 speed. When I run it at realtime and robot is coming back from that part "north" to the main long hall (that part that looks like two curved horns) back that long hall to go "east" it simply skips like this

cartochybakrouzek

I believe there is some hard computing when cartographer is closing the loop from that "north" part which is not compatible with hector trajectory server. I also hope that I have right settings for cartographer because map on the outcome is correct.

source code: https://www.dropbox.com/s/6mhipp0keaj1ee3/cartographer_source.rar?dl=0

used bag: 2012-01-28-11-12-01.bag.noimages (in ground truth) at http://projects.csail.mit.edu/stata/downloads.php

Thanks for any feedback in advance.

RonaldEnsing commented 4 years ago

The ROS service call for a TrajectoryQuery (rosservice call /trajectory_query) can only be done with cartographer in online mode. This service call is not available in offline mode. This means that if you would like to export a trajectory of a pbstream, you would need to load the pbstream as a loaded state file in online mode, only to be able to export the trajectory of that same loaded pbstream file. Is there any method to export the trajectory from the pbstream directly using a command line tool? Or any plan to implement that? Exporting the trajectory from a pbstream to e.g. a list of geometry_msgs/PoseStamped would make it possible to use the exported trajectory in @MichaelGrupp 's SLAM evaluation tool [1].

[1] https://github.com/MichaelGrupp/evo

MichaelGrupp commented 4 years ago

In master, there's rosrun cartographer_ros cartographer_dev_pbstream_trajectories_to_rosbag --input <pbstream> --output <bagfile> src. It does exactly that.

RonaldEnsing commented 4 years ago

In master, there's rosrun cartographer_ros cartographer_dev_pbstream_trajectories_to_rosbag --input <pbstream> --output <bagfile> src. It does exactly that.

Thanks a lot! That's very useful.

BenJamin-ad commented 4 years ago

How do I execute this?

rosrun cartographer_ros cartographer_dev_pbstream_trajectories_to_rosbag --input <pbstream> --output <bagfile>

as I get the following error:

[rosrun] Couldn't find executable named pbstream_trajectories_to_rosbag.

I have sourced my environment using 'source install_isolated/setup.bash'.

arjunskumar commented 2 years ago

rosrun cartographer_ros cartographer_dev_pbstream_trajectories_to_rosbag --input /home/arjun/Desktop/rosbags/bagname.bag.pbstream --output output_bag

This worked for me @BenJamin-ad

Zuhair-A-Ahmed commented 1 year ago

Long version: Hello, I am comparing SLAM algorithms based on their poses throughout their trajectory in my thesis and I can't come up with a way to get a trajectory from cartographer. I use .bag data with ground truth from MIT Stata center (link below). Currently I'm obtaining trajectory via hector trajectory server and it worked fine with both Hector SLAM and gMapping but Cartographers trajectory is quite off

Hello dear, Can you tell me how did you access the estimated trajectory of Gmapping?

MrDarknessWolf commented 1 year ago

hector trajectory server

i know this is YEARs LATER but does anyone know how does hector saves trajectories???