Skip to content

Feat/a2 joystick flat#671

Open
lemon-star608 wants to merge 4 commits into
mainfrom
feat/a2-joystick-flat
Open

Feat/a2 joystick flat#671
lemon-star608 wants to merge 4 commits into
mainfrom
feat/a2-joystick-flat

Conversation

@lemon-star608

Copy link
Copy Markdown
Collaborator

Summary

加入A2_joystick/mujoco任务

Linked Work

  • Issue:
  • Milestone:

Validation

  • make check
  • uv run pytest -m "not slow"
  • Additional task-specific validation listed below

Commands actually run:

# paste exact commands here

Impact

  • Backend impact: mujoco / motrix / both / none
  • Platform impact: macOS / Linux / both / unknown
  • Training effect expected: yes / no / unknown

Artifacts

  • W&B:
  • benchmark result:
  • video / screenshot:
  • ONNX / checkpoint:

Checklist

  • Added or updated tests where needed
  • Updated docs if behavior or workflow changed
  • Linked the driving issue
  • Noted any follow-up work explicitly

Self-contained robots/a2/ (meshes copied from the A2+Airbot composite),
12 position-style leg actuators with A2-strength gain classes, Go2-
compatible IMU/foot sensors. No arm, no keyframe (keyframe lives in the
task scene, per the asset/XML structure contract).
The A2 leg-only MJCF mirrors the Go2 joystick sensor/geom/leg-ordering
contract and uses <position> actuators, so the task reuses Go2WalkTask
unchanged. Only the A2 identity differs: scene path, standing pose, and
per-joint PD gains.

- A2 flat scene (scene_flat.xml) with four foot-contact sensors and a home
  keyframe aligned to unitree_rl_mjlab INIT_STATE (height 0.4, thigh 0.9,
  calf -1.8, hips +-0.1); default_angles derive from it automatically.
- A2JoystickCfg / A2JoystickFlatEnv registered and wired into the
  locomotion registry bootstrap.
- Per-joint PD gains via PdControlConfig.position_gains() (hip/thigh
  kp=100/kd=4, calf kp=150/kd=6) forwarded to the backend; the scalar
  default keeps Go2 behaviour byte-for-byte unchanged.
- a2_joystick_flat/mujoco owner YAML carrying training + reward.
- End-to-end contract tests (XML compiles, 12-DOF, obs layout, per-joint
  model gains, finite step) and support-matrix refresh.
Enable the sim2real DR suite on A2JoystickFlat (budget 500 iters; A2 is
~2.8x Go2 mass) and let the policy stand still at zero command instead of
marching in place.

Domain randomization:
- A2JoystickDomainRandomizationProvider supplies per-joint base gains so
  randomize_kp/kd scales each actuator off its true baseline (calf off
  150, not the shared scalar), and caches the pristine dof-armature +
  geom-friction tables via the public backend getters (cold path, no
  feature leak) so randomize_dof_armature and randomize_ground_friction
  are effective; the floor geom is the priority geom for friction.
- com_offset_y/z declared so the base COM randomizes in all three axes.
- DR ranges reference unitree_rl_mjlab A2 events (joint_armature scale
  0.9-1.1, foot friction 0.3-1.6); body_mass and gravity stay off.

Zero-command standing (gated so Go2's default behaviour is unchanged):
- RewardConfig.command_threshold gates the phase-driven gait rewards
  (swing_feet_z / contact) and the gait phase clock: while standing
  (||command|| <= threshold) the phase freezes per-env and a planted
  robot earns full contact reward. Default 0.0 keeps Go2's reward vector
  and phase advance byte-for-byte unchanged.
- New rewards stand_still / hip_deviation / stand_feet_air penalize
  residual micro-stepping and stance drift at zero command, all gated by
  command_threshold so they cost locomotion nothing.
- sample_commands_with_standing is the single source of truth for the
  standing-aware command distribution, shared by the reset path (DR
  provider) and mid-episode resampling (resampling_time > 0).

Tests: DR-on env constructs and steps finite, friction/armature baselines
cached once, floor geom dominates friction; Go2 stand-still contract
(phase freeze, gated rewards, command sampling).
@lemon-star608 lemon-star608 requested a review from TATP-233 as a code owner July 2, 2026 10:06

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

检查其他地方是否已经实现过了

@TATP-233 TATP-233 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

检查stand 指令其他地方已经实现过了

…ding_fraction

Review on #671 flagged that the standing-command logic our A2 PR added to
common/commands.py already existed elsewhere. It did: the block "zero a random
rel_standing_envs fraction of rows to zero" was copy-pasted inline in six DR
provider sites (go1/rough, go2/rough, go2w/rough, go2w/joystick reset+resample,
g1/joystick) with no shared helper.

Extract the block into common.commands.apply_standing_fraction() (in-place, same
RNG guard) and route all six sites plus sample_commands_with_standing through it.
Per-site zero_small_xy thresholds (0.08 for rough, 0.2 default for g1/go2w) and
heading handling are preserved, and the rough.py resample paths that only do
zero_small_xy (no standing fraction) are left untouched. Behaviour-preserving:
make test-all still 1431 passed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants