Robust synchronization in SO(3) and SE(3) via low-rank and sparse matrix decomposition