This commit is contained in:
wty-yy
2025-12-27 17:42:30 +08:00
parent 0a3985445a
commit f92f34ac14
28 changed files with 452 additions and 22 deletions

View File

@@ -15,6 +15,7 @@ task_register.register('go2.slope', BasePipeline, MujocoConfig, Go2SlopeGaugeCon
task_register.register('go2.wave', BasePipeline, MujocoConfig, Go2WaveGaugeConfig, Go2TerrainConfig)
task_register.register('go2.stairs_up', BasePipeline, MujocoConfig, Go2StairsUpGaugeConfig, Go2TerrainConfig)
task_register.register('go2.stairs_down', BasePipeline, MujocoConfig, Go2StairsDownGaugeConfig, Go2TerrainConfig)
task_register.register('go2.obstacle', BasePipeline, MujocoConfig, Go2ObstacleGaugeConfig, Go2TerrainConfig)
# Go2 MoE
task_register.register('go2_moe.flat', BasePipeline, MujocoConfig, Go2FlatGaugeConfig, Go2MoEConfig)
@@ -22,3 +23,4 @@ task_register.register('go2_moe.slope', BasePipeline, MujocoConfig, Go2SlopeGaug
task_register.register('go2_moe.wave', BasePipeline, MujocoConfig, Go2WaveGaugeConfig, Go2MoETerrainConfig)
task_register.register('go2_moe.stairs_up', BasePipeline, MujocoConfig, Go2StairsUpGaugeConfig, Go2MoETerrainConfig)
task_register.register('go2_moe.stairs_down', BasePipeline, MujocoConfig, Go2StairsDownGaugeConfig, Go2MoETerrainConfig)
task_register.register('go2_moe.obstacle', BasePipeline, MujocoConfig, Go2ObstacleGaugeConfig, Go2MoETerrainConfig)

View File

@@ -11,3 +11,4 @@ from .go2_slope_task import Go2SlopeGaugeConfig
from .go2_wave_task import Go2WaveGaugeConfig
from .go2_stairs_up_task import Go2StairsUpGaugeConfig
from .go2_stairs_down_task import Go2StairsDownGaugeConfig
from .go2_obstacle_task import Go2ObstacleGaugeConfig

View File

@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
'''
@File : go2_obstacle_task.py
@Time : 2025/12/27 14:32:22
@Author : wty-yy
@Version : 1.0
@Blog : https://wty-yy.github.io/
@Desc : Go2 Obstacle Task Configuration
'''
from robogauge.tasks.robots import Go2Config, Go2MoEConfig
from robogauge.tasks.gauge import ObstacleGaugeConfig
from robogauge.tasks.simulator.mujoco_config import MujocoConfig
class Go2ObstacleGaugeConfig(ObstacleGaugeConfig):
class metrics(ObstacleGaugeConfig.metrics):
class dof_limits(ObstacleGaugeConfig.metrics.dof_limits):
enabled = True
soft_dof_limit_ratio = 0.7
dof_names = ['hip', 'thigh'] # List of DOF names to monitor, None for all

View File

@@ -5,3 +5,4 @@ from .gauge_configs.slope_gauge_config import SlopeGaugeConfig
from .gauge_configs.wave_gauge_config import WaveGaugeConfig
from .gauge_configs.stairs_up_gauge_config import StairsUpGaugeConfig
from .gauge_configs.stairs_down_gauge_config import StairsDownGaugeConfig
from .gauge_configs.obstacle_gauge_config import ObstacleGaugeConfig

View File

@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
'''
@File : obstacle_gauge_config.py
@Time : 2025/12/27 14:33:14
@Author : wty-yy
@Version : 1.0
@Blog : https://wty-yy.github.io/
@Desc : Obstacle Gauge Configuration
'''
from robogauge.tasks.gauge.base_gauge_config import BaseGaugeConfig
class ObstacleGaugeConfig(BaseGaugeConfig):
gauge_class = 'BaseGauge'
class assets(BaseGaugeConfig.assets):
terrain_name = "obstacle"
terrain_level = 10 # 1-10
terrain_xmls = [
'{ROBOGAUGE_ROOT_DIR}/resources/terrains/obstacle/obstacle_10.xml',
'{ROBOGAUGE_ROOT_DIR}/resources/terrains/wall/10x10_wall.xml',
]
terrain_spawn_pos = [0.5, 2.0, 0.0] # x y z [m], robot freejoint spawn position on the terrain
class goals(BaseGaugeConfig.goals):
class target_pos_velocity: # goal to reach a target position by velocity command
enabled = True
target_pos = [6.5, -2.0, 0.3] # x y z [m], target position in the environment, used for target position goal
lin_vel_x = 0.8 # +/- m/s
lin_vel_y = 1.0 # +/- m/s
ang_vel_yaw = 1.5 # +/- rad/s
max_cmd_duration = 30.0 # [s] maximum duration to reach the target position
reach_threshold = 0.1

View File

@@ -87,6 +87,9 @@ class TerrainSearchLevelsConfig(Config):
[1.1, 3.0, 7],
]
class obstacle:
levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
class TerrainEvalLevelsConfig(Config):
class slope:
levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

View File

@@ -21,7 +21,7 @@ class WaveGaugeConfig(BaseGaugeConfig):
]
terrain_spawn_pos = [1.5, 1.25, 0.0] # x y z [m], robot freejoint spawn position on the terrain
class goals:
class goals(BaseGaugeConfig.goals):
class target_pos_velocity: # goal to reach a target position by velocity command
enabled = True
target_pos = [6.5, -2.65, 0.8] # x y z [m], target position in the environment, used for target position goal

