Skip to content

SCOPE: Motion plan replay plugin#782

Closed
Marcus (sucrammal) wants to merge 33 commits into
mainfrom
motion-plan-replay
Closed

SCOPE: Motion plan replay plugin#782
Marcus (sucrammal) wants to merge 33 commits into
mainfrom
motion-plan-replay

Conversation

@sucrammal

@sucrammal Marcus (sucrammal) commented Jun 16, 2026

Copy link
Copy Markdown
Member

Changes

  • Adds useMotionPlanReplayer.svelte.ts context managing plan list state (add/remove/select/step) and driving playback through reconcileSnapshotEntities
  • Adds parse-plan.ts (zod-validated extraction of frame_system/trajectory from concatenated plan JSON chunks), build-frame-descriptors.ts (resolves static vs. revolute-joint frames, handles quaternion/euler/OV orientations, model-frame reparenting into per-step transforms), and plan-to-snapshots.ts (renders trajectory steps into Snapshot[])
  • Adds MotionPlanReplayerUI.svelte (floating panel – upload, list, select, remove) and MotionPlanReplayerScrubber.svelte (play/pause/step/seek transport), wired into +layout.svelte and exported from plugins/index.ts
  • Adds PartOfPlan relation (relations.ts) tying every entity spawned for a plan, including nested model assets, to a single plan-root entity, so switching, clearing, or removing a plan cascades cleanup via koota's autoDestroy instead of manual entity bookkeeping
  • Tests: Adds specs for parse-plan, build-frame-descriptors, plan-to-snapshots, and the PartOfPlan relation

Links:

Testing:

  • Open the visualizer, click the "Motion Plan Replayer" dashboard button (or drag-and-drop a plan JSON file) to open the panel
  • Feel free to use some sample plans here.
  • Upload a valid motion plan JSON (frame_system + trajectory) → it appears in the list and the scrubber appears at the bottom
  • Press play → frames animate through the trajectory; step forward/back and drag the scrubber → poses update correctly at each step
  • With one plan active, select a second plan → the first plan's entities (including any model geometry) are fully removed before the second renders
  • Remove the active plan, or click Exit on the scrubber → no leftover entities remain in the scene
  • Drop/upload a malformed or non-plan JSON file → a toast error appears and nothing is spawned
  • Upload a file with a name that's already loaded → the "already loaded" warning toast appears

POC demo:

motion-plan-replay-POC.mov

Salad1:

saladMotionPlanReplay.mov

Vino:

vinoMotionPlanReplay.mov

Cappucina

cappucinaMotionPlanReplay.mov

@changeset-bot

changeset-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e13263d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-10 19:52 UTC

1. Joints (frame_type: rotational) should not be apart of the main tree
2. Geometry: translations vs. translations. One is the offset from origin frame for the attachment point of the next link, the other is the offset from origin frame to geometry center of the link.
Cameras, grippers, and obstacles parented to model frames (e.g. "left-arm") were permanently orphaned because model frames are  never spawned as ECS entities. They now redirect to the arm's end-effector via model.primary_output_frame, falling back to model.links[last].id: Viam's convention that the last link is  always the end-effector.
Updated motion replay entities get their preserved opacity restored, so slider changes stick across scrubs.
Semantic error messages for duplicate or invalid motion plan JSON.
Fill in gaps (large jumps in angle change) with sub-steps, where every joint moves at a velocity proportional to its total delta.
- planToSnapshots unexported
- GeometryDescriptor collapsed: parseGeometry() now returns Geometry | null directly
-  computeJointedLinkPose moved
-  LocalPose → Pose getting rid of unnecessary type.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great POC! looks very nice!

my main things for when we do the full impl are

  1. we should try to be more koota native and create a plan entity and relationships for the plan <--> plan entities
  2. I think we can use zod to parse the plans a little easier
  3. we should strip back some of the (very cool) functionality you added in P0 (i.e. no linear interp between steps, no preserve opacity and visibility (yet), no multiple plans loaded at a time)

Comment thread src/lib/components/FileDrop/FileDrop.svelte Outdated
Comment thread src/lib/components/FileDrop/useFileDrop.svelte.ts Outdated
Comment thread src/app.css
}

