cartographer-project / cartographer

Cartographer is a system that provides real-time simultaneous localization and mapping (SLAM) in 2D and 3D across multiple platforms and sensor configurations.
Apache License 2.0
7.04k stars 2.24k forks source link

Delete trajectory makes cartographer crash #1859

Open mksetaro opened 2 years ago

mksetaro commented 2 years ago

Hi there,

At Yape we have been using cartographer 3d since the beginning of the project and recently we have started working on some customization to make it more suitable for our use case.

While working on that we have noticed that deleting a trajectory was causing the cartographer to crash with two different error traces.

The first one gives the following trace (already mentioned in #1826 and #1767 comment ):

[ INFO] [1632231593.656546094]: I0921 15:39:53.000000 12803 pose_graph_3d.cc:534] Remaining work items in queue: 0 callback result pre terminate called after throwing an instance of 'std::out_of_range' what(): map::at

The second gives:

F0921 15:25:05.650257 11545 optimization_problem_3d.cc:371] Check failed: imu_data_.HasTrajectory(trajectory_id) [FATAL] [1632230705.650795345]: F0921 15:25:05.000000 11545 optimization_problem_3d.cc:371] Check failed: imu_data_.HasTrajectory(trajectory_id)

After some analysis and debugging we've noticed that a missing check to ignore deleted trajectories in OptimizationProblem3D::Solve and PoseGraph3D::RunOptimization() was causing the above mentioned errors.

We have fixed the issue but I still would like to ask if the solution is correct or if we're missing something and the patch could backfire in future.

Thanks and cheers, Michelangelo.