v0.1.12 add all slope levels; plot radar with bar
This commit is contained in:
@@ -4,8 +4,10 @@ from robogauge.tasks.robots import RobotConfig, Go2Config, Go2MoEConfig
|
||||
from robogauge.tasks.pipeline import BasePipeline
|
||||
from robogauge.tasks.gauge import BaseGaugeConfig
|
||||
|
||||
from robogauge.tasks.custom.go2_flat_task import Go2FlatGaugeConfig, Go2FlatConfig, Go2MoEFlatConfig, Go2MoEFlatMujocoConfig
|
||||
from robogauge.tasks.custom.go2 import *
|
||||
|
||||
task_register.register('base', BasePipeline, MujocoConfig, BaseGaugeConfig, RobotConfig)
|
||||
task_register.register('go2_flat', BasePipeline, MujocoConfig, Go2FlatGaugeConfig, Go2FlatConfig)
|
||||
task_register.register('go2_moe_flat', BasePipeline, Go2MoEFlatMujocoConfig, Go2FlatGaugeConfig, Go2MoEFlatConfig)
|
||||
task_register.register('go2_flat', BasePipeline, MujocoConfig, Go2FlatGaugeConfig, Go2Config)
|
||||
task_register.register('go2_moe_flat', BasePipeline, MujocoConfig, Go2FlatGaugeConfig, Go2MoEConfig)
|
||||
task_register.register('go2_slope', BasePipeline, Go2SlopeMujocoConfig, Go2SlopeGaugeConfig, Go2Config)
|
||||
task_register.register('go2_moe_slope', BasePipeline, Go2SlopeMujocoConfig, Go2SlopeGaugeConfig, Go2MoEConfig)
|
||||
10
robogauge/tasks/custom/go2/__init__.py
Normal file
10
robogauge/tasks/custom/go2/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
@File : __init__.py
|
||||
@Time : 2025/12/21 17:10:59
|
||||
@Author : wty-yy
|
||||
@Version : 1.0
|
||||
@Blog : https://wty-yy.github.io/
|
||||
'''
|
||||
from .go2_flat_task import Go2FlatGaugeConfig
|
||||
from .go2_slope_task import Go2SlopeGaugeConfig, Go2SlopeMujocoConfig
|
||||
@@ -37,24 +37,3 @@ class Go2FlatGaugeConfig(FlatGaugeConfig):
|
||||
ang_vel_yaw = 1.5 # +/- rad/s
|
||||
max_cmd_duration = 10.0 # [s] maximum duration to reach the target position
|
||||
reach_threshold = 0.1 # [m] distance threshold to consider the target reached
|
||||
|
||||
class Go2FlatConfig(Go2Config):
|
||||
class commands(Go2Config.commands):
|
||||
lin_vel_x = [-1.8, 1.8] # min max [m/s]
|
||||
lin_vel_y = [-1.8, 1.8] # min max [m/s]
|
||||
ang_vel_yaw = [-2.0, 2.0] # min max [rad/s]
|
||||
|
||||
class Go2MoEFlatConfig(Go2MoEConfig):
|
||||
class commands(Go2Config.commands):
|
||||
lin_vel_x = [-1.8, 1.8] # min max [m/s]
|
||||
lin_vel_y = [-1.8, 1.8] # min max [m/s]
|
||||
ang_vel_yaw = [-2.0, 2.0] # min max [rad/s]
|
||||
|
||||
class control(Go2Config.control):
|
||||
model_path = "{ROBOGAUGE_ROOT_DIR}/resources/models/go2/go2_moe_cts_124k.pt"
|
||||
# model_path = "/home/xfy/Coding/kaiwu2025/rob_finals/sim2real/models/v6-2_106503/kaiwu_script_v6-2_106503.pt"
|
||||
|
||||
class Go2MoEFlatMujocoConfig(MujocoConfig):
|
||||
class domain_rand(MujocoConfig.domain_rand):
|
||||
base_mass = 0.0
|
||||
friction = 1.0
|
||||
24
robogauge/tasks/custom/go2/go2_slope_task.py
Normal file
24
robogauge/tasks/custom/go2/go2_slope_task.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
@File : go2_slope_task.py
|
||||
@Time : 2025/12/21 17:06:27
|
||||
@Author : wty-yy
|
||||
@Version : 1.0
|
||||
@Blog : https://wty-yy.github.io/
|
||||
@Desc : Go2 Slope Task Configuration
|
||||
'''
|
||||
from robogauge.tasks.robots import Go2Config, Go2MoEConfig
|
||||
from robogauge.tasks.gauge import SlopeGaugeConfig
|
||||
from robogauge.tasks.simulator.mujoco_config import MujocoConfig
|
||||
|
||||
class Go2SlopeGaugeConfig(SlopeGaugeConfig):
|
||||
class metrics(SlopeGaugeConfig.metrics):
|
||||
class dof_limits(SlopeGaugeConfig.metrics.dof_limits):
|
||||
enabled = True
|
||||
soft_dof_limit_ratio = 0.7
|
||||
dof_names = ['hip', 'thigh'] # List of DOF names to monitor, None for all
|
||||
|
||||
class Go2SlopeMujocoConfig(MujocoConfig):
|
||||
class domain_rand(MujocoConfig.domain_rand):
|
||||
action_delay = True
|
||||
friction = 2.4
|
||||
@@ -1,3 +1,4 @@
|
||||
from .base_gauge import BaseGauge
|
||||
from .base_gauge_config import BaseGaugeConfig
|
||||
from .gauge_configs.flat_gauge_config import FlatGaugeConfig
|
||||
from .gauge_configs.slope_gauge_config import SlopeGaugeConfig
|
||||
|
||||
@@ -20,18 +20,19 @@ class BaseGaugeConfig(Config):
|
||||
|
||||
class goals:
|
||||
class max_velocity: # goal with maximum velocity
|
||||
enabled = True
|
||||
enabled = False
|
||||
cmd_duration = 5.0 # [s] duration for each velocity command
|
||||
|
||||
class diagonal_velocity: # goal with diagonal velocity changes
|
||||
enabled = True
|
||||
enabled = False
|
||||
cmd_duration = 6.0 # [s] duration for a pair of diagonal velocity commands
|
||||
|
||||
class target_pos_velocity: # goal to reach a target position by velocity command
|
||||
enabled = True
|
||||
enabled = False
|
||||
target_pos = [5, 0, 0] # x y z [m], target position in the environment, used for target position goal
|
||||
lin_vel_x = 1.0 # +/- m/s
|
||||
ang_vel_yaw = 1.0 # +/- rad/s
|
||||
lin_vel_y = 1.0 # +/- m/s
|
||||
ang_vel_yaw = 1.5 # +/- rad/s
|
||||
max_cmd_duration = 10.0 # [s] maximum duration to reach the target position
|
||||
reach_threshold = 0.1
|
||||
|
||||
|
||||
@@ -16,40 +16,3 @@ class FlatGaugeConfig(BaseGaugeConfig):
|
||||
terrain_name = "flat_0" # {type}_{level}
|
||||
terrain_xml = '{ROBOGAUGE_ROOT_DIR}/resources/terrains/flat.xml'
|
||||
terrain_spawn_pos = [0, 0, 0] # x y z [m], robot freejoint spawn position on the terrain
|
||||
|
||||
class goals(BaseGaugeConfig.goals):
|
||||
class max_velocity: # goal with maximum velocity
|
||||
enabled = True
|
||||
move_duration = 5.0 # [s] duration for each velocity command
|
||||
end_stance = True # whether to end with zero velocity command
|
||||
standce_duration = 2.0 # [s] duration for the ending stance command
|
||||
|
||||
class diagonal_velocity: # goal with diagonal velocity changes
|
||||
enabled = True
|
||||
cmd_duration = 6.0 # [s] duration for a pair of diagonal velocity commands
|
||||
|
||||
class target_pos_velocity: # goal to reach a target position by velocity command, config target at assets.target_pos
|
||||
enabled = True
|
||||
target_pos = [5, 0, 0] # x y z [m], target position in the environment, used for target position goal
|
||||
lin_vel_x = 1.0 # +/- m/s
|
||||
ang_vel_yaw = 1.0 # +/- rad/s
|
||||
max_cmd_duration = 10.0 # [s] maximum duration to reach the target position
|
||||
reach_threshold = 0.1
|
||||
|
||||
class metrics(BaseGaugeConfig.metrics):
|
||||
metric_dt = 0.1 # [s] frequency to compute metrics
|
||||
class dof_limits:
|
||||
enabled = True
|
||||
soft_dof_limit_ratio = 0.9
|
||||
dof_names = None # List of DOF names to monitor, None for all
|
||||
|
||||
class visualization:
|
||||
enabled = True
|
||||
dof_torque = True
|
||||
dof_pos = True
|
||||
|
||||
class lin_vel_err:
|
||||
enabled = True
|
||||
|
||||
class ang_vel_err:
|
||||
enabled = True
|
||||
|
||||
28
robogauge/tasks/gauge/gauge_configs/slope_gauge_config.py
Normal file
28
robogauge/tasks/gauge/gauge_configs/slope_gauge_config.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
@File : slope_gauge_config.py
|
||||
@Time : 2025/12/21 17:02:23
|
||||
@Author : wty-yy
|
||||
@Version : 1.0
|
||||
@Blog : https://wty-yy.github.io/
|
||||
@Desc : Slope Gauge Configuration
|
||||
'''
|
||||
from robogauge.tasks.gauge.base_gauge_config import BaseGaugeConfig
|
||||
|
||||
class SlopeGaugeConfig(BaseGaugeConfig):
|
||||
gauge_class = 'BaseGauge'
|
||||
|
||||
class assets(BaseGaugeConfig.assets):
|
||||
terrain_name = "slope_5" # {type}_{level}
|
||||
terrain_xml = '{ROBOGAUGE_ROOT_DIR}/resources/terrains/slope/slope_10.xml'
|
||||
terrain_spawn_pos = [0, 0, 0] # x y z [m], robot freejoint spawn position on the terrain
|
||||
|
||||
class goals:
|
||||
class target_pos_velocity: # goal to reach a target position by velocity command
|
||||
enabled = True
|
||||
target_pos = [4, 0, 2.0] # x y z [m], target position in the environment, used for target position goal
|
||||
lin_vel_x = 1.0 # +/- m/s
|
||||
lin_vel_y = 1.0 # +/- m/s
|
||||
ang_vel_yaw = 1.5 # +/- rad/s
|
||||
max_cmd_duration = 20.0 # [s] maximum duration to reach the target position
|
||||
reach_threshold = 0.1
|
||||
@@ -9,6 +9,7 @@
|
||||
'''
|
||||
import yaml
|
||||
import random
|
||||
import traceback
|
||||
import numpy as np
|
||||
from pathlib import Path
|
||||
from copy import deepcopy
|
||||
@@ -104,7 +105,7 @@ class BasePipeline:
|
||||
if self.gauge.is_reset(sim_data):
|
||||
sim_data = self.reset_sim(sim_data)
|
||||
except Exception as e:
|
||||
logger.error(f"❌ Pipeline execution failed with error: {e}")
|
||||
logger.error(f"❌ Pipeline execution failed with error: {e},\n{traceback.format_exc()}")
|
||||
self.gauge.switch_to_next_goal() # save current goal metrics
|
||||
self.gauge.save_results()
|
||||
return logger.log_dir, e
|
||||
|
||||
@@ -21,7 +21,7 @@ class RobotConfig(Config):
|
||||
class control:
|
||||
device = 'cpu'
|
||||
# torch script model path
|
||||
model_path = "{ROBOGAUGE_ROOT_DIR}/resources/models/go2/go2_cts_83501.pt"
|
||||
model_path = "{ROBOGAUGE_ROOT_DIR}/resources/models/go2/go2_cts_max2_100k.pt"
|
||||
control_dt = 0.02 # 50 Hz
|
||||
control_type = 'P' # Position control
|
||||
support_goal: Literal['velocity', 'position'] = 'velocity'
|
||||
|
||||
@@ -20,7 +20,7 @@ class Go2Config(RobotConfig):
|
||||
|
||||
class control(RobotConfig.control):
|
||||
device = 'cpu'
|
||||
model_path = "{ROBOGAUGE_ROOT_DIR}/resources/models/go2/go2_cts_83501.pt"
|
||||
model_path = "{ROBOGAUGE_ROOT_DIR}/resources/models/go2/go2_cts_max2_100k.pt"
|
||||
# model_path = "{ROBOGAUGE_ROOT_DIR}/resources/models/go2/go2_cts_cmd-1,1_38k.pt"
|
||||
control_dt = 0.02 # 50 Hz
|
||||
control_type = 'P' # Position control
|
||||
@@ -47,8 +47,8 @@ class Go2Config(RobotConfig):
|
||||
cmd = [2.0, 2.0, 0.25]
|
||||
|
||||
class commands(RobotConfig.commands):
|
||||
lin_vel_x = [-1.5, 1.5] # min max [m/s]
|
||||
lin_vel_y = [-1, 1] # min max [m/s]
|
||||
lin_vel_x = [-2.0, 2.0] # min max [m/s]
|
||||
lin_vel_y = [-1.0, 1.0] # min max [m/s]
|
||||
lin_vel_z = None # min max [m/s]
|
||||
ang_vel_roll = None # min max [rad/s]
|
||||
ang_vel_pitch = None # min max [rad/s]
|
||||
|
||||
@@ -15,7 +15,12 @@ from robogauge.tasks.robots.go2.go2 import Go2
|
||||
class Go2MoE(Go2):
|
||||
def get_action(self, obs: np.ndarray):
|
||||
obs_tensor = torch.tensor(obs, dtype=torch.float32).unsqueeze(0).to(self.device)
|
||||
action, weights = self.model(obs_tensor)
|
||||
action, results = self.model(obs_tensor)
|
||||
if isinstance(results, tuple):
|
||||
weights, latent = results
|
||||
latent = latent.detach().cpu().numpy().squeeze(0)
|
||||
else:
|
||||
weights = results
|
||||
action = action.detach().cpu().numpy().squeeze(0)[self.model2mj_idx]
|
||||
weights = weights.detach().cpu().numpy().squeeze(0)
|
||||
self.last_action = action
|
||||
|
||||
Reference in New Issue
Block a user