Skip to content

pycvc: the water physics' knobs (the wake, wading, the wind, boats) - #1548

Merged
transfix merged 2 commits into
masterfrom
feat/pycvc-water-physics
Nov 26, 2026
Merged

transfix merged 2 commits into
masterfrom
feat/pycvc-water-physics

Conversation

@transfix

Copy link
Copy Markdown
Owner

pycvc now binds the water physics that it did not: the physics wake, wading, the wind and boats. The ocean-and-weather roadmap listed each of these as an open note ("pycvc does not bind ..."). Each one is checked against C++ in a new test, test_pycvc_physics_water.py (ctest pycvc_physics_water).

What Python gets

The wake (C5, C6)

  • pycvc.field_wake(cells, cell, depth, period, ..., shore) holds the wake's parameters.
  • add_field(..., inertial=True, wake=...) turns it on for a fluid.
  • Readouts: field_wake_info(field) (the window, sources, outside), field_wake_height(field, x, y), field_wake_of(field).
  • water_at(p, body=None) gives the water at a point with the waves in it, without body's own waves when one is given.
  • pycvc.shore_grid_mask(depth, shore_m, min_x, min_y, cell, slope) builds a coast from numpy planes.
  • add_box, add_sphere and add_hull take hull= (a hull_mesh).

Wading

  • vehicle_desc.wading is a pycvc.wading_desc, with every field read and written in place.
  • vehicle_state adds water_force and engine_flooded, and each wheel adds water_depth and water_drag.
  • physics_world.set_vehicle(id, desc) changes a running vehicle's settings (it was not bound before).
  • The physics binding (world_binding, C++) gets these knobs, with key metadata: vehicles.<name>.tuning.wading.{wheel_displacement, wheel_drag, underbody_depth, underbody_drag, tire_pressure, fording_depth}. It also publishes engine_flooded, water_force.* and each wheel's water_depth and water_drag.
  • WorldEntities.list() gives each world vehicle's wading.

The wind

  • pycvc.wind_flow(speed_mps, dir_rad, gustiness, base_z) is the physics wind.
  • pycvc.scene_wind_flow(speed, dir, gustiness, base_z) is the wind that Ariadne's wind.speed / wind.dir (degrees) / wind.gustiness keys make.
  • physics_world.set_wind(speed, dir, gustiness, base_z) keeps air everywhere, as SceneWorld does (1.225 kg/m^3, C_d 1). A second call changes it in place, and None removes it. wind() and wind_field() read it back.
  • add_field(None, kind="flow", wind=...) adds a wind field directly. field_wind(id) reads a field's wind.
  • mujoco_robot.set_wind(...), wind_force() and wind_torque() put a MuJoCo robot in the wind.

Boats (O11, O12)

  • Hulls: hull_mesh, box_hull and loft_hull.
  • boat_desc: the hull body via hull() / set_hull(...), its mesh copied in and out, and the propeller and rudder as dicts.
  • dyn_boat_desc: launch, jonboat, tactical and preset(name).
  • On physics_world: add_boat, set_boat_controls, boat_state, remove_boat and boat_desc_of.
  • dyn_boat_plant: state, boat_state, books, hold_controls, and float_height / draft. nav_sim_world_set_plant accepts it.
  • plant_host gets boat_state(i) and boat_books(i) while the agents drive boats.

vehicle_desc.wading and dyn_boat_desc.boat now keep their owner alive. Without that, humvee().wading or tactical().boat pointed into a temporary that Python had already freed. The test caught this through a failing read.

