Skip to content

Watching a Forest Replay

A SITL run writes a log of everything the stack saw and did. trace_export turns the log into a replay in reflex-trace/1, the trace format of reflex, with the field the run flew as the replay’s scene: each obstacle a cylinder drawn as a tree, the goal, and the geofence. This page plays two replays in reflex’s trace player. The player runs nothing: it shows the logged truth sample by sample, with its provenance underneath.

Baseline s0-gt-pid flies a straight line from the pad to the goal at 3 m/s on the true state, and avoids nothing (bring-up plan). On the forest field each seed grows a different forest, so whether a run gets through is up to the forest: over 100 seeds, 32 reach the goal at every cruise speed tried.

The run is scenarios/s0-forest-collision.yaml, seed 1706. Its score: it collides with obstacle 0 at 11.8 s, 41.0 m along its path and 10.4 m short of the goal.

Where does a straight line through the forest hit a trunk? 1× real time
World: z up · Body: x forward, y left, z up
Rotors (PX4 Quad X): 0 FR, 1 RL spin CCW · 2 FL, 3 RR spin CW
Scene: 56 entities · Collision shapes: what a simulation tests
Thrust arrows: 1 N = 5 cm · Grid: 0.5 m · Body axes: x red, y green, z blue
Position [m] x y z dashed: reference
Rotor thrusts [N] Thrust

t = 0.000 s / 13.750 s

Keys (with the player focused): Space play/pause · ← → one sample (Shift: ten) · Home/End · [ ] speed

The SITL run of baseline s0-gt-pid on scenarios/s0-forest-collision.yaml (seed 1706), sampled every 0.05 s from the 1 kHz truth. The vehicle takes off at 0.03 s, climbs to the goal's 2 m, and flies the straight line toward the goal 50 m away at about 3 m/s. At 11.8 s the vehicle, a sphere of the scenario's 0.25 m collision radius, touches the trunk of obstacle 0: the run has collided, and the replay ends 2 s later. The scene is the forest the seed grew: 54 trunks drawn as trees, the goal (green) and the geofence. Collision shapes shows the trunks the scorer tests. The first panel plots the true position with the planner's reference dashed; the second the rotor thrusts at the cursor.

  1. takeoff
  2. obstacle collision (obstacle 0)

What to look for:

  • The line doesn’t bend. The reference runs straight at the goal, and the vehicle follows it into the trunk: the baseline sees the obstacles (the oracle reports them every frame) but doesn’t use them.
  • The collision event. Seek to it with its button. Turn on Collision shapes to see the trunk the vehicle’s sphere touched; the canopies are only drawn.

The run is scenarios/s0-forest-near-miss.yaml, seed 1710. Its score: it reaches the goal in 14.3 s from takeoff, along 50.5 m, and its closest approach leaves 0.056 m between the vehicle’s 0.25 m collision sphere and a trunk.

How close does a straight line pass the trunks when it gets through? 1× real time
World: z up · Body: x forward, y left, z up
Rotors (PX4 Quad X): 0 FR, 1 RL spin CCW · 2 FL, 3 RR spin CW
Scene: 56 entities · Collision shapes: what a simulation tests
Thrust arrows: 1 N = 5 cm · Grid: 0.5 m · Body axes: x red, y green, z blue
Position [m] x y z dashed: reference
Rotor thrusts [N] Thrust

t = 0.000 s / 16.350 s

Keys (with the player focused): Space play/pause · ← → one sample (Shift: ten) · Home/End · [ ] speed

The SITL run of baseline s0-gt-pid on scenarios/s0-forest-near-miss.yaml (seed 1710), sampled every 0.05 s from the 1 kHz truth. The vehicle takes off at 0.03 s, climbs, and flies the straight line to the goal. It passes one trunk with 0.056 m to spare beyond its 0.25 m collision radius, and reaches the goal's 1 m radius 14.3 s after takeoff; the replay ends 2 s later, with the vehicle holding at the goal. The scene is the forest this seed grew: 54 trunks drawn as trees, the goal and the geofence. The first panel plots the true position with the planner's reference dashed; the second the rotor thrusts at the cursor.

  1. takeoff
  2. reached the goal

The same straight line, through another forest: nothing changed but the seed. That’s why s0-gt-pid is the lower bound an avoiding planner must beat.

Build the tools and record a run, then export it, from the repo root:

Terminal window
cmake --preset gcc-release && cmake --build --preset gcc-release
b=build/gcc-release
$b/sitl_s0-gt-pid --scenario scenarios/s0-forest.yaml --out run.brlog
$b/apps/trace_export --log run.brlog --scenario scenarios/s0-forest.yaml --out replay.json

--scenario must be the file the log was recorded from: trace_export checks its hash against the log’s, and takes the trace’s seed and physics step and the scorer’s collision radius and speed limit from it. --rate sets the sample rate (20 Hz by default); it must divide the physics rate. tools/gen_replay.sh records this page’s two replays.

To play a replay on a page, import the player and the trace in an .mdx document in docs/, as this one does:

import TracePlayer from '@branes-ai/trace-player/TracePlayer.astro';
import replay from '@site/traces/my-replay.json';
<TracePlayer trace={replay} title="…?" description="…" plots={[…]} />

The player refuses a trace that isn’t valid reflex-trace/1, so the docs build fails rather than publish a broken replay.