View File

@@ -12,6 +12,7 @@ import yaml
from robogauge.tasks.pipeline.multi_pipeline import MultiPipeline
from robogauge.utils.logger import Logger
from robogauge.utils.progress_monitor import report_progress, ProgressTypes, ProgressData
from robogauge.utils.file_utils import compress_directory
level_logger = Logger() # LevelPipeline logger
@@ -21,7 +22,11 @@ class LevelPipeline:
self.seeds = args.seeds
self.console_output = console_output
self.progress_data = progress_data
level_logger.create(args.experiment_name+'_level', args.run_name, console_output=console_output)
parent_log_dir = getattr(args, 'parent_log_dir', None)
level_logger.create(args.experiment_name+'_level', args.run_name, console_output=console_output, parent_log_dir=parent_log_dir)
self.args.parent_log_dir = str(level_logger.log_dir / "subtasks")
self.compress_logs = args.compress_logs
args.compress_logs = False # Disable child log compression
def run(self):
level_logger.info(f"🚀 Starting Level Searcher for '{self.args.experiment_name}'.")
@@ -53,6 +58,9 @@ class LevelPipeline:
level_logger.info(f"❌ No valid level found [1-10].")
with open(level_logger.log_dir / "level_search_results.yaml", 'w') as f:
yaml.dump(level_results, f, allow_unicode=True, sort_keys=False)
level_logger.logger.info(f"📂 Level search results saved to: {level_logger.log_dir / 'level_search_results.yaml'}")
if self.compress_logs:
compress_directory(level_logger.log_dir / "subtasks", delete_original=True, logger=level_logger)
return level, level_results
def test_level(self, level: int):
@@ -63,7 +71,7 @@ class LevelPipeline:
success_mean = float(aggregated_results['summary']['success']['mean'].split(' ')[0])
all_success = success_mean >= 0.8
if all_success:
level_logger.info(f"✅ Level {level} passed all tests.")
level_logger.info(f"✅ Level {level} passed all tests, success mean: {success_mean}.")
else:
level_logger.info(f"❌ Level {level} failed some tests.")
level_logger.info(f"❌ Level {level} failed some tests, success mean: {success_mean}.")
return all_success, aggregated_results

View File

