Load and process the YAML configuration file
(config_path)
| 9 | from legged_gym import LEGGED_GYM_ROOT_DIR |
| 10 | |
| 11 | def load_config(config_path): |
| 12 | """Load and process the YAML configuration file""" |
| 13 | with open(config_path, 'r') as f: |
| 14 | config = yaml.safe_load(f) |
| 15 | |
| 16 | # Process paths with LEGGED_GYM_ROOT_DIR |
| 17 | for path_key in ['policy_path', 'xml_path']: |
| 18 | config[path_key] = config[path_key].format(LEGGED_GYM_ROOT_DIR=LEGGED_GYM_ROOT_DIR) |
| 19 | |
| 20 | # Convert lists to numpy arrays where needed |
| 21 | array_keys = ['kps', 'kds', 'default_angles', 'cmd_scale', 'cmd_init'] |
| 22 | for key in array_keys: |
| 23 | config[key] = np.array(config[key], dtype=np.float32) |
| 24 | |
| 25 | return config |
| 26 | |
| 27 | def pd_control(target_q, q, kp, target_dq, dq, kd): |
| 28 | """Calculates torques from position commands""" |