v1.1.0; fix metrics bugs
This commit is contained in:
@@ -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