MichaelGrupp / evo

Python package for the evaluation of odometry and SLAM
https://michaelgrupp.github.io/evo/
GNU General Public License v3.0
3.33k stars 745 forks source link

Question about Umeyama alignment #593

Closed robincourant closed 9 months ago

robincourant commented 9 months ago

I want to extend my appreciation for this project - it's been a valuable tool for my work! Thanks!

I'm using Umeyama alignment to work with trajectories consisting of 9 poses. They all share the same rotations initially but have different translations. When I align them, it works fine for the translations, but sometimes it flips the rotations, even though they were identical before alignment. Has anyone else experienced this behaviour? Any ideas why it's happening?

MichaelGrupp commented 9 months ago

This sounds like a question related to your specific data, so this can't really be answered without a reproducible example with trajectory files.

robincourant commented 9 months ago

Hi, thanks for your feedback, I've attached two trajectory files (traj_1.txt and traj_2.txt) that produce the error I described, using the following command: evo_traj kitti --ref=traj_2.txt traj_1.txt --align

Am I doing something wrong? I've found an alternative with a leat square on only scale an translation.

MichaelGrupp commented 9 months ago

Looking at the two trajectories, this seems to be the expected result because the translations go into flipped directions relative to the first pose of each trajectory.

You can see this with origin alignment --align_origin, which forces the two trajectories to start from the same position and orientation. I also added --correct_scale because the shape of the trajectory seems to be the almost same apart from scale.

evo_traj kitti --ref=traj_2.txt traj_1.txt --correct_scale --align_origin --plot_mode xyz -p

plot xyz

Umeyama alignment minimizes the distance between corresponding positions. So in your case you get well-aligned positions, but the orientations don't match because the translations are going into opposite directions relative to the poses. But this is expected with this kind of data.

plot2

robincourant commented 9 months ago

Great, thanks a lot for your detailed reply! I see your point.

I found an alternative with least squares to find a scale parameter and a translation, I put it there if it can help someone.

image