Skip to content

dimos map tooling, stream alignment#2306

Merged
paul-nechifor merged 85 commits into
mainfrom
feat/ivan/stream_alignment
Jun 3, 2026
Merged

dimos map tooling, stream alignment#2306
paul-nechifor merged 85 commits into
mainfrom
feat/ivan/stream_alignment

Conversation

@leshy

@leshy leshy commented May 29, 2026

Copy link
Copy Markdown
Member

dimos map utilities for dataset collection team

you can ignore those, they are temporary,

changing pose source for observation stream, rendering global map, loop closures etc. lots of tooling (temporary and will change a lot)

dataset validation instructions document

stream alignment

a very simple stream.align tool - this needs much more work. multi stream input and output, interpolation of poses/transforms etc

leshy added 30 commits May 24, 2026 18:53
Replaces the monolithic pgo_then_voxels with four primitives over
mem2 Streams and Transforms:

  pgo_keyframes(lidar)            -> Stream[Keyframe]
  keyframes_to_corrections(kfs)   -> Stream[Transform]   (world_corrected <- world_raw)
  make_interpolator(corrections)  -> (ts) -> Transform   (SLERP + linear, endpoint-clipped)
  apply_corrections(stream, corr) -> Stream[T]           (shuffles obs.pose)

Drift correction is now a first-class, reusable Stream[Transform] that
any pose-stamped consumer can apply — same math as before (rigid
T_corr = T_global @ T_local^-1 per keyframe, SLERP + linear interpolation
between bracketing keyframes), just composable.

dimos map --pgo migrates to the new primitives; pgo_then_voxels is
deleted. The internal _SimplePGO / PGOConfig / _KeyPose machinery stays
in pgo.py and is imported by pgo2.
Renames:
  pgo.py  -> pgo_internals.py   (gtsam/ICP machinery)
  pgo2.py -> pgo.py             (public Stream-shaped API)

`dimos.mapping.relocalization.pgo` is now the canonical import path
(`pgo_keyframes`, `keyframes_to_corrections`, `make_interpolator`,
`apply_corrections`, `correction_at`, `Keyframe`). The internal
_SimplePGO / PGOConfig / _KeyPose / _icp / _voxel_downsample helpers
live in pgo_internals.py and are imported lazily inside pgo.py to keep
gtsam off the public-API import path.
Adds test_pgo.py covering pose normalization on Observation, the Transform↔Pose3
conversion helpers, the interpolator edge cases, apply_corrections behavior, and
a real-recording smoke test (skipped when data/go2_short.db is absent).
Annotates the two map.py helpers so they pass mypy. Removes leftover section
divider comments to satisfy the no-section-markers project rule.
The colors-copy block in `PointCloud2.transform` calls `self.pointcloud`
to check `has_colors()`, which forces a tensor->legacy conversion on
every invocation. With `pgo --full-pgo` rebuilding from hundreds of
lidar frames, that hidden allocation dominates the per-frame cost. The
colors path was lidar-irrelevant (lidar clouds have no colors anyway)
and the feature it was meant to support never landed; remove it so
transform() stays a clean numpy round-trip.
leshy added a commit that referenced this pull request Jun 1, 2026
Add from_time/to_time (relative to the first observation) and
from_timestamp/to_timestamp (absolute epoch seconds) for windowing a
stream by time. A trailing to_time is a duration measured from the
current start, so from_time(2).to_time(30) reads as "skip 2s, take the
following 30s"; frames mix freely (from_timestamp(ts).to_time(30)).

Shared base for the stream-alignment (#2306) and go2dds (#2314)
branches, which both need this windowing API.
Pulls the stairs dataset LFS pointer from feat/ivan/go2stairs so the map
tooling can use it; object already on remote LFS store.
Comment thread dimos/mapping/loop_closure/pgo_auto.py
…nment

# Conflicts:
#	dimos/memory2/stream.py
#	dimos/memory2/test_stream.py
@leshy leshy mentioned this pull request Jun 1, 2026
leshy added 2 commits June 1, 2026 20:51
The self-hosted CI image's published :dev tag is stale (predates
libturbojpeg0-dev in docker/python/Dockerfile), so TurboJPEG() raises at
runtime and the four verbs that decode the color_image stream fail. Guard
them with skipif so they skip on a lib-less image and still run where the
native lib is present.
Comment thread dimos/mapping/utils/cli/map.py
Comment thread dimos/mapping/utils/cli/rename.py Outdated
Comment thread dimos/memory2/stream.py Outdated
Comment thread dimos/memory2/type/observation.py
Comment thread dimos/mapping/utils/cli/summary.py Outdated
Comment thread dimos/mapping/loop_closure/pgo_auto.py
leshy added 2 commits June 2, 2026 16:58
- dimos map global / replay: new --bottom-cutoff option, threaded to
  PointCloud2.to_rerun(bottom_cutoff=) for global/accumulated maps only
  (raw lidar frames untouched); e.g. --bottom-cutoff 0 strips the floor.
- rename/summary/replay/replay-marker: usage docs now reference the
  `dimos map <verb>` commands instead of `python -m ...cli.<mod>`.
- observation: drop redundant explicit _data_lock=Lock() in with_pose/tag/
  derive; __init__ creates a fresh per-instance lock when None.
Comment thread dimos/memory2/type/observation.py
leshy added 4 commits June 2, 2026 18:46
The entry point is `dimos map <verb>` (self-documented via --help); don't
document running the modules directly. summary.py keeps its rewritten usage
line per reviewer suggestion.
Both copied the source's _data_lock through the fields() dict while setting
_loader=lambda: self.data. Accessing the derived obs while the source was
still unloaded re-entered the same non-reentrant lock on one thread →
deadlock. Caught by test_attaches_pose_and_keeps_payload_lazy.

Regression from 07f4e4a, which dropped the explicit
_data_lock=threading.Lock() from both methods.
paul-nechifor
paul-nechifor previously approved these changes Jun 3, 2026
@paul-nechifor paul-nechifor enabled auto-merge (squash) June 3, 2026 00:28
…nment

# Conflicts:
#	dimos/mapping/utils/cli/map.py
#	dimos/memory2/store/base.py
#	dimos/memory2/stream.py
#	dimos/memory2/test_stream.py
@paul-nechifor paul-nechifor merged commit 6a007ac into main Jun 3, 2026
21 checks passed
@paul-nechifor paul-nechifor deleted the feat/ivan/stream_alignment branch June 3, 2026 03:09
@bogwi bogwi mentioned this pull request Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants