Repository navigation
nav: dyn_spin_plant_dg, the discrete-gradient step with the wheels spinning - #1045
Merged
Merged
Conversation
…inning dyn_spin_plant_dg (detail/dyn_bike_dg.h, opt-in) solves the momenta e = (vx, vy, r, om_f, om_r), M = diag(m, m, Iz, J_f, J_r), with Q from the plant's hook dyn_spin_ph_forces_at (#982) and its optional wrench (#983). The body's rows take the midpoint. The wheels' rows take theta_wheels, 1 by default, because the wheels' slip is far stiffer than the step. The books (dyn_spin_ph_rates_at at e_th) close to the solver's tolerance, with one more line, `scheme`, for the wheels' damping. Actuators, clamp, blend and pose are dyn_plant_dg's. dyn_plant_dg now calls them through dyn_dg_actuators and dyn_dg_finish, and its step is unchanged. Nothing that calls dyn_plant or dyn_spin_plant changes. nav_dyn_bike_dg_test gains DynSpinDG.*: rate against dyn_spin_ph_rhs, actuators to the bit, books, order, stiff wheel slip at nav's 0.06 s and the live plant's 0.01 s with and without substeps, and cost. docs/NAV_TRAINING.md gets the gates.
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.
What
diff::dyn_spin_plant_dgininc/cvc/nav/detail/dyn_bike_dg.h: the discrete-gradient step of #978, now with the wheels spinning. It is opt-in, and nothing that callsdyn_plant,dyn_spin_plantordyn_plant_dgchanges.dyn_bike.h,dyn_4w.handdyn_bike_plantare untouched.The solve. A 5-vector solve on
e = (vx, vy, r, om_f, om_r)withM = diag(m, m, Iz, J_f, J_r):Qcomes from the agreed hookdyn_spin_ph_forces_at(dyn_bike, dyn_4w: opt-in wheel spin in pH form; plant logs carry the wheels; cvc::ph potential and input options #982), with its optional wrench (dyn_bike_plant: compliant contact in pH form against sim_world's field and between vehicles; plant logs keep contact windows #983).Jcomes fromdyn_spin_ph_J. The actuators sit at the step's midpoint.Books.
dyn_spin_ph_rates_atate_th, timesh, plus the wrench's work.Jis skew, soH(e1) - H(e) = h e_th^T Q(e_th) - (th - 1/2) sum J dom^2exactly. The second term is a new books line,scheme. It is at least 0, and exactly 0 atth = 1/2.Actuators, clamp, blend, pose. These are
dyn_plant_dg's. They are factored intodyn_dg_actuatorsanddyn_dg_finish, anddyn_plant_dgcalls the same helpers. All of dyn_bike: an opt-in discrete-gradient step whose energy books close exactly #978's tests pass unchanged.Newton. The Jacobian uses forward-mode duals through one tire evaluation per direction (
dyn_spin_dg_rate_one). There is a backtracking line search on|M^-1 F|.M - h (J - R) Theta, withR >= 0fromdyn_spin_ph_R. That step always descends.Options.
dyn_spin_dg_options:theta_wheels(default 1),substeps(default 1),max_iters40.Out of scope. The ground form (
dyn_plant_ground).The decision: the wheels' rows at the step's end (
th = 1)The wheels' slip is stiff:
h lambdais 60 to 600 at 0.06 s on the Humvee. The midpoint rule is A-stable but not L-stable, so atth = 1/2the slip swings every step once disturbed. Substeps help only nearh lambdaof 2 (25 substeps of 0.06 s).At
th = 1on the wheels alone, the slip's amplification is about(1 - b/2) / (1 + a + b/2), wherea ≈ 120 bon the Humvee. So the slip settles in a step or two, about asdyn_spin_plant's does. Three things come with that:scheme;dyn_spin_plantat every hdt.Substeps stay at 1.
Gates (
nav_dyn_bike_dg_test, DynSpinDG.*, the Humvee)th = 1(default)th = 1/2dyn_spin_plantdyn_spin_ph_rhs, 500 states (rolling, spinning, locked, reversed; grades 0 to 0.08), mu 0.9 and 0.3dyn_spin_plant, lags and slew on, 100 statesschemeexactly 0The order gates are:
th = 1/2between 3.4x and 4.6x per halving on both ranges;th = 1between 1.7x and 2.6x, and under 0.2 ofdyn_spin_plant's error at every hdt.Stiff wheel slip (DynSpinDG.StiffWheelSlip)
The low-speed blend is off so the runs compare. The reference is
th = 1at 0.1 ms. A swing is a sign change in the slip's step-to-step change, each over 1 mm/s, counted on either wheel.dyn_spin_plantth = 1/2, 1th = 1At the live plant's 0.01 s,
th = 1swings 2, 0, 2, 0 and 0 times, againstdyn_spin_plant's 2, 0, 0, 0 and 0.th = 1/2still swings 590, 149 and 34 times coasting. Every DG configuration solves (0 unconverged), and no coasting step gains energy.Cost
The cost run is CostPerStep's 600 s swerve at 0.06 s, which spends most of its time at a crawl (0.2 to 15.5 m/s). There
th = 1averages 6.3 Newton steps, against 3.9 forth = 1/2. Capping Newton's own line search at two halvings before the secant step cut it from 20 µs to 12 µs a step. At 0.01 s,th = 1is 3.6 steps and 5 to 7 µs.The timings come from a shared build host, so expect ±30%.
dyn_plant_dg's timing on the same runs is 2.8 to 4.5 µs.Tests run locally (Windows, MSVC, cvcpkg prefix)
nav_dyn_bike_dg_test: 13/13, all 7 DynBikeDG and all 6 DynSpinDG.nav_dyn_bike_test23/23,nav_dyn_ph_full_test8/8,nav_dyn_spin_test13/13.nav_plant_test28/28 run (5 experiments skipped: they run only with their env flags set),physics_dyn_bike_plant_test10/10,physics_dyn_contact_test9/9. None of these includesdyn_bike_dg.h.docs/NAV_TRAINING.mdgets a short section and the gates table afterdyn_plant_dg's.