v1.0.2; change high speed move, remove useless comments

This commit is contained in:
wty-yy
2026-01-26 16:22:01 +08:00
parent 164014325a
commit 2aed91e7ce
11 changed files with 106 additions and 203 deletions

View File

@@ -27,6 +27,15 @@ def get_gravity_orientation(quaternion):
return gravity_orientation
def quat_rotate_inverse(q, v):
q = np.array(q, np.float32)
v = np.array(v, np.float32)
q_w = q[0]
q_vec = q[1:]
a = v * (2.0 * q_w ** 2 - 1.0)
b = np.cross(q_vec, v) * q_w * 2.0
c = q_vec * np.dot(q_vec, v) * 2.0
return a - b + c
def pd_control(target_q, q, kp, target_dq, dq, kd):
"""Calculates torques from position commands"""
@@ -162,11 +171,17 @@ if __name__ == "__main__":
# Close the viewer automatically after simulation_duration wall-seconds.
start = time.time()
while viewer.is_running() and time.time() - start < simulation_duration:
vel = d.qvel[:3]
ang_vel = d.qvel[3:6]
local_vel = quat_rotate_inverse(d.qpos[3:7], vel)
local_ang_vel = quat_rotate_inverse(d.qpos[3:7], ang_vel)
show_str = f"Speed: Vx={local_vel[0]:.2f}, Vy={local_vel[1]:.2f}, Wz={local_ang_vel[2]:.2f}, "
step_start = time.time()
if use_joystick and counter % control_decimation == 0:
cmd = get_xbox_command(joystick, config["max_cmd"])
print(f"Cmd: Vx={cmd[0]:.2f}, Vy={cmd[1]:.2f}, Wz={cmd[2]:.2f}", end='\r')
show_str += f"Cmd: Vx={cmd[0]:.2f}, Vy={cmd[1]:.2f}, Wz={cmd[2]:.2f}"
print(show_str, end='\r')
tau = pd_control(target_dof_pos, d.qpos[7:], kps, np.zeros_like(kds), d.qvel[6:], kds)
d.ctrl[:] = tau

View File

@@ -243,7 +243,7 @@ if __name__ == "__main__":
# 处理 MoE 和 绘图
if isinstance(result, tuple):
action, weights = result # moe
action, (weights, latent) = result # moe
action = action.detach().numpy().squeeze()[idx_model2mj]
weights = weights.detach().numpy().squeeze()

View File

@@ -1417,13 +1417,6 @@ class LeggedRobot(BaseTask):
# Penalize joint poses far away from default pose
return torch.sum(torch.abs(self.dof_pos - self.default_dof_pos), dim=1)
def _reward_hip_to_default(self):
hip_dof_names = ['FL_hip_joint', 'FR_hip_joint', 'RL_hip_joint', 'RR_hip_joint']
hip_dof_indices = [0, 3, 6, 9]
hip_pos = self.dof_pos[:, hip_dof_indices]
default_hip_pos = self.default_dof_pos[:, hip_dof_indices]
return torch.sum(torch.abs(hip_pos - default_hip_pos), dim=1)
def _reward_upright(self):
return (-1 - self.projected_gravity[:, 2]) / 2

View File

@@ -176,32 +176,6 @@ class GO2Cfg(LeggedRobotCfg):
}
min_legs_distance = 0.1 # min distance between legs to not be considered stumbling
class scales:
# tracking_lin_vel = 1.0
# tracking_ang_vel = 0.2
# lin_vel_z = -10.0
# base_height = -50.0
# action_rate = -0.005
# similar_to_default = -0.1
# dof_power = -1e-3 # 能够明显抑制跳跃
# dof_acc = -3e-7
# tracking_lin_vel = 1.0
# tracking_ang_vel = 0.5
# lin_vel_z = -2.0
# ang_vel_xy = -0.05
# dof_acc = -2.5e-7
# dof_power = -1e-3 # 能够明显抑制跳跃
# # torques = -1e-4 # 无用会走着走着倒了
# correct_base_height = -10.0
# action_rate = -0.01
# action_smoothness = -0.01
# collision = -1.0
# dof_pos_limits = -2.0
# feet_regulation = -0.05
# hip_to_default = -0.1
# similar_to_default = -0.05
# CTS reward
tracking_lin_vel = 1.0
tracking_ang_vel = 0.5
lin_vel_z = -2.0
@@ -215,11 +189,12 @@ class GO2Cfg(LeggedRobotCfg):
collision = -1.0
dof_pos_limits = -2.0
feet_regulation = -0.05
# CTS奖励训出来双脚距离非常近, 真机效果很差, 但是sim2sim能上20cm楼梯, 尝试加入hip_to_default奖励或similar_to_default奖励
hip_to_default = -0.05 # 在训练到y=1.5, 双脚会明显碰撞, 为避免该问题提升hip, 效果更差, 还是保持0.05 (y最大也只到0.1了)
# legs_distance = -1.5 # 奖励双脚距离, 避免CTS训练出来双脚距离过近, 尝试加入后robogauge flat验证效果变差, 删除
# CTS reward trains to have very close feet distance, real robot performance is poor, but sim2sim can climb 20cm stairs, try to add hip_to_default reward or similar_to_default reward
# training to y=1.5, font feet will collide noticeably, max y=1.0
hip_to_default = -0.05
# legs_distance = -1.5 # not good performance, avoid leg collision
# similar_to_default = -0.01
# feet_contact_forces = -1.0 # 尝试加入但并没有起到任何效果, 删除
# feet_contact_forces = -1.0 # try to add but no effect, remove
turn_over_roll_threshold = math.pi / 4 # threshold on roll to use turn over rewards
class turn_over_scales:
@@ -238,7 +213,7 @@ class GO2CfgPPO(LeggedRobotCfgPPO):
class runner(LeggedRobotCfgPPO.runner):
run_name = ''
experiment_name = 'go2_ppo'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgCTS(LeggedRobotCfgCTS):
@@ -246,7 +221,7 @@ class GO2CfgCTS(LeggedRobotCfgCTS):
num_steps_per_env = 24
run_name = ''
experiment_name = 'go2_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class policy(LeggedRobotCfgCTS.policy):
@@ -264,7 +239,7 @@ class GO2CfgMoECTS(LeggedRobotCfgMoECTS):
class runner(LeggedRobotCfgMoECTS.runner):
run_name = ''
experiment_name = 'go2_moe_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgMCPCTS(LeggedRobotCfgMCPCTS):
@@ -275,7 +250,7 @@ class GO2CfgMCPCTS(LeggedRobotCfgMCPCTS):
class runner(LeggedRobotCfgMCPCTS.runner):
run_name = ''
experiment_name = 'go2_mcp_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgACMoECTS(LeggedRobotCfgACMoECTS):
@@ -285,7 +260,7 @@ class GO2CfgACMoECTS(LeggedRobotCfgACMoECTS):
class runner(LeggedRobotCfgACMoECTS.runner):
run_name = ''
experiment_name = 'go2_ac_moe_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgDualMoECTS(LeggedRobotCfgDualMoECTS):
@@ -295,7 +270,7 @@ class GO2CfgDualMoECTS(LeggedRobotCfgDualMoECTS):
class runner(LeggedRobotCfgDualMoECTS.runner):
run_name = ''
experiment_name = 'go2_dual_moe_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgREMCTS(LeggedRobotCfgREMCTS):
@@ -305,5 +280,5 @@ class GO2CfgREMCTS(LeggedRobotCfgREMCTS):
class runner(LeggedRobotCfgREMCTS.runner):
run_name = ''
experiment_name = 'go2_rem_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500

View File

