Skip to content

pycvc: dyn_bike_plant's wheel spin, side slope, compliant contact and ground - #1002

Merged
transfix merged 1 commit into
masterfrom
feat/pycvc-dyn-plant-options
Nov 3, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/pycvc-dyn-plant-options

Conversation

@transfix

@transfix transfix commented Nov 3, 2026

Copy link
Copy Markdown
Owner

#982, #983 and #987 gave dyn_bike_plant three opt-in options: wheel spin, compliant contact and the side slope. pycvc.dyn_bike_plant (#979) exposed none of them, and none of their book lines. Python also had no way to give the plant a ground other than a flat ground_z, so the side slope had nothing to read. This PR binds all of it.

The binding (bindings/pycvc/pycvc_physics.i)

New keywords, all defaulting to the plant's current behaviour:

Keyword What it does
ground A pycvc.height_field in world metres, copied as it is now. It sets plant.ground_height, falling back to ground_z where the field has no height. The vehicle climbs it (#869), and the side slope reads it.
wheel_spin Turns on wheel spin.
side_slope Turns on the side slope.
contact Turns on compliant contact.
contact_field A sim_world handle. The plant copies that world's signed distance on contact_plane as it is now. dyn_bike_plant::sdf_field only borrows the grid, which the world rebuilds when its map changes, so the copy keeps the field valid.
contact_vehicles Whether the vehicles also meet each other.
contact_params A dict of dyn_contact_params' fields.

Each of these raises:

  • contact together with world, since dyn_bike_plant.h says to use one or the other;
  • contact_field without contact;
  • a contact_field that is not a sim_world;
  • a contact setting that does not exist.

Other changes:

  • Books: books() and last_tick() gain slip, contact_energy, contact_stored, contact_dissipated and contact_exchange.
  • New accessors: wheel_speed(i, axle), and contact_now(i), which returns the barrier's energy, the damper's power, the points touching and the body wrench, or None without contact.
  • Options: options() reports the new settings.

Test (test_pycvc_physics.py)

test_the_dynamic_plant_options runs make_sim's world on the full-size preset:

Case Measured
Defaults No slip line, no contact, and the axles' wheels at the same rate
Wheel spin on grip 0.3 1.75 kJ of slip booked; the axles' wheels at different speeds
A 5% ramp up the road Grade line −51.5 kJ
A 10% slope across the road, with the side slope Pulled down to y = −0.228 m; without the option it stays at 0.000 and its grade line is 0
A wall in another sim_world's map, driven at by a navigator whose map is empty The rear axle stops 4.55 m short of the wall; 4 points touch at 23.5 kN; the damping books 81.6 kJ; the world's contact line stays 0

Every run's books close to 1e-9 of the flow, with residuals below 5e-3 of it. books_gap now includes the slip and contact lines.

All 73 checks of test_pycvc_physics.py pass, on Windows with MSVC 19.44 Release and Python 3.11.

A limit found on the way

The contact case runs at a 0.005 s substep. At the default 0.01 s, the damper, held over each substep, overshoots this 7.8 m/s impact:

Substep contact_dissipated Limiter Residual / flow
0.01 s (default) −1.52e5 J (the contact supplies energy) −2.42e5 J (rebound at −3.24 m/s) 3.1e-2
0.005 s +8.16e4 J 0 2.4e-3
0.0025 s +8.18e4 J 0 1.3e-3
0.00125 s +8.19e4 J 0 2.6e-4

physics_dyn_contact_test impacts at 5 m/s only. This PR changes no plant code. The fix belongs in the plant: an implicit damper, a contact substep, or a cap on h·c_k/m.

… ground

pycvc.dyn_bike_plant takes the plant's opt-in options from #982, #983 and #987:
wheel_spin; side_slope; and contact, with contact_field (a sim_world handle,
whose signed distance on contact_plane is copied as it is now), contact_vehicles
and contact_params (a dict of dyn_contact_params' fields). ground, a
pycvc.height_field in world metres (copied), gives the plant a ground height,
which the vehicle climbs and the side slope reads; before, Python had only a flat
ground_z. contact with a world raises, as do contact_field without contact and a
contact setting that does not exist.

The books gain slip, contact_energy, contact_stored, contact_dissipated and
contact_exchange. options() reports the new settings. wheel_speed(i, axle) and
contact_now(i) (the barrier's energy, the damper's power, the points touching and
the body wrench) read an agent.

test_pycvc_physics.py's test_the_dynamic_plant_options:
- wheel spin on grip 0.3 books 1.75 kJ of slip, and the axles' wheels part;
- a 5% ramp costs 51.5 kJ;
- a 10% side slope pulls the vehicle 0.23 m downhill, where the plain ground
  leaves it on its line;
- driven at a wall in another sim_world's map, it stops with its rear axle
  4.55 m short, pressed with 4 points at 23.5 kN, and the damping books 81.6 kJ.
Every run's books close to 1e-9 of the flow.

The contact run uses a 0.005 s substep. At the default 0.01 s the damper, held
over the substep, overshoots this 7.8 m/s impact: the books show
contact_dissipated at -1.5e5 J (the contact supplying energy), the limiter takes
2.4e5 J, and the residual is 3.1e-2 of the flow. At 0.005, 0.0025 and 0.00125 s
the residual is 2.4e-3, 1.3e-3 and 2.6e-4 of the flow. physics_dyn_contact_test
impacts at 5 m/s only.
@transfix
transfix merged commit 1ded7be into master Nov 3, 2026
27 checks passed
@transfix
transfix deleted the feat/pycvc-dyn-plant-options branch November 3, 2026 20:16
transfix added a commit that referenced this pull request Nov 7, 2026
…efault substep (#1038)

pycvc.dyn_bike_plant(..., contact_step_depth=None) binds #1004's
dyn_bike_plant_options::contact_step_depth (m; None keeps the plant's default,
<= 0 never substeps), and options() reports it.

test_pycvc_physics.py's contact case, the navigator driving into a wall from
another sim_world's map at about 7.8 m/s, goes back to the default 0.01 s
substep: #1002 ran it at 0.005 s because the damper overshot, and #1004's
implicit damper and contact substeps fixed that. It now also checks the speed
clamp takes nothing, and the new keyword's round trip, default and type.

All 77 checks pass (Windows, MSVC 19.44 Release, Python 3.11, on master
f94a9b2). At 0.01 s the contact dissipates 8.15e4 J, the limiter takes 0 and
the residual is 1.33e-3 of the flow, as #1004's C++ fast-impact test has it.
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