/* Push toasts above the motion plan scrubber bar (fixed bottom-4, ~44px tall). */
body.has-scrubber [aria-label='Toasts'] {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: for final impl we probably should look into how to do this with component placements instead of the app css


const clearActivePlan = () => {
for (const entry of entityMap.values()) {
if (world.has(entry.entity)) hierarchy.destroyEntityTree(world, entry.entity)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the final setup, lets look into making a new PlanEntity, which we can then give relationships to all the world entities that are part of it (see the selection plugin https://github.com/viamrobotics/visualization/blob/main/src/lib/plugins/Selection/traits.ts for inspo)

this way we can make this flow more koota native and the relationship has an auto destroy hook e.x. https://github.com/viamrobotics/visualization/blob/main/src/lib/plugins/Selection/relations.ts#L9 so we can make it so all world entities auto clean up when a plan entity is removed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried mirroring the pattern from Selection plugin here: 5631b12. This makes the destroy plan path logically clearer! Is this up to your spec?

Comment thread src/lib/plugins/MotionPlanReplayer/useMotionPlanReplayer.svelte.ts
Comment thread src/lib/plugins/MotionPlanReplayer/parse-plan.ts
Comment thread src/lib/plugins/MotionPlanReplayer/MotionPlanReplayerUI.svelte Outdated
Comment thread src/lib/plugins/MotionPlanReplayer/MotionPlanReplayerScrubber.svelte Outdated
provideMotionPlanReplayer(untrack(() => plans))
</script>

{#if plans === undefined}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be cool if drag and drop just updated the plans array and then we could use the ui for both cases

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Designed a more explicit hook here (f3f70cb) which calls the same addPlan hook from app vs. standalone.

Comment thread src/lib/plugins/MotionPlanReplayer/interpolate-trajectory.ts Outdated
When a frame (e.g. gripper) is parented to a model frame (e.g. left-arm), it should first try to parent itself to the model frame's primary_output_frame, which is the primary tip/end-effector frame. If that metadata is not found, default to the last frame ofthe model frame
- Added src/lib/plugins/MotionPlanReplayer/relations.ts (PartOfPlan relation, autoDestroy: 'source')
- Updated useMotionPlanReplayer.svelte.ts to spawn a planEntity, tag spawned entities (recursively through ChildOf) with PartOfPlan, replace the manual clearActivePlan teardown loop with a single planEntity.destroy(), and drive the coloring/opacity pass off world.query(planRelations.PartOfPlan(planEntity))
@mrloureed

Jason (mrloureed) commented Jul 1, 2026

Copy link
Copy Markdown
Member

Marcus (@sucrammal) Some UX / UI feedback for you:

  • axis helpers are not showing up like they do generally
  • color mapping would be nice if we know the resource type (arm is one color, grippers, etc.) but if we don't have the info it's okay to not do this
  • motion player items look like radio buttons so it's not obvious to me that you can click them to deselect; consider using checkboxes or eye icons instead; maybe the latter for consistency
  • when one uploads a motion file it should auto select
  • move the exit replay button to the right rather than on the left
  • make the movie player widget's background the same as selected button dark gray

@mrloureed Jason (mrloureed) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comment to the ticket for design feedback

- Motion plan items use eyes for toggle visibility
- Scrubber matches color of selected buttons
- Auto-select newly uploaded plans
- Move exit button to the right.
@sucrammal

Marcus (sucrammal) commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Jason (@mrloureed) Re: your UI/UX feedback. Alongside persistent color, opacity, and visibility toggle edits, I'm going to push off implementing axes helpers and anything color at the moment, as per Matthew MacFarquhar (@mattmacf98):

  1. we should strip back some of the (very cool) functionality you added in P0 (i.e. no linear interp between steps, no preserve opacity and visibility (yet), no multiple plans loaded at a time)

But, implemented everything else!

Screen.Recording.2026-07-06.at.4.43.34.PM.mov

@sucrammal Marcus (sucrammal) marked this pull request as ready for review July 7, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants