Skip to content

gym twin: nav@1's plant arm (GymTwin(plant_arm=True)) and its gate - #190

Merged
transfix merged 2 commits into
mainfrom
feat/gym-twin-plant-arm
Nov 16, 2026
Merged

transfix merged 2 commits into
mainfrom
feat/gym-twin-plant-arm

Conversation

@transfix

@transfix transfix commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

The gym twin gets nav@1's plant arm, behind an option: GymTwin(gym, plant_arm=True). The default is unchanged. Write-up: docs/gym-twin.md, gate 5. It needs transfix/libcvc#1286 (plants()' plan), stacked on transfix/libcvc#1284. The second commit mirrors transfix/libcvc#1297 (stacked on #1286), with which nav@1 comes to rest at its goals.

Why. On a vehicle plant, libcvc's drive gives its command through the plant arm (plant_drive), after the control law. The twin had only the control law (bike_control). Replaying nav@1's ticks from the drive the gym reports (its coefficients and carrot), the twin's command departed from the plant's on most agent-ticks within 60 m of a goal: 61 % in gate 5, parked ticks included.

What changed:

  • sdf_nav.bike_control(..., plant=PlantArm(...), steer_now=) is libcvc's plant arm (veh_params::plant):

    • the stopping speed takes off the latency's distance and plans with the gentler of a_brake and a_max;
    • braking may go down to -a_brake (6 m/s² on the Humvee, where the law stopped at a_max, 2 m/s²);
    • the creep floor never exceeds the stopping speed;
    • the steering stays within the plant's lock and within steer_rate × dt of the actuator's angle now;
    • the acceleration returned is the one that reaches the next speed, kept within [sp_min, vmax].

    plant=None is the old path, op for op.

  • GymTwin(gym, plant_arm=True) reads plants()' plan:

    • the vehicle's own a_max, vmax and cornering a_lat, its wheelbase and its footprint discs replace the navigator's in the drive's settings;
    • the latency, a_brake, the slew and the lock go into a PlantArm;
    • it refuses a gym without a plan, or one whose plant modulates the drive.
  • Parking. control(..., parked=) brakes those rows to a stop within the tick, at most at a_brake, as nav@1 parks an agent at its goal. GymTwin.parked(gym) reads which agents the next tick parks. rollout, drive_gym and tick_residuals park a row from the tick that ends within the reach of its goal.

  • control takes ext_steer=, as bike_control does.

  • The stop at the goal (second commit): bike_control(..., stop_at=) is libcvc#1297's veh_params::stop_at. The speed toward each row's goal is held to the speed it stops there from (with the plant arm's latency and braking), over the motion that closes on it. GymTwin(plant_arm=True) applies it where fields()["navigator"]["stop_at_goal"] is set; a libcvc without the key gets no stop.

Gate 5. nav@1 drives three Humvees on dynamic4w on the flat square, 85–115 m to their goals. Each tick the twin is given the gym's state before the tick, the drive the gym reports, and whether the tick parks the agent. Its command is compared with the one the gym's plant took (steer_command, accel_command). An agent-tick departs at more than 1e-4 rad of steering or 0.01 m/s² of acceleration.

Against libcvc #1297 (nav@1 stops at its goals; the final stack):

agent-ticks n departing, control law alone (before) departing, plant_arm=True (after)
en route (over 60 m from the goal, not parked) 317 0.9 % 0 %
arriving (within 60 m, not parked) 311 77.8 % 0 %
parked, on the acceleration 185 98.4 % 0 %

Against #1286 alone (nav@1 overshoots):

agent-ticks n before after
en route 317 0.9 % (3) 0 %
arriving 190 10.5 % (20) 0.5 % (1)
parked, on the acceleration 252 99.2 % (250) 0 %
  • The largest departures outside parking, before → after:
    • on #1297: 0.0084 rad and 6.3 m/s² → 6·10⁻⁷ rad and 4·10⁻⁵ m/s²;
    • on #1286: 0.0084 rad and 6.4 m/s² → 4·10⁻⁷ rad and 0.65 m/s².
  • Before, what departs is:
    • the first ticks' steering, which the actuator's slew holds to 0.021 rad a tick;
    • braking past a_max when the stopping governor binds against the square's edge;
    • the park brake.
  • On #1286 alone, the one arriving tick that still departs is the first tick the stopping governor binds against the edge. From the next tick on, the two agree to 1e-4 m/s². Its cause is not found. On #1297 the agents slow for their goals before they near the edge, and it does not occur.

