v0.1.15; add stairs_up/down

This commit is contained in:
wty-yy
2025-12-25 18:15:48 +08:00
parent 0dd3c10aba
commit 9d9d83ed9f
54 changed files with 1356 additions and 81 deletions

View File

@@ -53,7 +53,7 @@ class BasePipeline:
def load(self):
self.sim.load(
self.gauge_cfg.assets.terrain_xml,
self.gauge_cfg.assets.terrain_xmls,
self.robot_cfg.assets.robot_xml,
self.gauge_cfg.assets.terrain_spawn_pos,
self.robot_cfg.control.default_dof_pos
@@ -68,7 +68,7 @@ class BasePipeline:
"Control dt must be multiple of simulation dt."
logger.info(f"Sim FPS: {1.0 / self.sim_cfg.physics.simulation_dt:.2f}, Control FPS: {1.0 / self.robot_cfg.control.control_dt:.2f}, Frame Skip: {frame_skip:d}")
logger.info("Running pipeline...")
error = None
warning, error = None, None
while not self.gauge.is_done():
try:
if self.first_reset: # wait for robot to be still
@@ -77,7 +77,10 @@ class BasePipeline:
velocity_goal=VelocityGoal(), # zero velocity
position_goal=PositionGoal(), # current position
)
if np.linalg.norm(sim_data.proprio.base.lin_vel) < 0.05 and sim_data.sim_time - self.last_reset_time > 0.1:
if (
(np.linalg.norm(sim_data.proprio.base.lin_vel) < 0.05 and sim_data.sim_time - self.last_reset_time > 0.1) or # robot is still
(sim_data.sim_time - self.last_reset_time) > 3.0 # wait max 3s
):
self.first_reset = False
else:
goal_data = self.gauge.get_goal(sim_data)
@@ -106,18 +109,24 @@ class BasePipeline:
if self.gauge.is_reset(sim_data):
sim_data = self.reset_sim_and_robot(sim_data)
except Exception as e:
error = e
logger.error(f"❌ Goal '{self.gauge.goal_str}' failed with error: {e},\n{traceback.format_exc()}")
self.gauge.switch_to_next_goal() # save current goal metrics
if str(e).startswith("[Penetration Error]"):
warning = e
logger.warning(f"⚠️ Penetration detected! Reset current goal and continue..., error: {e}")
self.gauge.reset_current_goal()
logger.info("⏩ Pipeline recovered from penetration and continued current goal 🎯.")
else:
error = e
logger.error(f"❌ Goal '{self.gauge.goal_str}' failed with error: {e},\n{traceback.format_exc()}")
self.gauge.switch_to_next_goal() # skip to next goal
logger.info("⏩ Pipeline recovered from error and continued next goal 🎯.")
sim_data = self.reset_sim_and_robot(sim_data)
logger.info("⏩ Pipeline recovered from error and continued next goal 🎯.")
self.sim.close_viewer()
self.sim.close_video_writer()
logger.info("✅ Pipeline execution finished.")
logger.info(f"📁 Logging saved at: {logger.log_dir}")
return self.gauge.results, error
return self.gauge.results, warning, error
def reset_sim_and_robot(self, sim_data: SimData):
self.sim.reset()

View File

@@ -46,17 +46,16 @@ class LevelPipeline:
with open(logger.log_dir / "level_search_results.yaml", 'w') as f:
yaml.dump(level_results, f, allow_unicode=True, sort_keys=False)
return level, level_results
def test_level(self, level: int) -> bool:
logger.info(f"🔍 Testing level {level}...")
self.args.level = level
multi_pipeline = MultiPipeline(self.args)
aggregated_results = multi_pipeline.run()
success_mean = float(aggregated_results['success']['mean'].split(' ')[0])
all_success = success_mean == 1.0
all_success = success_mean >= 0.8
if all_success:
logger.info(f"✅ Level {level} passed all tests.")
else:
logger.info(f"❌ Level {level} failed some tests.")
return all_success, aggregated_results
return all_success, aggregated_results

View File

@@ -36,13 +36,15 @@ def run_single_process(args, data):
console_output=False
)
pipeline = task_register.make_pipeline(args=local_args, create_logger=False)
results, error = pipeline.run()
results, warning, error = pipeline.run()
if error is None:
ret = {
'status': 'success',
'results': results,
'model_path': pipeline.robot_cfg.control.model_path,
}
if warning is not None:
logger.warning(f"⚠️ Process with seed={seed}, base_mass={base_mass}, friction={friction} completed with warning: {warning}")
else:
logger.error(f"❌ Process with seed={seed}, base_mass={base_mass}, friction={friction} failed with error: {error}")
ret = {