v1.1.0; fix metrics bugs
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
# UPDATE
|
||||
## 20260110
|
||||
### v1.1.0
|
||||
1. 修复三个Metric计算错误
|
||||
1. DofLimitsMetric中soft_lower_limit, soft_upper_limit范围计算错误,通过原来比例为0.7但是按照整个范围对单边做限制,修改为0.4比例等价之前的限制,表示关节超过总范围的40%开始惩罚
|
||||
2. OrientationStabilityMetric中错误将roll计算成了pitch,修改为正确的roll计算,不然slope会一直扣分
|
||||
3. TorqueSmoothnessMetric计算错误,之前的last_torque一直忘记更新了,完全错误,修改为上一步的torque
|
||||
2. 修复delay action中actions_start_decimation随机数范围错误,之前是[0, frame_skip],修改为[0, frame_skip-1],避免出现不执行action的bug
|
||||
## 20260106
|
||||
### v1.0.5
|
||||
1. `robogauge/scripts/server.py`加入`--port`设置端口配置选项, 加入`--num-processes`设置并行进程数量
|
||||
|
||||
@@ -14,7 +14,7 @@ class Go2FlatGaugeConfig(FlatGaugeConfig):
|
||||
class metrics(FlatGaugeConfig.metrics):
|
||||
class dof_limits(FlatGaugeConfig.metrics.dof_limits):
|
||||
enabled = True
|
||||
soft_dof_limit_ratio = 0.7
|
||||
soft_dof_limit_ratio = 0.4
|
||||
dof_names = ['hip', 'thigh'] # List of DOF names to monitor, None for all
|
||||
|
||||
class goals(FlatGaugeConfig.goals):
|
||||
|
||||
@@ -14,5 +14,5 @@ class Go2ObstacleGaugeConfig(ObstacleGaugeConfig):
|
||||
class metrics(ObstacleGaugeConfig.metrics):
|
||||
class dof_limits(ObstacleGaugeConfig.metrics.dof_limits):
|
||||
enabled = True
|
||||
soft_dof_limit_ratio = 0.7
|
||||
soft_dof_limit_ratio = 0.4
|
||||
dof_names = ['hip', 'thigh'] # List of DOF names to monitor, None for all
|
||||
|
||||
@@ -14,12 +14,12 @@ class Go2SlopeForwardGaugeConfig(SlopeForwardGaugeConfig):
|
||||
class metrics(SlopeForwardGaugeConfig.metrics):
|
||||
class dof_limits(SlopeForwardGaugeConfig.metrics.dof_limits):
|
||||
enabled = True
|
||||
soft_dof_limit_ratio = 0.7
|
||||
soft_dof_limit_ratio = 0.4
|
||||
dof_names = ['hip', 'thigh'] # List of DOF names to monitor, None for all
|
||||
|
||||
class Go2SlopeBackwardGaugeConfig(SlopeBackwardGaugeConfig):
|
||||
class metrics(SlopeBackwardGaugeConfig.metrics):
|
||||
class dof_limits(SlopeBackwardGaugeConfig.metrics.dof_limits):
|
||||
enabled = True
|
||||
soft_dof_limit_ratio = 0.7
|
||||
soft_dof_limit_ratio = 0.4
|
||||
dof_names = ['hip', 'thigh'] # List of DOF names to monitor, None for all
|
||||
|
||||
@@ -14,12 +14,12 @@ class Go2StairsForwardGaugeConfig(StairsForwardGaugeConfig):
|
||||
class metrics(StairsForwardGaugeConfig.metrics):
|
||||
class dof_limits(StairsForwardGaugeConfig.metrics.dof_limits):
|
||||
enabled = True
|
||||
soft_dof_limit_ratio = 0.7
|
||||
soft_dof_limit_ratio = 0.4
|
||||
dof_names = ['hip', 'thigh'] # List of DOF names to monitor, None for all
|
||||
|
||||
class Go2StairsBackwardGaugeConfig(StairsBackwardGaugeConfig):
|
||||
class metrics(StairsBackwardGaugeConfig.metrics):
|
||||
class dof_limits(StairsBackwardGaugeConfig.metrics.dof_limits):
|
||||
enabled = True
|
||||
soft_dof_limit_ratio = 0.7
|
||||
soft_dof_limit_ratio = 0.4
|
||||
dof_names = ['hip', 'thigh'] # List of DOF names to monitor, None for all
|
||||
|
||||
@@ -14,5 +14,5 @@ class Go2WaveGaugeConfig(WaveGaugeConfig):
|
||||
class metrics(WaveGaugeConfig.metrics):
|
||||
class dof_limits(WaveGaugeConfig.metrics.dof_limits):
|
||||
enabled = True
|
||||
soft_dof_limit_ratio = 0.7
|
||||
soft_dof_limit_ratio = 0.4
|
||||
dof_names = ['hip', 'thigh'] # List of DOF names to monitor, None for all
|
||||
|
||||
@@ -35,8 +35,12 @@ class DofLimitsMetric(BaseMetric):
|
||||
lower_limit = sim_data.proprio.joint.limits[i, 0]
|
||||
upper_limit = sim_data.proprio.joint.limits[i, 1]
|
||||
dof_range = upper_limit - lower_limit
|
||||
soft_lower_limit = lower_limit + (1 - self.soft_dof_limit_ratio) * dof_range
|
||||
soft_upper_limit = upper_limit - (1 - self.soft_dof_limit_ratio) * dof_range
|
||||
if dof_range <= 1e-6:
|
||||
logger.warning(f"DOF range for {sim_data.proprio.joint.names[i]} is too small ({dof_range:.6f}), skipping metric calculation.")
|
||||
continue
|
||||
|
||||
soft_lower_limit = lower_limit + (1 - self.soft_dof_limit_ratio) * dof_range / 2
|
||||
soft_upper_limit = upper_limit - (1 - self.soft_dof_limit_ratio) * dof_range / 2
|
||||
|
||||
pos = sim_data.proprio.joint.pos[i]
|
||||
dof_name = sim_data.proprio.joint.names[i]
|
||||
@@ -53,6 +57,11 @@ class DofLimitsMetric(BaseMetric):
|
||||
values.append(value)
|
||||
else:
|
||||
values.append(value)
|
||||
|
||||
if len(values) == 0:
|
||||
logger.warning("No DOF limit values calculated, returning 0.0.")
|
||||
return 0.0
|
||||
|
||||
rms_value = 1 - np.sqrt(np.mean(np.square(values)))
|
||||
logger.log(1 - rms_value, f'dof_limits/rms', step=sim_data.n_step)
|
||||
return rms_value
|
||||
|
||||
@@ -28,9 +28,9 @@ class OrientationStabilityMetric(BaseMetric):
|
||||
|
||||
def __call__(self, sim_data: SimData, goal_data: GoalData) -> float:
|
||||
projected_gravity = get_projected_gravity(sim_data.proprio.base.quat)
|
||||
projected_x = projected_gravity[0]
|
||||
metric_value = 1 - abs(projected_x) # consider roll only
|
||||
logger.log(abs(projected_x), f'stable_metric/projected_x_abs', step=sim_data.n_step)
|
||||
projected_y = projected_gravity[1]
|
||||
metric_value = 1 - abs(projected_y) # consider roll only
|
||||
logger.log(abs(projected_y), f'stable_metric/projected_y_abs', step=sim_data.n_step)
|
||||
return metric_value
|
||||
|
||||
class TorqueSmoothnessMetric(BaseMetric):
|
||||
@@ -55,6 +55,7 @@ class TorqueSmoothnessMetric(BaseMetric):
|
||||
self.last_torque = current_torque
|
||||
return 1.0 # No change at first step
|
||||
torque_diff = current_torque - self.last_torque
|
||||
self.last_torque = current_torque
|
||||
rms_value = np.sqrt(np.mean(np.square(torque_diff)))
|
||||
metric_value = 1.0 - rms_value / self.scaling_factor
|
||||
logger.log(rms_value, f'stable_metric/torque_rms_diff', step=sim_data.n_step)
|
||||
|
||||
@@ -101,7 +101,7 @@ class BasePipeline:
|
||||
action, p_gains, d_gains, control_type = self.robot.get_action(obs)
|
||||
|
||||
if self.sim_cfg.domain_rand.action_delay:
|
||||
actions_start_decimation = random.randint(0, frame_skip)
|
||||
actions_start_decimation = random.randint(0, frame_skip - 1)
|
||||
else:
|
||||
self.sim.setup_action(action, p_gains, d_gains, control_type)
|
||||
for i in range(frame_skip):
|
||||
|
||||
Reference in New Issue
Block a user