Skip to content

Repository files navigation

group-sync-torch

Batched PyTorch solvers for group synchronization: recover absolute poses from noisy pairwise relatives.

Given a connected measurement graph and relatives $\bar{R}_{ij} \approx R_{i}^{\top} R_{j}$ on $\mathrm{SO}(3)$,

$$\min_{R_{i} \in \mathrm{SO}(3)} \sum_{(i,j)\in E} w_{ij}\, \left\| \log\left(R_{i}^{\top} R_{j} \bar{R}_{ij}^{\top}\right) \right\|^{2}.$$

The solution is unique up to a global left action $R_{i} \mapsto Q R_{i}$. This package estimates the poses with a spectral method (connection Laplacian + rounding), then optionally takes geodesic gradient steps on $\mathrm{SO}(3)^{n}$. Rigid motions on $\mathrm{SE}(3)$ are recovered in two stages: sync the rotations, then solve a linear system for the translations.

SpectralSO3Sync is a torch.nn.Module around the solver. examples/outlier_weights.py trains a tiny MLP to downweight junk edges; the eigenvector step is unchanged. That helps on synthetic outliers. It does not replace the linear algebra, and oracle weights (if you already knew the bad edges) are still much better.

SO(3) sync error vs tangent-space noise

Outlier edge weights vs unweighted spectral

Install

uv sync --extra dev

Quickstart

import torch
from group_sync_torch import (
    so3,
    erdos_renyi_edges,
    rotations_from_absolutes,
    spectral_sync,
    refine_rotations,
    mean_geodesic_error,
)

n = 24
R_true = so3.rand_uniform(n)
src, dst = erdos_renyi_edges(n, p=0.35)
graph = rotations_from_absolutes(R_true, src, dst, noise_std=0.2)

R_hat = spectral_sync(graph)
R_hat = refine_rotations(graph, R_hat)

err_deg = mean_geodesic_error(R_hat, R_true).item() * 180 / torch.pi
print(f"mean geodesic error: {err_deg:.2f} deg")
uv run examples/synthetic_so3.py
uv run examples/noise_sweep.py
uv run examples/outlier_weights.py
uv run pytest

Layout

src/group_sync_torch/
  so3.py / se3.py   exp, log, hat/vee, projection
  graph.py          directed relative measurements
  spectral.py       connection-Laplacian solver
  layers.py         nn.Module wrapper (grads into relatives)
  refine.py         geodesic gradient steps
  se3_sync.py       two-stage rigid motions
  metrics.py        left-gauge alignment and error

License

MIT

About

Batched PyTorch solvers for group synchronization on SO(3) and SE(3)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages