@@ -27,7 +27,7 @@ def euler_from_quaternion(quat_angle):
2727 pitch is rotation around y in radians (counterclockwise)
2828 yaw is rotation around z in radians (counterclockwise)
2929 """
30- x , y , z , w = quat_angle
30+ w , x , y , z = quat_angle
3131 t0 = + 2.0 * (w * x + y * z )
3232 t1 = + 1.0 - 2.0 * (x * x + y * y )
3333 roll_x = np .arctan2 (t0 , t1 )
@@ -114,7 +114,6 @@ def init_onnx(self):
114114 self .joint_vel_policy = np .zeros (12 )
115115
116116 self .q0 = np .array ([- 0.1 , 0.8 , - 1.5 , 0.1 , 0.8 , - 1.5 , - 0.1 , 1. , - 1.5 , 0.1 , 1. , - 1.5 ])
117- self .q_des = self .q0 .copy ()
118117
119118 # First two elements are 0, third is the forward speed
120119 forward_speed = 0.37
@@ -152,30 +151,20 @@ def forward(self, camera: bool = False):
152151 self .update_yaw [:] = 0.0
153152 self .update_depth [:] = 0.0
154153
155- w_P_b , w_Q_b = pb .getBasePositionAndOrientation (robot_id )
156-
157- w_P_b = np .array (w_P_b , dtype = np .float32 )
158- w_R_b = np .array (pb .getMatrixFromQuaternion (w_Q_b ), dtype = np .float32 ).reshape (
159- 3 , 3
160- )
161-
162- self .w_T_b [:3 , :3 ] = w_R_b
163- self .w_T_b [:3 , 3 ] = w_P_b
164-
165- _ , ang_vel_w = pb .getBaseVelocity (robot_id )
166- ang_vel_b = w_R_b .T @ np .array (ang_vel_w )
167154 contact_states = self .low_msg .foot_force > 20
168155
169- roll , pitch , yaw = euler_from_quaternion (w_Q_b )
156+ quat = self .low_msg .imu_state .quaternion
157+ roll , pitch , yaw = euler_from_quaternion (quat )
170158 imu_obs = np .array ([roll , pitch ])
171159
172- q = np .array ([ms .q for ms in self .low_msg .motor_state ])[:12 ] - self .q0
160+ q = np .array ([ms .q for ms in self .low_msg .motor_state ])[:12 ]
161+ q -= self .q0
173162
174163 self .joint_vel [:] = (q - self .joint_pos ) * 50.
175164 self .joint_pos [:] = q
176165
177166 obs_data = [
178- 1 * ang_vel_b * 0.25 , # 3
167+ 1 * self . low_msg . imu_state . gyroscope * 0.25 , # 3
179168 1 * imu_obs , # 2
180169 [0.0 ],
181170 1 * self .yaws .squeeze (),
0 commit comments