What it is not:

  • Parked steering departs on 83 % of parked ticks on #1297 (56 % on #1286), with or without the plant arm. nav@1 holds a parked agent's carrot 2 cm ahead of it. There, pure pursuit amplifies float rounding about 330 times, so the gym's float steering and the twin's double steering differ by up to the slew. The gate compares parked ticks on the acceleration and reports their steering apart.
  • On #1286 alone nav@1 overshoots. It arrives at 15–17 m/s and is parked as it passes within the 3 m reach. The park brake then stops it 9–13 m past the goal, so the gym's own arrival test is never met and the episode does not end. nav: nav@1 comes to rest at its goal (the drive's stop points) and a parked bicycle holds transfix/libcvc#1297 fixes that; the gate still ends itself, so it runs on both.
  • With #1297, beta and gamma act less on the approach. Above ~5 m/s the stop sets the braking and their gradients are exactly zero, so gate 3's plant-arm case starts at ~3.5 m/s, 6 m out. Training through the plant arm is not measured.
  • Not measured here:
    • the training gates with the plant arm (they ran with the control law alone);
    • near buildings, where only the square's edge acted;
    • the comm force.

Tests. test_gate5_the_plant_arm_is_the_command_the_plant_took and test_the_plant_arm_parks_a_rollout_at_its_goal are new, and gate 3's gradients now also run with the plant arm (they match central differences).

  • Against a libcvc build of nav: nav@1 comes to rest at its goal (the drive's stop points) and a parked bicycle holds transfix/libcvc#1297 on #1275 + #1284 + #1286, pytest tests/test_gym_twin.py: 10 passed. The first commit was checked the same way against #1286 alone (10 passed). The second commit was not re-run against #1286 alone, where the twin reads no stop_at_goal.
  • On a build without the plan (#1275 + #1284), it gives 7 passed and 3 skipped.
  • The drive's parity tests (pytest over every test that uses bike_control, bicycle_rollout, ext_rollout, dyn4 or the twin): 157 passed, 1 skipped (no CUDA).
  • black and ruff are clean.
  • CI's pycvc from cvcpkg has no twin exports, so test_gym_twin.py skips there.

On a vehicle plant libcvc's drive gives its command through the plant arm
(plant_drive), after the control law: the stopping governor with the latency
and the vehicle's braking, braking down to -a_brake, the steering actuator's
slew and lock, the vehicle's own envelope and footprint, and the park brake at
the goal. sdf_nav.bike_control takes it as plant= (a PlantArm) and steer_now=;
GymTwin(gym, plant_arm=True) reads it from plants()' plan (transfix/libcvc#1286)
and parks rows in rollout, drive_gym and tick_residuals as nav@1 parks an agent.
The default is the control law alone, unchanged.

Gate 5 (tests/test_gym_twin.py): nav@1 drives three Humvees on dynamic4w; the
twin's command from the drive the gym reports against the command the gym's
plant took. Departing agent-ticks, plant arm against the control law alone:
en route 0 % against 0.9 %, arriving 0.5 % (one tick) against 10.5 %, parked
(acceleration) 0 % against 99.2 %. Gate 3 runs with the plant arm too.
docs/gym-twin.md has the numbers.
…es it

transfix/libcvc#1297 makes nav@1 come to rest at its goals: the drive's
speed toward a stop point is held to the speed it stops there from (a_max,
or on the plant arm the latency and a_brake). sdf_nav.bike_control takes it
as stop_at=, and GymTwin(plant_arm=True) applies it at each row's goal where
fields()["navigator"]["stop_at_goal"] is set (older libcvc: no stop).

Gate 5 against #1297: plant arm 0 % departing en route, arriving and parked
(accel), against 0.9 / 77.8 / 98.4 % for the control law alone; the gate
now steps past the gym's end of the episode until the agents are at rest.
Gate 3's plant-arm case starts below ~5 m/s, where beta and gamma act: above
it the stop sets the braking and their gradients are zero.
@transfix
transfix merged commit d267b3a into main Nov 16, 2026
6 checks passed
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