Skip to content

Commit

Permalink
Tidy up.
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxenburg committed Feb 28, 2025
1 parent ff5456a commit 01d5a11
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions flybody/tasks/task_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ def observable_indices_in_tensor(
def wing_qpos_to_conventional(model_wing_qpos: np.ndarray,
body_pitch_angle: float = 47.5,
) -> np.ndarray:
"""Transform model wing qpos to conventional wing kinematics definition.
"""Transform model wing joint qpos to conventional wing kinematics definition.
Args:
model_wing_qpos: Wing MjData.qpos in radians, shape (B, 6).
Order of angles: yaw_left, roll_left, pitch_left,
yaw_right, roll_right, pitch_right.
Order of joints: yaw, roll, pitch, yaw, roll, pitch.
Left-right order is arbitrary.
body_pitch_angle: Body pitch angle for initial flight pose, relative to
ground, degrees. 0: horizontal body position. Default value from
https://doi.org/10.1126/science.1248955
Expand All @@ -45,14 +45,13 @@ def wing_qpos_to_conventional(model_wing_qpos: np.ndarray,
model_wing_qpos = np.array(model_wing_qpos)
conventional = np.zeros_like(model_wing_qpos)
body_pitch_angle = np.deg2rad(body_pitch_angle)
for i in [0, 3]:
# Yaw, doesn't require transformation.
conventional[..., i] = model_wing_qpos[..., i].copy()
# Roll.
conventional[..., i+1] = - model_wing_qpos[..., i+1]
# Pitch.
conventional[..., i+2] = (np.pi / 2 - body_pitch_angle -
model_wing_qpos[..., i+2])
# Yaw, doesn't require transformation.
conventional[..., [0, 3]] = model_wing_qpos[..., [0, 3]].copy()
# Roll.
conventional[..., [1, 4]] = - model_wing_qpos[..., [1, 4]]
# Pitch.
conventional[..., [2, 5]] = (
np.pi / 2 - body_pitch_angle - model_wing_qpos[..., [2, 5]])
return conventional


Expand Down

0 comments on commit 01d5a11

Please sign in to comment.