@@ -117,7 +117,7 @@ class GO2Cfg(LeggedRobotCfg):
limit_ang_vel_at_zero_command_prob = 0.2 # probability of add limiting angular velocity commands when zero command is sampled
limit_vel_prob = 0.2 # probability of limiting linear velocity command
limit_vel_invert_when_continuous = True # invert the limit logic when using continuous sample limit velocity commands
limit_vel = {"lin_vel_x": [-1, 1], "lin_vel_y": [-1, 1], "ang_vel_yaw": [-1, 0, 1]} # sample vel commands from min [-1] or zero [0] or max [1] range only
limit_vel = {"lin_vel_x": [-1, 1], "lin_vel_y": [0], "ang_vel_yaw": [-1, 0, 1]} # sample vel commands from min [-1] or zero [0] or max [1] range only
stop_heading_at_limit = True # stop heading updates when vel is limited
dynamic_resample_commands = True # sample commands with low bounds
command_range_curriculum = [ { # list for command range curriculums at specific training iterations
@@ -134,21 +134,21 @@ class GO2Cfg(LeggedRobotCfg):
'heading': [-1.57, 1.57], # min max [rad]
}, { # list for command range curriculums at specific training iterations
'iter': 20000, # training iteration at which the command ranges are updated
'lin_vel_x': [-3.5, 3.5], # min max [m/s]
'lin_vel_x': [-2.0, 3.5], # min max [m/s]
'lin_vel_y': [-0.5, 0.5], # min max [m/s]
'ang_vel_yaw': [-1.0, 1.0], # min max [rad/s]
'heading': [-1.57, 1.57], # min max [rad]
}, { # list for command range curriculums at specific training iterations
'iter': 30000, # training iteration at which the command ranges are updated
'lin_vel_x': [-4.0, 4.0], # min max [m/s]
'lin_vel_y': [-0.0, 0.0], # min max [m/s]
'ang_vel_yaw': [-0.0, 0.0], # min max [rad/s]
'lin_vel_x': [-2.0, 4.0], # min max [m/s]
'lin_vel_y': [-0.5, 0.5], # min max [m/s]
'ang_vel_yaw': [-1.0, 1.0], # min max [rad/s]
'heading': [-1.57, 1.57], # min max [rad]
}, { # list for command range curriculums at specific training iterations
'iter': 40000, # training iteration at which the command ranges are updated
'lin_vel_x': [-4.5, 4.5], # min max [m/s]
'lin_vel_y': [-0.0, 0.0], # min max [m/s]
'ang_vel_yaw': [-0.0, 0.0], # min max [rad/s]
'lin_vel_x': [-2.0, 4.2], # min max [m/s]
'lin_vel_y': [-0.5, 0.5], # min max [m/s]
'ang_vel_yaw': [-1.0, 1.0], # min max [rad/s]
'heading': [-1.57, 1.57], # min max [rad]
}
]
@@ -185,10 +185,10 @@ class GO2Cfg(LeggedRobotCfg):
class rewards(LeggedRobotCfg.rewards):
soft_dof_pos_limit = 0.9
base_height_target = 0.38
base_height_target = 0.33
only_positive_rewards = False
max_contact_force = 147. # forces above this value are penalized, go2 weight 15kg
curriculum_rewards = [
curriculum_rewards = [ # reward scalars are linearly interpolated between start and end iters
{'reward_name': 'lin_vel_z', 'start_iter': 0, 'end_iter': 1500, 'start_value': 1.0, 'end_value': 0.0},
{'reward_name': 'correct_base_height', 'start_iter': 0, 'end_iter': 5000, 'start_value': 1.0, 'end_value': 10.0},
# {'reward_name': 'dof_power', 'start_iter': 0, 'end_iter': 3000, 'start_value': 1.0, 'end_value': 0.1},
@@ -206,33 +206,7 @@ class GO2Cfg(LeggedRobotCfg):
}
min_legs_distance = 0.1 # min distance between legs to not be considered stumbling
class scales:
# tracking_lin_vel = 1.0
# tracking_ang_vel = 0.2
# lin_vel_z = -10.0
# base_height = -50.0
# action_rate = -0.005
# similar_to_default = -0.1
# dof_power = -1e-3 # 能够明显抑制跳跃
# dof_acc = -3e-7
# tracking_lin_vel = 1.0
# tracking_ang_vel = 0.5
# lin_vel_z = -2.0
# ang_vel_xy = -0.05
# dof_acc = -2.5e-7
# dof_power = -1e-3 # 能够明显抑制跳跃
# # torques = -1e-4 # 无用会走着走着倒了
# correct_base_height = -10.0
# action_rate = -0.01
# action_smoothness = -0.01
# collision = -1.0
# dof_pos_limits = -2.0
# feet_regulation = -0.05
# hip_to_default = -0.1
# similar_to_default = -0.05
# CTS reward
tracking_lin_vel = 1.0
tracking_lin_vel = 2.0 # Increase for faster running
tracking_ang_vel = 0.5
lin_vel_z = -2.0
ang_vel_xy = -0.05
@@ -245,11 +219,13 @@ class GO2Cfg(LeggedRobotCfg):
collision = -1.0
dof_pos_limits = -2.0
feet_regulation = -0.05
# CTS奖励训出来双脚距离非常近, 真机效果很差, 但是sim2sim能上20cm楼梯, 尝试加入hip_to_default奖励或similar_to_default奖励
hip_to_default = -0.05 # 在训练到y=1.5, 双脚会明显碰撞, 为避免该问题提升hip, 效果更差, 还是保持0.05 (y最大也只到0.1了)
# legs_distance = -1.5 # 奖励双脚距离, 避免CTS训练出来双脚距离过近, 尝试加入后robogauge flat验证效果变差, 删除
# CTS reward trains to have very close feet distance, real robot performance is poor, but sim2sim can climb 20cm stairs, try to add hip_to_default reward or similar_to_default reward
# training to y=1.5, font feet will collide noticeably, max y=1.0
hip_to_default = -0.05
# legs_distance = -1.5 # not good performance, avoid leg collision
# similar_to_default = -0.01
# feet_contact_forces = -1.0 # 尝试加入但并没有起到任何效果, 删除
# feet_contact_forces = -1.0 # try to add but no effect, remove
x_command_hip_regular = -0.5 # when x command exists, encourage symmetrical hip positions
turn_over_roll_threshold = math.pi / 4 # threshold on roll to use turn over rewards
class turn_over_scales:
@@ -268,7 +244,7 @@ class GO2CfgPPO(LeggedRobotCfgPPO):
class runner(LeggedRobotCfgPPO.runner):
run_name = ''
experiment_name = 'go2_ppo'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgCTS(LeggedRobotCfgCTS):
@@ -276,7 +252,7 @@ class GO2CfgCTS(LeggedRobotCfgCTS):
num_steps_per_env = 24
run_name = ''
experiment_name = 'go2_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class policy(LeggedRobotCfgCTS.policy):
@@ -294,7 +270,7 @@ class GO2CfgMoECTS(LeggedRobotCfgMoECTS):
class runner(LeggedRobotCfgMoECTS.runner):
run_name = ''
experiment_name = 'go2_moe_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgMCPCTS(LeggedRobotCfgMCPCTS):
@@ -305,7 +281,7 @@ class GO2CfgMCPCTS(LeggedRobotCfgMCPCTS):
class runner(LeggedRobotCfgMCPCTS.runner):
run_name = ''
experiment_name = 'go2_mcp_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgACMoECTS(LeggedRobotCfgACMoECTS):
@@ -315,7 +291,7 @@ class GO2CfgACMoECTS(LeggedRobotCfgACMoECTS):
class runner(LeggedRobotCfgACMoECTS.runner):
run_name = ''
experiment_name = 'go2_ac_moe_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgDualMoECTS(LeggedRobotCfgDualMoECTS):
@@ -325,7 +301,7 @@ class GO2CfgDualMoECTS(LeggedRobotCfgDualMoECTS):
class runner(LeggedRobotCfgDualMoECTS.runner):
run_name = ''
experiment_name = 'go2_dual_moe_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgREMCTS(LeggedRobotCfgREMCTS):
@@ -335,5 +311,5 @@ class GO2CfgREMCTS(LeggedRobotCfgREMCTS):
class runner(LeggedRobotCfgREMCTS.runner):
run_name = ''
experiment_name = 'go2_rem_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500

View File

@@ -191,32 +191,6 @@ class GO2Cfg(LeggedRobotCfg):
# }
min_legs_distance = 0.1 # min distance between legs to not be considered stumbling
class scales:
# tracking_lin_vel = 1.0
# tracking_ang_vel = 0.2
# lin_vel_z = -10.0
# base_height = -50.0
# action_rate = -0.005
# similar_to_default = -0.1
# dof_power = -1e-3 # 能够明显抑制跳跃
# dof_acc = -3e-7
# tracking_lin_vel = 1.0
# tracking_ang_vel = 0.5
# lin_vel_z = -2.0
# ang_vel_xy = -0.05
# dof_acc = -2.5e-7
# dof_power = -1e-3 # 能够明显抑制跳跃
# # torques = -1e-4 # 无用会走着走着倒了
# correct_base_height = -10.0
# action_rate = -0.01
# action_smoothness = -0.01
# collision = -1.0
# dof_pos_limits = -2.0
# feet_regulation = -0.05
# hip_to_default = -0.1
# similar_to_default = -0.05
# CTS reward
tracking_lin_vel = 1.0
tracking_ang_vel = 0.5
lin_vel_z = -2.0
@@ -230,11 +204,12 @@ class GO2Cfg(LeggedRobotCfg):
collision = -1.0
dof_pos_limits = -2.0
feet_regulation = -0.05
# CTS奖励训出来双脚距离非常近, 真机效果很差, 但是sim2sim能上20cm楼梯, 尝试加入hip_to_default奖励或similar_to_default奖励
hip_to_default = -0.05 # 在训练到y=1.5, 双脚会明显碰撞, 为避免该问题提升hip, 效果更差, 还是保持0.05 (y最大也只到0.1了)
# legs_distance = -1.5 # 奖励双脚距离, 避免CTS训练出来双脚距离过近, 尝试加入后robogauge flat验证效果变差, 删除
# CTS reward trains to have very close feet distance, real robot performance is poor, but sim2sim can climb 20cm stairs, try to add hip_to_default reward or similar_to_default reward
# training to y=1.5, font feet will collide noticeably, max y=1.0
hip_to_default = -0.05
# legs_distance = -1.5 # not good performance, avoid leg collision
# similar_to_default = -0.01
# feet_contact_forces = -1.0 # 尝试加入但并没有起到任何效果, 删除
# feet_contact_forces = -1.0 # try to add but no effect, remove
turn_over_roll_threshold = math.pi / 4 # threshold on roll to use turn over rewards
class turn_over_scales:
@@ -253,7 +228,7 @@ class GO2CfgPPO(LeggedRobotCfgPPO):
class runner(LeggedRobotCfgPPO.runner):
run_name = ''
experiment_name = 'go2_ppo'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgCTS(LeggedRobotCfgCTS):
@@ -261,7 +236,7 @@ class GO2CfgCTS(LeggedRobotCfgCTS):
num_steps_per_env = 24
run_name = ''
experiment_name = 'go2_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class policy(LeggedRobotCfgCTS.policy):
@@ -279,7 +254,7 @@ class GO2CfgMoECTS(LeggedRobotCfgMoECTS):
class runner(LeggedRobotCfgMoECTS.runner):
run_name = ''
experiment_name = 'go2_moe_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgMCPCTS(LeggedRobotCfgMCPCTS):
@@ -290,7 +265,7 @@ class GO2CfgMCPCTS(LeggedRobotCfgMCPCTS):
class runner(LeggedRobotCfgMCPCTS.runner):
run_name = ''
experiment_name = 'go2_mcp_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgACMoECTS(LeggedRobotCfgACMoECTS):
@@ -300,7 +275,7 @@ class GO2CfgACMoECTS(LeggedRobotCfgACMoECTS):
class runner(LeggedRobotCfgACMoECTS.runner):
run_name = ''
experiment_name = 'go2_ac_moe_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgDualMoECTS(LeggedRobotCfgDualMoECTS):
@@ -310,7 +285,7 @@ class GO2CfgDualMoECTS(LeggedRobotCfgDualMoECTS):
class runner(LeggedRobotCfgDualMoECTS.runner):
run_name = ''
experiment_name = 'go2_dual_moe_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgREMCTS(LeggedRobotCfgREMCTS):
@@ -320,5 +295,5 @@ class GO2CfgREMCTS(LeggedRobotCfgREMCTS):
class runner(LeggedRobotCfgREMCTS.runner):
run_name = ''
experiment_name = 'go2_rem_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500

View File

@@ -191,32 +191,6 @@ class GO2Cfg(LeggedRobotCfg):
# }
min_legs_distance = 0.1 # min distance between legs to not be considered stumbling
class scales:
# tracking_lin_vel = 1.0
# tracking_ang_vel = 0.2
# lin_vel_z = -10.0
# base_height = -50.0
# action_rate = -0.005
# similar_to_default = -0.1
# dof_power = -1e-3 # 能够明显抑制跳跃
# dof_acc = -3e-7
# tracking_lin_vel = 1.0
# tracking_ang_vel = 0.5
# lin_vel_z = -2.0
# ang_vel_xy = -0.05
# dof_acc = -2.5e-7
# dof_power = -1e-3 # 能够明显抑制跳跃
# # torques = -1e-4 # 无用会走着走着倒了
# correct_base_height = -10.0
# action_rate = -0.01
# action_smoothness = -0.01
# collision = -1.0
# dof_pos_limits = -2.0
# feet_regulation = -0.05
# hip_to_default = -0.1
# similar_to_default = -0.05
# CTS reward
tracking_lin_vel = 1.0
tracking_ang_vel = 0.5
lin_vel_z = -2.0
@@ -230,11 +204,12 @@ class GO2Cfg(LeggedRobotCfg):
collision = -1.0
dof_pos_limits = -2.0
feet_regulation = -0.05
# CTS奖励训出来双脚距离非常近, 真机效果很差, 但是sim2sim能上20cm楼梯, 尝试加入hip_to_default奖励或similar_to_default奖励
hip_to_default = -0.05 # 在训练到y=1.5, 双脚会明显碰撞, 为避免该问题提升hip, 效果更差, 还是保持0.05 (y最大也只到0.1了)
# legs_distance = -1.5 # 奖励双脚距离, 避免CTS训练出来双脚距离过近, 尝试加入后robogauge flat验证效果变差, 删除
# CTS reward trains to have very close feet distance, real robot performance is poor, but sim2sim can climb 20cm stairs, try to add hip_to_default reward or similar_to_default reward
# training to y=1.5, font feet will collide noticeably, max y=1.0
hip_to_default = -0.05
# legs_distance = -1.5 # not good performance, avoid leg collision
# similar_to_default = -0.01
# feet_contact_forces = -1.0 # 尝试加入但并没有起到任何效果, 删除
# feet_contact_forces = -1.0 # try to add but no effect, remove
turn_over_roll_threshold = math.pi / 4 # threshold on roll to use turn over rewards
class turn_over_scales:
@@ -253,7 +228,7 @@ class GO2CfgPPO(LeggedRobotCfgPPO):
class runner(LeggedRobotCfgPPO.runner):
run_name = ''
experiment_name = 'go2_ppo'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgCTS(LeggedRobotCfgCTS):
@@ -261,7 +236,7 @@ class GO2CfgCTS(LeggedRobotCfgCTS):
num_steps_per_env = 24
run_name = ''
experiment_name = 'go2_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class policy(LeggedRobotCfgCTS.policy):
@@ -279,7 +254,7 @@ class GO2CfgMoECTS(LeggedRobotCfgMoECTS):
class runner(LeggedRobotCfgMoECTS.runner):
run_name = ''
experiment_name = 'go2_moe_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgMCPCTS(LeggedRobotCfgMCPCTS):
@@ -290,7 +265,7 @@ class GO2CfgMCPCTS(LeggedRobotCfgMCPCTS):
class runner(LeggedRobotCfgMCPCTS.runner):
run_name = ''
experiment_name = 'go2_mcp_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgACMoECTS(LeggedRobotCfgACMoECTS):
@@ -300,7 +275,7 @@ class GO2CfgACMoECTS(LeggedRobotCfgACMoECTS):
class runner(LeggedRobotCfgACMoECTS.runner):
run_name = ''
experiment_name = 'go2_ac_moe_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgDualMoECTS(LeggedRobotCfgDualMoECTS):
@@ -310,7 +285,7 @@ class GO2CfgDualMoECTS(LeggedRobotCfgDualMoECTS):
class runner(LeggedRobotCfgDualMoECTS.runner):
run_name = ''
experiment_name = 'go2_dual_moe_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500
class GO2CfgREMCTS(LeggedRobotCfgREMCTS):
@@ -320,5 +295,5 @@ class GO2CfgREMCTS(LeggedRobotCfgREMCTS):
class runner(LeggedRobotCfgREMCTS.runner):
run_name = ''
experiment_name = 'go2_rem_cts'
max_iterations = 120000
max_iterations = 150000
save_interval = 500

View File

@@ -50,4 +50,19 @@ class Go2Robot(LeggedRobot):
# print(f"acc: {self.privileged_obs_buf[:,48+4+12:48+4+12+12].min(), self.privileged_obs_buf[:,48+4+12:48+4+12+12].max()}")
if self.add_noise:
self.obs_buf += (2 * torch.rand_like(self.obs_buf) - 1) * self.noise_scale_vec
self.obs_buf += (2 * torch.rand_like(self.obs_buf) - 1) * self.noise_scale_vec
def _reward_hip_to_default(self):
hip_dof_names = ['FL_hip_joint', 'FR_hip_joint', 'RL_hip_joint', 'RR_hip_joint']
hip_dof_indices = [0, 3, 6, 9]
hip_pos = self.dof_pos[:, hip_dof_indices]
default_hip_pos = self.default_dof_pos[:, hip_dof_indices]
return torch.sum(torch.abs(hip_pos - default_hip_pos), dim=1)
def _reward_x_command_hip_regular(self):
hip_dof_names = ['FL_hip_joint', 'FR_hip_joint', 'RL_hip_joint', 'RR_hip_joint']
hip_dof_indices = [0, 3, 6, 9]
hip_pos = self.dof_pos[:, hip_dof_indices]
x_command_ratio = torch.abs(self.commands[:,0]) / torch.norm(self.commands[:,:3], dim=1)
rew = torch.abs(hip_pos[:,0]+hip_pos[:,1]) + torch.abs(hip_pos[:,2]+hip_pos[:,3])
return rew * x_command_ratio

View File

@@ -13,7 +13,7 @@
<texture type="skybox" builtin="flat" rgb1="0 0 0" rgb2="0 0 0" width="512" height="3072" />
<texture type="2d" name="groundplane" builtin="checker" mark="edge" rgb1="0.2 0.3 0.4" rgb2="0.1 0.2 0.3" markrgb="0.8 0.8 0.8" width="300" height="300" />
<material name="groundplane" texture="groundplane" texuniform="true" texrepeat="5 5" reflectance="0.2" />
<texture name="wood_tex" type="2d" file="./assets/wood.png" rgb1="0.6 0.4 0.2" width="512" height="512" /><material name="wood_mat" texture="wood_tex" specular="0.2" shininess="0.1" rgba="1 1 1 1" /><texture name="sponge_tex" type="2d" builtin="flat" rgb1="1.0 0.7 0.7" width="512" height="512" /><material name="mat_sponge" texture="sponge_tex" specular="0.1" shininess="0.1" rgba="1 0.7 0.7 1" /><hfield name="perlin_hfield" size="1.2 2.4 0.08 0.1" file="height_field.png" /></asset>
<texture name="wood_tex" type="2d" file="./assets/wood.png" rgb1="0.6 0.4 0.2" width="512" height="512" /><material name="wood_mat" texture="wood_tex" specular="0.2" shininess="0.1" rgba="1 1 1 1" /><texture name="sponge_tex" type="2d" builtin="flat" rgb1="0.90196 0.83922 0.56471" width="512" height="512" /><material name="mat_sponge" texture="sponge_tex" specular="0.1" shininess="0.1" rgba="1 0.7 0.7 1" /><hfield name="perlin_hfield" size="1.2 2.4 0.08 0.1" file="height_field.png" /></asset>
<worldbody>
<light pos="1 0 3.5" dir="0 0 -1" directional="true" />

View File

@@ -6,8 +6,8 @@ import noise
import os
ROBOT = "go2"
INPUT_SCENE_PATH = os.path.join(os.path.dirname(__file__), "scene.xml")
OUTPUT_SCENE_PATH = os.path.join(os.path.dirname(__file__), "scene_terrain.xml")
INPUT_SCENE_PATH = os.path.join(os.path.dirname(__file__), "flat.xml")
OUTPUT_SCENE_PATH = os.path.join(os.path.dirname(__file__), "race_track_tmp.xml")
PATH_DIR = Path(__file__).parent.absolute()
# zyx euler angle to quaternion
def euler_to_quat(roll, pitch, yaw):
@@ -114,7 +114,8 @@ class TerrainGenerator:
tex.attrib["name"] = "sponge_tex"
tex.attrib["type"] = "2d"
tex.attrib["builtin"] = "flat" # 使用内置平面纹理,不需要 file 路径
tex.attrib["rgb1"] = "1.0 0.7 0.7" # 设置颜色:粉色 (参考图片颜色)
# tex.attrib["rgb1"] = "1.0 0.7 0.7" # 设置颜色:粉色 (参考图片颜色)
tex.attrib["rgb1"] = "0.90196 0.83922 0.56471" # 设置颜色:黄色
tex.attrib["width"] = "512"
tex.attrib["height"] = "512"

View File

@@ -1,12 +1,3 @@
# -*- coding: utf-8 -*-
'''
@File : batch_compress.py
@Time : 2026/01/09 17:49:54
@Author : wty-yy, Gemini 3
@Version : 1.0
@Blog : https://wty-yy.github.io/
@Desc : None
'''
import os
import subprocess
from pathlib import Path
@@ -14,66 +5,53 @@ from pathlib import Path
def smart_compress(logs_root):
logs_path = Path(logs_root).resolve()
if not logs_path.exists():
print(f"找不到目录: {logs_root}")
print(f"Can't find directory: {logs_root}")
return
# 遍历 logs 下的第一层子目录 (cts_vanilla, go2_moe_cts 等)
projects = [d for d in logs_path.iterdir() if d.is_dir()]
for project in projects:
project_name = project.name
print(f"\n🚀 正在处理项目: {project_name}")
print(f"\n🚀 Processing project: {project_name}")
# 1. 搜寻需要包含的内容
include_items = []
# 检查是否存在 exported 文件夹
if (project / "exported").exists():
include_items.append("exported")
# 搜寻所有包含 tfevents 的文件夹 (如 Jan04_15-55-59_)
# 我们寻找 events 文件,然后取其父目录名(相对于项目根目录)
event_folders = set()
for event_file in project.rglob("events.out.tfevents*"):
# 计算相对于项目根目录的路径
relative_folder = event_file.parent.relative_to(project)
event_folders.add(str(relative_folder))
include_items.extend(list(event_folders))
if not include_items:
print(f"⚠️ 跳过 {project_name}: 未发现符合条件的训练数据或 exported 文件夹")
print(f"⚠️ Skipping {project_name}: No eligible training data or exported folder found")
continue
# 2. 构造压缩命令
output_zst = logs_path / f"{project_name}.tar.zst"
# 命令解释:
# -C: 切换到项目所在目录,这样压缩包内的路径不会带一堆无用的父级前缀
# --exclude='*.pt': 显式排除所有模型权重文件
# -T0: zstd 开启全核并行
tar_cmd = [
"tar",
"-I", "zstd -T0 -3",
"-C", str(project),
"--exclude=*.pt",
"--exclude=*.pth", # 预防万一有 .pth
"--exclude=*.pth",
"-cf", str(output_zst)
] + include_items
print(f"📦 正在打包 (已排除 .pt 文件)...")
print(f"📦 Packaging (excluding .pt files and .pth files)...")
try:
# 执行压缩
subprocess.run(tar_cmd, check=True)
# 统计结果
final_size = output_zst.stat().st_size / (1024 * 1024)
print(f"完成! 压缩包: {output_zst.name} ({final_size:.2f} MB)")
print(f"Done! Archive: {output_zst.name} ({final_size:.2f} MB)")
except subprocess.CalledProcessError as e:
print(f"{project_name} 压缩失败: {e}")
print(f"{project_name} Compression failed: {e}")
if __name__ == "__main__":
# 执行目录
# Execution directory
TARGET_LOGS_DIR = "./logs"
smart_compress(TARGET_LOGS_DIR)