Skip to content

fix(sim): ignore teleport for missing robot ids - #8

Open
taitaitai58 wants to merge 3 commits into
masterfrom
fix/teleport-missing-robot-guard
Open

fix(sim): ignore teleport for missing robot ids#8
taitaitai58 wants to merge 3 commits into
masterfrom
fix/teleport-missing-robot-guard

Conversation

@taitaitai58

Copy link
Copy Markdown

Summary

  • GameObjects.qml の Replacement ハンドラで children[id] が無い/reset が無い場合は no-op
  • m2 は robotCount 分しかロボットを作らないため、mirror-kickoff の id 11..15 退避 teleport が TypeError になっていた

Test plan

  • mirror_raven.sh 起動時に Cannot call method 'reset' of undefined が出ないこと
  • 存在する id(0..10)の teleport は従来どおり効くこと

Made with Cursor

taitaitai58 and others added 3 commits July 12, 2026 17:21
Replacement (robot/ball teleport) already called DynamicRigidBody.reset()
on position, but two gaps left it looking like the physics body never
really moved:

- mocSim_BallReplacement.vx/vy were parsed but silently dropped, so a
  teleported ball with a requested launch velocity just sat still.
- A robot's previously-commanded velocity (veltangent/velnormal/velangular)
  stayed latched in the Robot model after a teleport, so the very next
  tick re-applied it and the robot immediately drove off again — plus the
  QML-side pose bookkeeping (prePoses/preVelocities) still held the
  pre-teleport pose, reading the position jump itself as a brief phantom
  velocity through MotionControl's accel limiter.

Fixes:
- Robot::resetMotion() zeroes kick/spinner/tangent/normal/angular targets
  and clears the actuation-delay buffers; observer.cpp calls it for the
  replaced robot before re-emitting {blue,yellow}RobotsChanged so QML
  picks up the stop immediately instead of waiting on the next commands
  packet.
- onRobotReplacementRequested seeds prePoses/preVelocities to the
  just-placed, at-rest pose so there's no phantom one-tick velocity.
- observer.cpp now forwards ball vx/vy (m/s -> scene mm/s, same axis
  convention as position) through a widened ballReplacementRequested
  signal; GameObjects.qml's new placeBall() helper (factored out of the
  existing mouse "place ball" path, which behaves identically to before)
  applies it via setLinearVelocity() when present.

Verified headless (QT_QPA_PLATFORM=offscreen) by sending mocSim_Packet
Replacement datagrams via protoc --encode and reading back vision:
- Robot teleported mid-command (veltangent latched) now lands and stays
  within ~0.05mm over 1.3s, vs. previously coasting away at full speed.
- Ball Replacement with vx/vy now visibly travels and decelerates under
  the existing slip/roll friction model instead of sitting still.
- Ball Replacement without vx/vy (the common case) is unaffected: still
  placed at rest.
- A second robot's independent, ongoing velocity command is unaffected
  by another robot's Replacement (no cross-talk).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment said ~46 g golf ball but the PhysX mass was 46.0 while robots
use 2.5 kg, so the ball was ~18× heavier than a robot and ~1000× a real
SSL ball. Collision impulse ratio is now correct; friction impulses use
the same ballMass SSOT.

Co-authored-by: Cursor <cursoragent@cursor.com>
mirror-kickoff parks ids 11..15 for leftover-robot sims, but m2 only
instantiates config robotCount bodies. Calling reset on undefined
children threw TypeError on every kickoff teleport.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant