Configuration loader for Unitree G1 deployment.
| 5 | |
| 6 | |
| 7 | class G1Config: |
| 8 | """Configuration loader for Unitree G1 deployment.""" |
| 9 | |
| 10 | def __init__(self, file_path) -> None: |
| 11 | with open(file_path) as f: |
| 12 | config = yaml.load(f, Loader=yaml.FullLoader) |
| 13 | |
| 14 | self.control_dt = config["control_dt"] |
| 15 | |
| 16 | self.msg_type = config["msg_type"] |
| 17 | self.imu_type = config["imu_type"] |
| 18 | |
| 19 | self.weak_motor = [] |
| 20 | if "weak_motor" in config: |
| 21 | self.weak_motor = config["weak_motor"] |
| 22 | |
| 23 | self.lowcmd_topic = config["lowcmd_topic"] |
| 24 | self.lowstate_topic = config["lowstate_topic"] |
| 25 | |
| 26 | self.policy_path = config["policy_path"] |
| 27 | |
| 28 | self.kps = np.array(config["kps"]) |
| 29 | self.kds = np.array(config["kds"]) |
| 30 | self.default_angles = np.array(config["default_angles"], dtype=np.float32) |
| 31 | |
| 32 | self.ang_vel_scale = config["ang_vel_scale"] |
| 33 | self.dof_pos_scale = config["dof_pos_scale"] |
| 34 | self.dof_vel_scale = config["dof_vel_scale"] |
| 35 | self.action_scale = config["action_scale"] |
| 36 | self.cmd_scale = np.array(config["cmd_scale"], dtype=np.float32) |
| 37 | self.max_cmd = np.array(config["max_cmd"], dtype=np.float32) |
| 38 | self.obs_len_history = config["obs_len_history"] |
| 39 | |
| 40 | self.num_actions = config["num_actions"] |
| 41 | self.num_obs = config["num_obs"] |
| 42 | |
| 43 | self.enable_actions_reindex = config["enable_actions_reindex"] |
| 44 | |
| 45 | # the default joint order of g1 robot |
| 46 | self.default_body_joint_names = [ |
| 47 | "left_hip_pitch_joint", |
| 48 | "left_hip_roll_joint", |
| 49 | "left_hip_yaw_joint", |
| 50 | "left_knee_joint", |
| 51 | "left_ankle_pitch_joint", |
| 52 | "left_ankle_roll_joint", |
| 53 | "right_hip_pitch_joint", |
| 54 | "right_hip_roll_joint", |
| 55 | "right_hip_yaw_joint", |
| 56 | "right_knee_joint", |
| 57 | "right_ankle_pitch_joint", |
| 58 | "right_ankle_roll_joint", |
| 59 | "waist_yaw_joint", |
| 60 | "waist_roll_joint", |
| 61 | "waist_pitch_joint", |
| 62 | "left_shoulder_pitch_joint", |
| 63 | "left_shoulder_roll_joint", |
| 64 | "left_shoulder_yaw_joint", |