Skip to content

Runtime の lifecycle

SimulationInstance::step() は fixed physics interval 一つを、13 個の canonical phase で進めます。 phase order は execution mode や ROS integration によって変更されません。

標準 phase sequence

Order Phase Responsibility
1 DeferredActionsCommit boundary まで defer された physical action を確定する
2 ExternalInputCommit ingress mailbox の accepted input を deterministic に可視化する
3 ContinuousPrescribedState current boundary の authoritative prescribed state を確立する
4 DerivedStateRecompute state mutation 後の MuJoCo derived state を整合させる
5 DeviceUpdate 各 Device が自身の acquisition clock と delivery queue を進め、due output を可視化する
6 ActuatorApplication component-owned ActuatorDriver の command semantics を適用して actuator value を決める
7 PhysicsStep MuJoCo integration を一 interval 実行する
8 PostPhysicsSnapshot derived state を整合させ、completed boundary の read-only state を確立する
9 InteractionEvaluation domain interaction proposal を評価する
10 DomainCommit domain proposal を transaction として commit する
11 Observer committed domain state と completed physical state を観測する
12 TraceRecord step の semantic trace frame を確定する
13 ExternalOutputPublish runtime 外へ出す immutable output boundary を確定する

Boundary model の考え方

physics step 開始前の state を P_n、integration 完了後の coherent state を P_(n+1) と考えます。 PostPhysicsSnapshot は position-dependent derived state と sensor state が completed qpos/qvel と一致するように mj_forward 相当の再計算を済ませ、owner thread 上の Interaction と Observer に read-only MujocoReadView として公開します。 SimulationSnapshot の full-state copy は snapshot() など copied value が必要な boundary でだけ作ります。

この再計算がなければ、integration で qpos が進んだ一方、sensor data が一つ前の boundary を表す組み合わせを観測する場合があります。

Completed boundary の derived state

physics integration 後、次の boundary で使う position / velocity derived state は必ず再構築します。 kinematics、collision、constraint construction、position/velocity sensor state はこの prefix に含まれます。

actuation force、acceleration-stage sensor、constraint force などの suffix は、execution policy により consumer が必要とするまで遅延できます。 標準 Device、Interaction、Observer は必要な state level を runtime contract として宣言し、force-bearing API、snapshot、semantic trace は必要時に FullForward へ昇格します。 この最適化は acquisition time、delivery time、phase ordering、physics parameter を変更しません。

SimulationHost の production default は lazy completed-boundary forward を有効にします。 未知の custom runtime capability は保守的に FullForward を要求します。

Device の timing

各 Device runtime は自身の nominal schedule と quantized execution boundary を保持します。 acquisition 後の sample は component-owned latency queue に入り、同じ DeviceUpdate boundary で due sample だけが controller-visible になります。 このため Device ごとの clock は global kernel schedule graph を増やしません。

Controller は SimulationInstance の外側で DeviceOutput を読み、結果を ExternalInput として enqueue します。 入力が runtime から見える時点は ExternalInputCommit だけなので、ROS controller と in-process SIL controller で visibility contract を分けません。

Actuation の timing

Controller output は committed ExternalInput として trace に残ります。 command transport、timeout、hardware-specific conversion は component-owned ActuatorDriver が保持し、kernel は最終的な ActuatorApplication だけを記録します。

このため controller output と MuJoCo へ適用された値の差は、committed_inputs と actuator_applications の境界で比較できます。

Fault state の扱い

runtime invariant が破れた Instance は faulted state と fault phase を保持します。 failure message だけでなく canonical phase を diagnostic に含めることで、同じ logical error でも lifecycle のどこで発生したかを特定できます。