A reading trail through real source

Engine map.

Start from the behavior you want to understand, then enter the smallest relevant file. The map distinguishes Python task logic, the native physics core, its WebAssembly build, and browser presentation.

Python sceneruntime ABIC++ substepstelemetrytask / browser

Behavior-to-source map

I want to…ReadLook forLesson
Author a scenepython/lavendersim/scene.pyScene, body/joint/site/sensor/actuator buildersCh. 2–5
Validate and loadpython/lavendersim/runtime.pyCodeSceneEnv and native ABI bindingsCh. 1–12
Apply controlsengine/physics.cppupdate_controller_targets, commanded_effortCh. 12
Detect contactsengine/physics.cppdetect_contacts, collide_pair, GJK/EPA helpersCh. 8
Reuse impulsesengine/physics.cppsave_contact_cache, warm_start_contactsCh. 9, 11
Solve joints/contactengine/physics.cppsolve_joint_velocity, solve_contact_velocityCh. 7, 9–11
Integrate and projectengine/physics.cppintegrate_orientation, project_joint, substepCh. 1, 7, 12
Sample sensorsengine/physics.cppupdate_imu_sensors, update_tactile_sensorsCh. 12
Read diagnosticspython/lavendersim/runtime.pyobservations, collision/solver/pipeline trace accessorsCh. 7–12
Define RL taskspython/lavendersim/env/tasks.pyregistered task reset, reward, terminationEnvironment catalog
Create by registry IDpython/lavendersim/env/core.pyregister, make, spec, list_envsCh. 12
Vectorize workersexperiment/vector_env.pyProcessVectorEnvCh. 12
Render in browserengine/index.template.htmlWebGL renderer, live Python messages, UI commandsTraining & web
Verify WASM ABIscripts/check_wasm_exports.mjssemantic native-style checks inside WebAssemblyCh. 7–12

Trace one env.step(action)

  1. The task validates a fixed-shape action and translates it into named joint commands.
  2. CodeSceneEnv.step writes controls across the native ABI and requests the control interval.
  3. sim_step divides that interval into bounded substeps and resets public diagnostics.
  4. substep follows the nine stages explained in Chapter 12.
  5. The runtime exposes body, joint, site, contact, sensor, solver, collision, and pipeline buffers as NumPy arrays.
  6. The task flattens policy-visible signals, computes reward and termination, and may publish richer telemetry to the web server.
python
observation, reward, terminated, truncated, info = env.step(action)
# task observation: flat policy input
# env.sim.observe(): rich engine telemetry
# info: task reward terms and diagnostics

Who owns which truth?

LayerOwnsDoes not own
Scene DSLTopology, geometry, materials, sensors, actuator configurationEpisode reward or trained behavior
C++ engineRigid-body state, contacts, constraints, actuator response, native sensor samplesTask success or PPO policy
lavendersim.envReset distribution, policy observation, reward, termination, horizonContact response implementation
Experiment toolingVector workers, PPO collection/update, checkpointingScene physics semantics
Python web serverAuthoritative live state, commands, targets, overlaysStatic Pages physics
BrowserWebGL view, controls, pointer targets, optional local WASM steppingTraining decisions when Python is authoritative

Four source-reading routes

30 MIN

A falling body

Scene sphere → runtime step → gravity/force accumulation → integration → body observation.

60 MIN

A bouncing contact

Pair filtering → narrow phase → manifold → restitution bias → normal impulse → contact telemetry.

90 MIN

An articulated leg

Joint builder → coordinate measurement → actuator effort → joint row solve → projection → joint observation.

90 MIN

Python to browser

Environment telemetry → live server message → transform application → overlay draw → pointer command back to Python.

VERIFY

Read tests beside code

Search tests/ and tests/tutorials/ for the public behavior before trusting a comment or screenshot.

COMPARE

Keep models separate

Reference NumPy labs teach algorithms; they do not imply the C++ engine implements every reference algorithm.

Native and WebAssembly share a deliberately small ABI

scripts/build_wasm.sh exports the same scene-construction, stepping, control, and telemetry functions used by the web runtime. scripts/check_wasm_exports.mjs checks behavior—contacts, controls, solver state, and pipeline order—not merely that names exist. Old JSON scene fields receive defaults in the JavaScript loader.

Best debugging habit: construct the smallest scene that preserves the bug, turn on the closest diagnostic buffer, assert the numerical cause, and only then inspect its rendering.