Skip to content

boats: nav drives them, dyn_boat_plant and plant_host's dynamicboat (O12) - #1306

Merged
transfix merged 1 commit into
masterfrom
feat/boat-plant
Nov 16, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/boat-plant

Conversation

@transfix

Copy link
Copy Markdown
Owner

O12 of the water roadmap (D4): nav's agents drive boats. dyn_boat_plant sits beside dyn_bike_plant and dyn_4w_plant, takes nav's command through a driver, keeps an energy ledger like theirs, and plant_host selects it as dynamicboat.

What changed

  • cvc/physics/dyn_boat_plant.h, src/cvc/physics/dyn_boat_plant.cpp (new). A cvc::nav::vehicle_plant whose agents drive O11b's boats (world::add_boat) in a borrowed world that holds their water.
    • Boats. A dyn_boat_desc is a boat_desc with a hull_mesh, plus max_speed and turn_radius for nav's plan. Presets, measured: launch() (physics_boat_test's 4 m box boat with a shaft propeller and rudder: 3.19 m/s, 15.4 m) and jonboat() (a 3.6 m flat box of 350 kg with a steering outboard: 4.0 m/s, 4.1 m).
    • Attach. Each boat goes in over its agent's start at the draft its hull_mesh gives (float_height, by bisection). A start with no fluid field under it, water shallower than the draft, or a hull too heavy to float is refused, and a refused attach leaves no boats behind.
    • The driver, every world step. The throttle takes nav's acceleration as dyn_driver.h does, over the propeller's thrust at the boat's speed through the water. Its trim is kept when the command changes sign: restarting it, as a car's driver does, held the swell runs 3–5 % slow. The rudder holds the bicycle's yaw rate u·tan δ / L, with a feed-forward share of full rudder and a PI term on the yaw-rate error taken as a curvature. state().steer is the bicycle angle the driver holds, not the rudder. Reported as the rudder, the driver's corrections went into nav's steering-rate limit, and the launch chattered instead of turning round.
    • The books, every world step: kinetic now = kinetic at attach + drive − brake − rudder − damping + water + gravity + residual. Drive and brake are the thrust's T·u_a through the water. Rudder is the rudder force's work against the water past it. Water is the field load's work (field_load_on) plus the water's own motion's push on the propeller and rudder. Each force works at the step's mean velocity, so the residual is the integrator's.
    • Also: step_world off with before_world_step / after_world_step, world_gone, add_vehicle / remove_vehicle / add_desc (what a scene's world vehicles use), and the plant ledger's sample().
  • plant_host: dynamicboat (the launch) and dynamicboat:<presets>, in a world of the geometry (no flat ground) and set_water(field)'s fluid field.
    • With no water under the starts, use() throws and the agents fall back to the bicycle, with fallback() true, so pull() does not retry every call.
    • Without Jolt the name falls back to the bicycle, as a preset does.
  • world::water_at(point) (new, public): the water at a point at the field time, as the propeller reads it. water_sample moved from field_step.h into field.h.
  • cvc::nav::plant_medium (land, water) in plant_types.h, and vehicle_plant::medium(), land by default and water for the boat plant. This is for the later PR that spawns boats as world vehicles and filters spawn points by medium.
  • Docs: PHYSICS_API.md ("Boats as nav's plant", plant_host, water_at, the header table), and "As built (O12)" under D4 in the roadmap. The roadmap's Status line is untouched.

How it was checked (Windows 11, MSVC Release, Jolt)

physics_dyn_boat_plant_test, 11 tests, all pass:

  • Presets. The launch tops out at 3.1915 m/s and turns on a 15.39 m radius at full rudder and full throttle. The jonboat tops out at 4.0054 m/s and turns on 4.12 m.
  • Holding a speed and a yaw rate. Nav's commands for 2.5 m/s, then 2.5 m/s at 0.08 rad/s:
    • calm water: 2.5000 m/s and 0.08000 rad/s for both boats;
    • a 0.3 m, 5 s swell: 2.478–2.513 m/s and 0.0795–0.0798 rad/s.
  • The books. Over a weave and a stop astern, the residual is 6·10⁻⁸ to 2·10⁻⁷ of the flow on calm water and up to 3.5·10⁻⁵ on the swell. At a steady 2.5 m/s the launch's thrust delivers 11 305.28 J, against 11 248.80 J taken by the water and 56.25 J by the rudder.
  • Nav drives the boats (the roadmap's exit). In a sim_world over open water, a launch and a jonboat reach goals 120 m east from rest in 37.9 s. Then both turn round to goals about 100 m behind them and reach those in 61.0 s, with their books balanced.
  • plant_host: selection, a cycled preset list, an unknown preset refused (the plant kept), and no water refused.
  • Hosting: a host that steps the world matches the plant's own stepping bit for bit for 250 ticks.
  • Contacts: a hull that hits a pier counts a static contact.
  • Refusals and placement on the null backend.
  • Pinned hash: DynBoatPlant.CrossPlatformGoldenHash = 96abfc30fcae4fd4.

Every other physics and nav suite this could touch passes, plus physics_replay_test (ctest), ariadne_scene_world_test and world_rules_test. The physics ones are physics_boat_test, physics_hull_test, physics_field_test, physics_world_test, physics_plant_host_test, physics_dyn_bike_plant_test, physics_dyn_4w_plant_test, physics_plant_log_test, physics_codec_test, physics_immersion_test, physics_energy_test, physics_vehicle_test, physics_parity_test, physics_jolt_rollout_test, physics_dyn_contact_test and physics_pose_tracker_test. The nav ones are nav_plant_test (28 pass; 5 skip by design: experiments behind environment variables), nav_sim_world_test, nav_sim_world_agents_test, nav_stats_test, nav_test, nav_binding_test, nav_route_follower_test, nav_terrain_test, nav_trace_test, nav_vehicle_route_test, nav_world_grid_test, nav_world_planes_test and nav_yield_test.

No existing golden hash moved: the world's step is unchanged. Changed lines are formatted with git-clang-format.

Not checked or not done

  • Linux and macOS: not run. CI must confirm the new pinned hash 96abfc30fcae4fd4 there. The plant uses only det:: math and std::sqrt, and the test's scripted commands avoid libm.
  • pycvc: does not bind the plant. pycvc binds no boats yet (boat_desc, hull_mesh, boat_state), and this build has pycvc off.
  • Spawning boats: Ariadne's world vehicles do not spawn them yet, and nothing keeps their spawns on water. world::water_at reads a field's box, which knows nothing of the terrain inside it, so the spawner needs the water bodies, or the water's top against the ground's height and the boat's draft.
  • Saved state: snapshot(), physics_codec and a plant save and restore do not carry the plant's driver or books.

…O12)

cvc::physics::dyn_boat_plant (OCEAN-AND-WEATHER-ROADMAP.md D4) puts a
sim_world's agents on boats (world::add_boat) in a borrowed world that floats
them, beside dyn_bike_plant and dyn_4w_plant. Each boat goes in over its
agent's start at the draft its hull_mesh gives (float_height); a start with
no water under it, too shallow, or a hull that cannot float is refused.

Every world step a driver turns nav's bicycle angle and acceleration into
set_boat_controls. The throttle takes the acceleration as dyn_driver.h does,
over the propeller's thrust at the speed through the water, its trim kept
across sign changes since the water holds the boat back either way. The
rudder holds the bicycle's yaw rate u tan(delta) / L: a feed-forward share of
full rudder and a PI term on the yaw rate's error as a curvature. state()'s
steer is the angle the driver holds, not the rudder, which fed the driver's
corrections into nav's steering-rate limit.

The books are the hull's mechanical energy every step: drive and brake (the
thrust's T u_a through the water), rudder, damping, water (the field load and
the water's own motion on the propeller and rudder), gravity and the
integrator's residual. Presets launch (physics_boat_test's boat; 3.19 m/s,
15.4 m) and jonboat (a 350 kg flat box with a steering outboard; 4.0 m/s,
4.1 m), measured.

