initial WIP changes to support sonic in robosuite still needs review and ton more features, but right now locomotion in the robosuite env works with keyboard#809
Open
Abhiram824 wants to merge 10 commits into
Conversation
…and ton more features, but right now locomotion in the robosuite env works with keyboard
Replace the full-qpos freeze/fall-recovery startup hold in SonicWholeBodyController with an elastic band: a spring-damper force on the PELVIS body only (mj_data.xfrc_applied), never a qpos write, so free task objects (e.g. a manipulation env's cube/pot) evolve under normal physics instead of being teleported back to a snapshot every step. Reuses gear_sonic's ElasticBand (the same law base_sim uses), anchored at the spawn pose; released manually via band_enabled / release_band()/toggle_band() (the collector binds '9' in the viewer, mirroring base_sim). No fall recovery (a collapse stays down, by design). Also this session: - Remove the _SOURCE_FACTORY hook: the controller always builds DDSCommandSource; tests/collector override by monkeypatching the module's DDSCommandSource symbol (_patch_source). - Resolve the WBC config path from the installed gear_sonic package (_wbc_config_path); keep the guarded WBC_CONFIG export for tests/scripts. - Rename the opaque 1-2 letter locals in _prepare/run_controller. - collect_sonic_g1_demos.py: migrate off the removed factory hook, wire the band-release key, refresh docstrings, drop dead imports. - Add test_sonic_startup_band_is_object_safe (perturb TwoArmLift's pot, step, assert it is not snapped back + the pelvis band force is set/cleared). Tests: robosuite SonicG1 suite 8/8. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Builds on the band commit (80dc64c): - SonicG1 base placement: zero _base_offset (robosuite derives it from the root body's authored pos, and our pelvis is authored at z=0.793, so set_base_xpos buried the pelvis at -0.793) and put the stand height in base_xpos_offset.z (GR1 convention). The env now stands the floating robot at [front-of-table, 0.793], feet on the floor, in Lift/Stack/TwoArmLift. - collect_sonic_g1_demos.py: --environment loads ANY registered robosuite env via robosuite.make (not just the table-free SonicArena) -- safe now that the band no longer pins qpos; --robot selects SonicG1[/Fixed]; make_env() helper; set_init_pose sets JOINTS only (the env owns base placement). - Bundles external asset updates (build_sonic_g1_assets.py / robot.xml). SonicG1 suite 8/8; replay records a demo.hdf5 in Lift with the cube freejoint in the recorded state. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- base.py: add post_action_freq and render_freq throttle knobs (default 1 = every step, unchanged for all other envs) so the expensive once-per-step bookkeeping (reward/_check_success + any subclass _post_action work) and the built-in viewer render can run below the control rate. - collect_sonic_g1_demos.py: default to dt=0.005 / control_freq=200 so one step() == one physics substep == one SONIC PD command (the true control rate now equals the recorded/PD-command rate). Add --sim-dt/--control-freq/ --post-action-hz/--render-hz (post-action bookkeeping + passive-viewer sync at 20 Hz); match_base_sim_physics now takes a timestep arg; thread control_freq through make_env. Validated gold-faithful at 200 Hz live DDS (kick/macarena/walk within tol of the recorded gold mean). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…able action source) The SONIC PD command's joint-position target q* is now the env action: SonicWholeBodyController consumes it (set_goal) and applies the PD law with the deployment's constant per-motor gains (dq*=0, tau_ff=0); the DDS exchange no longer lives inside the controller. The action source is pluggable -- DDSActionSource (live C++ over DDS) / ReplayActionSource (recorded q*) / a learned policy -- so collection, replay, and policy-eval share one interface, and recorded demos store a meaningful 43-dim q* action (the SonicDataCollectionWrapper substep hook is no longer needed). - controllers/composite/sonic_whole_body_controller.py: set_goal stores q*; run_controller routes it through the part plan with the captured constant gains; action_limits = 43-dim (body 29 + hands 14); drops the in-controller DDS exchange; keeps the startup elastic band. - utils/sonic/action_sources.py (new): SonicActionSource / DDSActionSource (captures the constant gains once from the stream) / ReplayActionSource. - scripts/collect_sonic_g1_demos.py: driver loop is `action = source.act(env); env.step(action)`, paced over the whole loop. Validated live (DDS) at 200 Hz: all 7 gold motions track within tol of the gold mean (bit-faithful to the pre-refactor in-substep path); real-time on the heaviest kitchen (RTF ~2.18x). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…e RTF monitor After the action-source refactor the SONIC collectors pace their own step loop (source.act + env.step is throttled to control_timestep in the driver), so nothing sets env.real_time anymore and base.py's per-substep sleep throttle was dead. Remove self.real_time + the sleep machinery (_rt_anchor/_rt_slept). Keep the read-only RTF accounting (gated by CONSOLE_LOGGING_LEVEL=DEBUG) and simplify the [real-time] log to report just substeps/wall/sim/RTF -- the old "slept Xms (Y% idle)" fields only measured base.py's own (now-absent) throttle and always read 0, which was misleading. Still flags sub-real-time (RTF < 0.97) so a too-heavy scene / loaded box stays visible. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
WIP