Unitree H1
- class UnitreeH1(disable_arms=True, disable_back_joint=False, hold_weight=False, weight_mass=None, **kwargs)[source]
Bases:
BaseRobotHumanoidDescription
Mujoco simulation of the Unitree H1 robot. Optionally, the H1 can carry a weight. This environment can be partially observable by hiding some of the state space entries from the policy using a state mask. Hidable entries are “positions”, “velocities”, “foot_forces”, or “weight”.
Tasks
Walking: The robot has to walk forward with a fixed speed of 1.25 m/s.
Running: Run forward with a fixed speed of 2.5 m/s.
Carry: The robot has to walk forward with a fixed speed of 1.25 m/s while carrying a weight. The mass is either specified by the user or sampled from a uniformly from [0.1 kg, 1 kg, 5 kg, 10 kg].
Dataset Types
The available dataset types for this environment can be found at: Overview of Environments, Tasks and Datasets.
Observation Space
The observation space has the following properties by default (i.e., only obs with Disabled == False):
For walking task:(min=-inf, max=inf, dim=32, dtype=float32)For running task:(min=-inf, max=inf, dim=32, dtype=float32)For carry task:(min=-inf, max=inf, dim=33, dtype=float32)Some observations are disabled by default, but can be turned on. The detailed observation space is:
Index
Description
Min
Max
Disabled
Dim
Units
0
Position of Joint pelvis_ty
-inf
inf
False
1
Position [m]
1
Position of Joint pelvis_tilt
-inf
inf
False
1
Angle [rad]
2
Position of Joint pelvis_list
-inf
inf
False
1
Angle [rad]
3
Position of Joint pelvis_rotation
-inf
inf
False
1
Angle [rad]
4
Position of Joint back_bkz
-2.35
2.35
False
1
Angle [rad]
5
Position of Joint l_arm_shy
-2.87
2.87
True
1
Angle [rad]
6
Position of Joint l_arm_shx
-0.34
3.11
True
1
Angle [rad]
7
Position of Joint l_arm_shz
-1.3
4.45
True
1
Angle [rad]
8
Position of Joint left_elbow
-1.25
2.61
True
1
Angle [rad]
9
Position of Joint r_arm_shy
-2.87
2.87
True
1
Angle [rad]
10
Position of Joint r_arm_shx
-3.11
0.34
True
1
Angle [rad]
11
Position of Joint r_arm_shz
-4.45
1.3
True
1
Angle [rad]
12
Position of Joint right_elbow
-1.25
2.61
True
1
Angle [rad]
13
Position of Joint hip_flexion_r
-1.57
1.57
False
1
Angle [rad]
14
Position of Joint hip_adduction_r
-0.43
0.43
False
1
Angle [rad]
15
Position of Joint hip_rotation_r
-0.43
0.43
False
1
Angle [rad]
16
Position of Joint knee_angle_r
-0.26
2.05
False
1
Angle [rad]
17
Position of Joint ankle_angle_r
-0.87
0.52
False
1
Angle [rad]
18
Position of Joint hip_flexion_l
-1.57
1.57
False
1
Angle [rad]
19
Position of Joint hip_adduction_l
-0.43
0.43
False
1
Angle [rad]
20
Position of Joint hip_rotation_l
-0.43
0.43
False
1
Angle [rad]
21
Position of Joint knee_angle_l
-0.26
2.05
False
1
Angle [rad]
22
Position of Joint ankle_angle_l
-0.87
0.52
False
1
Angle [rad]
23
Velocity of Joint pelvis_tx
-inf
inf
False
1
Velocity [m/s]
24
Velocity of Joint pelvis_tz
-inf
inf
False
1
Velocity [m/s]
25
Velocity of Joint pelvis_ty
-inf
inf
False
1
Velocity [m/s]
26
Velocity of Joint pelvis_tilt
-inf
inf
False
1
Angular Velocity [rad/s]
27
Velocity of Joint pelvis_list
-inf
inf
False
1
Angular Velocity [rad/s]
28
Velocity of Joint pelvis_rotation
-inf
inf
False
1
Angular Velocity [rad/s]
29
Velocity of Joint back_bkz
-inf
inf
False
1
Angular Velocity [rad/s]
30
Velocity of Joint l_arm_shy
-inf
inf
True
1
Angular Velocity [rad/s]
31
Velocity of Joint l_arm_shx
-inf
inf
True
1
Angular Velocity [rad/s]
32
Velocity of Joint l_arm_shz
-inf
inf
True
1
Angular Velocity [rad/s]
33
Velocity of Joint left_elbow
-inf
inf
True
1
Angular Velocity [rad/s]
34
Velocity of Joint r_arm_shy
-inf
inf
True
1
Angular Velocity [rad/s]
35
Velocity of Joint r_arm_shx
-inf
inf
True
1
Angular Velocity [rad/s]
36
Velocity of Joint r_arm_shz
-inf
inf
True
1
Angular Velocity [rad/s]
37
Velocity of Joint right_elbow
-inf
inf
True
1
Angular Velocity [rad/s]
38
Velocity of Joint hip_flexion_r
-inf
inf
False
1
Angular Velocity [rad/s]
39
Velocity of Joint hip_adduction_r
-inf
inf
False
1
Angular Velocity [rad/s]
40
Velocity of Joint hip_rotation_r
-inf
inf
False
1
Angular Velocity [rad/s]
41
Velocity of Joint knee_angle_r
-inf
inf
False
1
Angular Velocity [rad/s]
42
Velocity of Joint ankle_angle_r
-inf
inf
False
1
Angular Velocity [rad/s]
43
Velocity of Joint hip_flexion_l
-inf
inf
False
1
Angular Velocity [rad/s]
44
Velocity of Joint hip_adduction_l
-inf
inf
False
1
Angular Velocity [rad/s]
45
Velocity of Joint hip_rotation_l
-inf
inf
False
1
Angular Velocity [rad/s]
46
Velocity of Joint knee_angle_l
-inf
inf
False
1
Angular Velocity [rad/s]
47
Velocity of Joint ankle_angle_l
-inf
inf
False
1
Angular Velocity [rad/s]
48
Mass of the Weight
0.0
inf
Only Enabled for Carry Task
1
Mass [kg]
49
3D linear Forces between Right Foot and Floor
0.0
inf
True
3
Force [N]
52
3D linear Forces between Left Foot and Floor
0.0
inf
True
3
Force [N]
Action Space
The action space has the following properties by default (i.e., only actions with Disabled == False):(min=-1, max=1, dim=11, dtype=float32)Some actions are disabled by default, but can be turned on. The detailed action space is:
Index
Name in XML
Control Min
Control Max
Disabled
0
back_bkz_actuator
-1.0
1.0
False
1
l_arm_shy_actuator
-1.0
1.0
True
2
l_arm_shx_actuator
-1.0
1.0
True
3
l_arm_shz_actuator
-1.0
1.0
True
4
left_elbow_actuator
-1.0
1.0
True
5
r_arm_shy_actuator
-1.0
1.0
True
6
r_arm_shx_actuator
-1.0
1.0
True
7
r_arm_shz_actuator
-1.0
1.0
True
8
right_elbow_actuator
-1.0
1.0
True
9
hip_flexion_r_actuator
-1.0
1.0
False
10
hip_adduction_r_actuator
-1.0
1.0
False
11
hip_rotation_r_actuator
-1.0
1.0
False
12
knee_angle_r_actuator
-1.0
1.0
False
13
ankle_angle_r_actuator
-1.0
1.0
False
14
hip_flexion_l_actuator
-1.0
1.0
False
15
hip_adduction_l_actuator
-1.0
1.0
False
16
hip_rotation_l_actuator
-1.0
1.0
False
17
knee_angle_l_actuator
-1.0
1.0
False
18
ankle_angle_l_actuator
-1.0
1.0
False
Rewards
The default reward function is based on the distance between the current center of mass velocity and the desired velocity in the x-axis. The desired velocity is given by the dataset to imitate.
Initial States
The initial state is sampled by default from the dataset to imitate.
Terminal States
The terminal state is reached when the robot falls, or rather starts falling. The condition to check if the robot is falling is based on the orientation of the robot, the height of the center of mass, and the orientation of the back joint. More details can be found in the
_has_fallenmethod of the environment.Methods
- static _add_weight(xml_handle, mass, color)[source]
Adds a weight to the Mujoco XML handle. The weight will be hold in front of Unitree H1. Therefore, the arms will be reoriented.
- Args:
xml_handle: Handle to Mujoco XML.
- Returns:
Modified Mujoco XML handle.
- static _get_action_specification()[source]
Getter for the action space specification.
- Returns:
A list of tuples containing the specification of each action space entry.
- _get_ground_forces()[source]
Returns the ground forces (np.array). By default, 4 ground force sensors are used. Environments that use more or less have to override this function.
- static _get_observation_specification()[source]
Getter for the observation space specification.
- Returns:
A list of tuples containing the specification of each observation space entry.
- _get_xml_modifications()[source]
Function that specifies which joints, motors and equality constraints should be removed from the Mujoco xml.
- Returns:
- A tuple of lists consisting of names of joints to remove, names of motors to remove,
and names of equality constraints to remove.
- _has_fallen(obs, return_err_msg=False)[source]
Checks if a model has fallen.
- Args:
obs (np.array): Current observation. return_err_msg (bool): If True, an error message with violations is returned.
- Returns:
True, if the model has fallen for the current observation, False otherwise. Optionally an error message is returned.
- static _reorient_arms(xml_handle)[source]
Reorients the elbow to not collide with the hip.
- Args:
xml_handle: Handle to Mujoco XML.
- Returns:
Modified Mujoco XML handle.
- static generate(task='walk', dataset_type='real', **kwargs)[source]
Returns an environment corresponding to the specified task.
Args: task (str): Main task to solve. Either “walk”, “run” or “carry”. The latter is walking while carrying an unknown weight, which makes the task partially observable. dataset_type (str): “real” or “perfect”. “real” uses real motion capture data as the reference trajectory. This data does not perfectly match the kinematics and dynamics of this environment, hence it is more challenging. “perfect” uses a perfect dataset.
- valid_task_confs = <loco_mujoco.environments.base.ValidTaskConf object>