- plant_host: dynamicboat / dynamicboat:<presets> on set_water's field and
  the geometry; no water is a fallback to the bicycle.
- world::water_at; water_sample moves to field.h.
- cvc::nav::plant_medium (land, water) and vehicle_plant::medium(), for
  spawning boats on water later.

physics_dyn_boat_plant_test: the presets' envelopes; 2.5 m/s and 0.08 rad/s
held exactly on calm water and within 1 % on a 0.3 m swell; the books' residual
6e-8 to 3.5e-5 of the flow; nav drives a launch and a jonboat 120 m to their
goals and turns them round to goals behind them; plant_host; a hosted world
bit for bit; a pier contact; the refusals; and the pinned hash
96abfc30fcae4fd4 (Windows MSVC; CI to confirm Linux and macOS). No existing
hash moved. pycvc does not bind the plant (it binds no boats yet).
@transfix
transfix enabled auto-merge (squash) November 16, 2026 07:29
@transfix
transfix merged commit 7dfb752 into master Nov 16, 2026
29 checks passed
@transfix
transfix deleted the feat/boat-plant branch November 16, 2026 22:24
transfix added a commit that referenced this pull request Nov 17, 2026
One conflict, in ci.yml's SAN_CXX_TESTS: this branch added stream_test, net_ws_client_test and
ariadne_host_test to the sanitizer legs' list, and #1292 added gradient_vector_diffusion_test,
critical_points_test and seed_generators_test (reflowing the lines). Kept both.

ci.yml's line 1271 (the arigl-web path filter's files.h/files.cpp line) also goes back to master's
bytes: master stores ci.yml with CRLF but that one line LF-only, and an earlier merge here had
given it a CR, a whitespace-only change in this PR's diff.
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