Repository navigation
pycvc: the physics world, its vehicles and the navigator's plant (P6) - #693
Merged
Merged
Conversation
Python drives the same world, vehicles and plant as C++ and reads the same values (bindings/pycvc/pycvc_physics.i): - physics_world: materials; box, sphere, hull, mesh and terrain bodies; state, states, set_state, forces; vehicles through drive or the pedals, with their state, wheels and energy ledger as dicts; step, contacts, raycast, save/restore, state_hash and snapshot_json (C++'s own serializer). - vehicle_desc with the humvee() and roboracer() presets. - physics_binding: world_binding, the world in the state tree. - nav_plant: a world's vehicles as a sim_world's plant, with its state, drift, modulation, tree keys and terrain_config_of. - On a sim_world handle: nav_sim_world_set_plant (None = nav's bicycle), plant_kind, set_terrain / set_terrain_config / terrain_settings / infeasible_entries, pull / publish and tick. nav_sim_world_create takes "" for the built-in policy. - state_comment, state_property and state_property_keys read what a key says it is. A nav_plant keeps its world alive, a physics_binding its app and world, and a sim_world handle the plant set on it. The gate, Python reads the same values as C++: test_pycvc_physics.py rebuilds the cross-platform golden scene through pycvc and gets C++'s pinned 70b2cc0bd34ea4be. It rebuilds physics_parity_test's scenarios (a Humvee through the driver model, an agent on the Jolt plant) call for call and matches their state hashes and values bit for bit, and a vehicle's state, the snapshot JSON and the tree agree. 59 checks pass on Windows; physics_parity_test (3 tests) is the C++ reference.
An optional map_id ((N,) plane ids) and n_planes put each agent in its own belief plane, as sim_world's constructor allows: one per agent is the fog-of-war twin, GRL-SNAM's Squad on the native runtime. An id outside [0, n_planes) raises, and the arrays are released when the constructor throws. test_pycvc_physics checks the shared default, the private planes and the bad id (62 checks).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
P6 of the vehicle physics roadmap, the libcvc part: pycvc for the physics world, its vehicles and the navigator's plant. The gate is "Python reads the same values as C++", and it is met bit for bit. Stacked on P5, and opened once that merges.
What Python gets (
bindings/pycvc/pycvc_physics.i)physics_worldtakesworld_config's fields as keywords.add_box/add_sphere/add_hull/add_mesh(apycvc.geometry) /add_terrain(apycvc.height_field).state/states/set_state/ forces and impulses.drive(the driver model) orset_controls(the pedals).vehicle_stateis a dict, with the wheels and the energy ledger.step,contacts,raycast,save/restore,state_hash, andsnapshot_json(C++'s own serializer).vehicle_desc:humvee()androboracer(), scalar fields read/write,axle(i),gear_ratios().physics_binding:world_binding, the world in the state tree.nav_plant: a world's vehicles as a sim_world's plant. It has its options as keywords,state(i)(with the measured tire use, load transfer, pitch and roll),vehicle(i), the drift,set_modulation,pull/publish, andterrain_config_of(desc, mu).nav_sim_world_set_plant(sim, plant)selects the plant, or nav's bicycle withNone;nav_sim_world_plant_kindreports it;set_terrain/set_terrain_config/terrain_settings/infeasible_entries(P5);pull/publish(the sim_world's settings in the tree) andtick;nav_sim_world_createtakes""for the built-in policy, as the C++ tests use. It also takes an optionalmap_id/n_planes, so an agent can have its own belief plane, as GRL-SNAM'sSquadneeds.state_comment,state_propertyandstate_property_keys, so Python reads what a key says it is (unit, access, recommended min/max).nav_plantkeeps its world alive, aphysics_bindingits app and world, and a sim_world handle the plant set on it. The handle's destructor releases the plant after the world that borrowed it.The gate
test_pycvc_physics.py(ctestpycvc_physics), 62 checks, all passing on Windows:PhysicsJolt.CrossPlatformGoldenHash's exact scene, rebuilt through pycvc, gives C++'s pinned70b2cc0bd34ea4be.physics_parity_test(new, 3 tests; ctest passes its path inCVC_PHYSICS_PARITY_EXE) writes its scenarios' values. Python rebuilds them call for call and requires the same, bit for bit: 3 state hashes and 22 values.ad4f3e75970506acon this box.fab1bf415fa513f7.physics.vehicles.<name>.*keys carry the same numbers. The tree's doubles round-trip exactly.vmaxand a modulation gain set in the tree reach the drive.Not in this PR
The rest of P6 is downstream and needs a libcvc release with P4–P6:
Squad(plant=…)and thenav_nativeplant option;gen-episodes/evalon Jolt, aKinematicsRecordschema bump and energy in the scorecards;--plant/--vehicle/--clockand the HUD.Test
physics_parity_test3/3 andtest_pycvc_physics.py59/59;physics_parity_test, and pycvc runs locally (on Windows withCVC_DLL_DIRSnaming the DLL directories).