@@ -24,6 +24,7 @@ from robogauge.utils.task_register import task_register
from robogauge.utils.logger import Logger
from robogauge.utils.process_utils import NoDaemonPool
from robogauge.utils.progress_monitor import report_progress, ProgressTypes, ProgressData
from robogauge.utils.file_utils import compress_directory
multi_logger = Logger() # MultiPipeline logger
@@ -38,7 +39,8 @@ def run_single_process(args, data):
logger.create(
experiment_name=local_args.experiment_name,
run_name=run_name,
console_output=False
console_output=False,
parent_log_dir=args.parent_log_dir
)
pipeline = task_register.make_pipeline(args=local_args, create_logger=False)
results, warning, error = pipeline.run()
@@ -73,7 +75,10 @@ class MultiPipeline:
self.progress_data = progress_data
self.num_processes = args.num_processes
self.static_info = {}
multi_logger.create(args.experiment_name+'_multi', args.run_name+'_multi', console_output=console_output)
parent_log_dir = getattr(args, 'parent_log_dir', None)
multi_logger.create(args.experiment_name+'_multi', args.run_name+'_multi', console_output=console_output, parent_log_dir=parent_log_dir)
self.args.parent_log_dir = str(multi_logger.log_dir / "subtasks")
self.compress_logs = args.compress_logs
def add_static_info(self, key: str, value):
if key not in self.static_info:
@@ -153,6 +158,8 @@ class MultiPipeline:
multi_logger.info("✅ Aggregated execution finished.")
multi_logger.info(f"📁 Aggregated results saved to: {save_path}")
if self.compress_logs:
compress_directory(multi_logger.log_dir / "subtasks", delete_original=True, logger=multi_logger)
# multi_logger.info(
# f"""\n{'='*20} Multi-Run Summary {'='*20}\n"""
# f"""{yaml.dump(summary, allow_unicode=True)}"""

View File

@@ -7,6 +7,12 @@
@Blog : https://wty-yy.github.io/
@Desc : Stress Pipeline for Robogauge
'''
# MuJoCo/XLA warnings suppression
import os
os.environ['ABSL_LOG_LEVEL'] = 'error'
import absl.logging
absl.logging.set_verbosity(absl.logging.ERROR)
import yaml
import traceback
import functools
@@ -22,9 +28,15 @@ from robogauge.utils.process_utils import NoDaemonPool
from robogauge.utils.progress_monitor import report_progress, ProgressTypes, start_progress_monitor_thread, ProgressData
from robogauge.tasks.pipeline import MultiPipeline, LevelPipeline
from robogauge.tasks.gauge.gauge_configs.terrain_levels_config import TerrainSearchLevelsConfig
from robogauge.utils.file_utils import compress_directory
stress_logger = Logger() # StressPipeline logger
GOALS = {
'level_pipeline': ['target_pos_velocity'],
'multi_pipeline': ['max_velocity', 'diagonal_velocity']
}
def run_pipeline(args, progress_queue, data):
args = deepcopy(args)
task_id = data['task_id']
@@ -44,6 +56,7 @@ def run_pipeline(args, progress_queue, data):
args.base_masses = [data['base_mass']]
args.task_name = f"{data['task_robot_model']}.{data['terrain_name']}"
args.experiment_name = f"{args.experiment_name}_{data['terrain_name']}_M{data['base_mass']}_F{data['friction']}"
args.goals = GOALS['level_pipeline']
level, level_results = LevelPipeline(args, console_output=False, progress_data=progress_data).run()
if level == 0: # no valid level found
@@ -63,6 +76,7 @@ def run_pipeline(args, progress_queue, data):
args.experiment_name = f"{args.experiment_name}_{data['terrain_name']}"
args.level = level
args.goals = GOALS['multi_pipeline']
results = {
'success': True,
'results': MultiPipeline(args, console_output=False, progress_data=progress_data).run(),
@@ -81,6 +95,9 @@ class StressPipeline:
args.experiment_name = self.task_robot_model + '_stress' + ('' if args.cli_experiment_name is None else '_' + args.cli_experiment_name)
self.static_info = {}
stress_logger.create(args.experiment_name, args.run_name)
self.args.parent_log_dir = str(stress_logger.log_dir / "subtasks")
self.compress_logs = args.compress_logs
args.compress_logs = False # Disable child log compression
def add_static_info(self, key: str, value):
if key not in self.static_info:
@@ -183,7 +200,9 @@ class StressPipeline:
for metric, means in result['results']['summary'].items():
for mean_name, mean_value in means.items():
value_collections[metric][mean_name].append(float(mean_value.split(' ')[0]))
value = float(mean_value.split(' ')[0])
value += (terrain_level - 1) * 0.1 if terrain_level is not None else 0.0
value_collections[metric][mean_name].append(value)
for metric, means in value_collections.items():
summary['summary'][metric] = {}
@@ -196,4 +215,7 @@ class StressPipeline:
yaml.dump(summary, file, allow_unicode=True, sort_keys=False)
stress_logger.info(f"✅ Stress benchmark aggregated execution finished.")
stress_logger.info(f"📁 Stress benchmark results saved to: {save_path}")
if self.compress_logs:
compress_directory(stress_logger.log_dir / "subtasks", delete_original=True, logger=stress_logger)
return summary