Backup DreamWaQ rslrl stability fixes
This commit is contained in:
@@ -31,7 +31,8 @@ HISTORY_LEN = 5
|
||||
ACTION_SCALE = 0.25
|
||||
KP = 28.0
|
||||
KD = 0.7
|
||||
CLIP_ACTIONS = 23.7
|
||||
CLIP_ACTIONS = 4.0
|
||||
CLIP_TORQUES = 80.0
|
||||
CLIP_OBS = 100.0
|
||||
MAX_VX, MAX_VY, MAX_WZ = 1.0, 1.0, 1.0
|
||||
|
||||
@@ -122,7 +123,7 @@ def main():
|
||||
|
||||
# Select XML scene
|
||||
terrain_map = {
|
||||
"flat": "scene_motor_actuator.xml",
|
||||
"flat": "scene_dreamwaq_flat.xml",
|
||||
"rough": "scene_rough_terrain.xml",
|
||||
"stairs": "scene_stairs_terrain.xml",
|
||||
"dreamwaq": "scene_dreamwaq_terrain.xml",
|
||||
@@ -243,10 +244,22 @@ def main():
|
||||
action = np.clip(action, -CLIP_ACTIONS, CLIP_ACTIONS)
|
||||
last_action = action.copy()
|
||||
|
||||
# PD control
|
||||
# PD control(对齐训练:目标限位 + 力矩裁剪)
|
||||
target = DEFAULT_ANGLES + action * ACTION_SCALE
|
||||
# 关节目标限位(与训练一致)
|
||||
jnt_lo = model.jnt_range[:, 0].copy() if hasattr(model, 'jnt_range') else None
|
||||
jnt_hi = model.jnt_range[:, 1].copy() if hasattr(model, 'jnt_range') else None
|
||||
# MuJoCo model.actuator_trnid 可能不直接暴露,改用 model.jnt_range
|
||||
try:
|
||||
trnid = model.actuator_trnid[:, 0] # transmission joint indices
|
||||
lo = model.jnt_range[trnid, 0]
|
||||
hi = model.jnt_range[trnid, 1]
|
||||
except Exception:
|
||||
lo = np.full(12, -12.0)
|
||||
hi = np.full(12, 12.0)
|
||||
target = np.clip(target, lo, hi)
|
||||
torques = KP * (target - data.qpos[7:19]) - KD * data.qvel[6:18]
|
||||
data.ctrl[:] = np.clip(torques, -CLIP_ACTIONS, CLIP_ACTIONS)
|
||||
data.ctrl[:] = np.clip(torques, -CLIP_TORQUES, CLIP_TORQUES)
|
||||
mujoco.mj_step(model, data)
|
||||
view.sync()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user