Verified (Windows, MSVC Release, Jolt, pycvc core; cvcGL off)

  • pycvc_physics_water, 107 checks:
    • Wake: the wake's golden scene built through pycvc gives PhysicsFieldWake.CrossPlatformGoldenHash c72e26b4ef0f764a bit for bit. A dropped crate's ring rocks a neighbour 5 m away (0.036 m heave, 0.29 m drift); without a wake it moves 0.
    • Wading: a stock Humvee floods as its front axle reaches the 0.9 m water (x = 40.06 m) and stops at 45.1 m. With tuning.wading.fording_depth set to 1.52 from the state tree, it drives on to 100 m.
    • Wind: the wind_flow digest and its 200 samples match C++'s pinned values (c7ec24178041550e, 3ec1c28ca0601404). 12 m/s pushes a 0.5 m ball with 69.1 N (½ρAu² = 69.3 N). set_wind and a hand-added flow field give the same hash.
    • Boats: the tactical boat floats 0.488 m over its keel and stays at its draft. Nav drives it 120 m to its goal in 15.2 s, and its books close with a residual of 1e-5 of the flow. A boat built from the launch's own numbers runs bit for bit like the launch.
  • Existing tests: every pycvc ctest in this build: 67 of 69 pass. The 2 failures are this box's environment, not this change: pycvc_volume_grid_contours (this deps prefix has no cvc::planar: "libcvc was built without cvc::planar") and pycvc_net ("a taken port raises": Windows lets a second socket bind the port). Rerun alone, they fail the same way.
  • C++ tests: physics_vehicle_test (with a new check of the wading knobs and telemetry; EveryPublishedKeySaysWhatItIs covers the new keys' metadata), physics_world_test, physics_energy_test and multi_app_integration_test all pass.
  • clang-cl 19 /Zs on the generated wrapper and the two binding sources: no errors.

Not run locally: Linux, macOS, wasm, cvcGL/pycvc_gl. The MuJoCo wind check in test_pycvc_mujoco.py runs only where MuJoCo is built; the test exits early on Windows. CI's pycvc-linux lane is the authoritative run.

Fields that need a follow-up (other open work)

Binds what the ocean-and-weather roadmap listed as "pycvc does not bind":

- the wake: field_wake (with a shore_grid_mask coast) on add_field / set_field,
  field_wake_info, field_wake_height, field_wake_of, water_at; add_box /
  add_sphere / add_hull take hull=;
- wading: vehicle_desc.wading (wading_desc), the wading readouts in
  vehicle_state, physics_world.set_vehicle; world_binding gets
  vehicles.<name>.tuning.wading.* knobs and the wading telemetry, with key
  metadata; WorldEntities.list() gives each vehicle's wading;
- the wind: wind_flow, scene_wind_flow (Ariadne's wind.* keys),
  physics_world.set_wind / add_wind, add_field(None, kind="flow", wind=...),
  mujoco_robot.set_wind;
- boats: hull_mesh, box_hull, loft_hull, boat_desc, dyn_boat_desc presets,
  add_boat / set_boat_controls / boat_state, dyn_boat_plant (a sim_world
  plant), plant_host.boat_state / boat_books.

test_pycvc_physics_water.py (107 checks) reproduces the wake's pinned golden
hash and the wind's pinned digest and samples, floods a Humvee past its
fording depth (and fords with the kit set from the tree), blows a light ball
downwind, floats the tactical boat at its draft and has nav drive it to a goal.
…t brings

pycvc_gl %imports pycvc.i, so its wrapper carries the type table's
derived-to-base casts for shore_grid_mask -> wake_shore and
wind_flow -> flow_velocity, and needs their headers. GCC (pycvc-linux)
failed on shore_grid_mask; clang-cl /Zs on the generated wrapper reproduces
the error without this include and passes with it.
@transfix
transfix merged commit 72fac0e into master Nov 26, 2026
30 checks passed
@transfix
transfix deleted the feat/pycvc-water-physics branch November 26, 2026 19:11
transfix added a commit that referenced this pull request Nov 26, 2026
The roadmap's F4 "Not done" list conflicted with #1548's pycvc line: kept
this branch's struck-through items and took master's pycvc wording.
transfix added a commit that referenced this pull request Nov 26, 2026
…edAndSleep (#1557)

The packed-crates wake test took 747 s of physics_field_test's 1200 s
ctest budget on #1548's package-linux libcvc-debug run, and timed out at
1200 s on #1551's first run of that lane, on a runner about 2.9x slower
(the sibling wake test took 784 s there against 271 s on #1548). With
the lane's --repeat until-pass:3 that one timeout cost the job an hour.

A small file, appended to the directory's TEST_INCLUDE_FILES after the
discovered tests' own include, sets that one test's TIMEOUT to 3600 (the
cap ci.yml gives the heavy Debug lanes). The other physics_field tests
keep 1200. ctest skips the line if the test is filtered out or renamed.

Checked with ctest 3.31: --show-only=json-v1 over the real discovered
physics_field_test file lists the test at 3600 and its 51 neighbours at
1200; a name with no test behind it raises no error.
transfix added a commit that referenced this pull request Nov 26, 2026
…lant.wading) (#1558)

#1542 merged before #1548, so the bindings take its fields:

- wading_desc.flood_area (and as_dict); vehicle_state water_inside and
  water_inside_mass; dyn_bike_plant.wading(i) / waded(i); WorldEntities'
  wading dict;
- world_binding: a tuning.wading.flood_area knob (whether it is 0 stays
  fixed: set_vehicle refuses the change, so it is ignored) and the
  water_inside / water_inside_mass telemetry, with key metadata.

test_pycvc_physics_water: a hard-doored Humvee (flood_area 0.1) in 0.7 m
fills over seconds to the level outside (0.787 m^3 at 60 s), published by
the binding; a dyn_bike_plant Humvee in 0.5 m wades (3738 N lifted).
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