Skip to content

Commit b9fefdc

Browse files
committed
fix: restore rotation_q_wxyz helper usage
1 parent 9536298 commit b9fefdc

4 files changed

Lines changed: 4 additions & 6 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ stubgen:
3333
find ./python/rcs/_core -name '*.pyi' -print | xargs sed -i 's/tuple\[typing\.Literal\[\([0-9]\+\)\], typing\.Literal\[1\]\]/tuple\[typing\.Literal[\1]\]/g'
3434
find ./python/rcs/_core -name '*.pyi' -print | xargs sed -i 's/tuple\[\([M|N]\), typing\.Literal\[1\]\]/tuple\[\1\]/g'
3535
sed -i 's/ q_home: numpy\.ndarray\[tuple\[M\], numpy\.dtype\[numpy\.float64\]\] | None/ q_home: numpy.ndarray | None/' python/rcs/_core/common.pyi
36-
python -c "from pathlib import Path; p=Path('python/rcs/_core/common.pyi'); lines=p.read_text().splitlines(); lines=[line for line in lines if 'def rotation_q_wxyz(' not in line]; t='\n'.join(lines)+'\n'; t=t.replace('numpy.ndarray[tuple[typing.Literal[2], N], numpy.dtype[numpy.float64]]', 'numpy.ndarray[tuple[typing.Literal[2], typing.Any], numpy.dtype[numpy.float64]]'); p.write_text(t)"
36+
python -c "from pathlib import Path; p=Path('python/rcs/_core/common.pyi'); t=p.read_text(); t=t.replace('numpy.ndarray[tuple[typing.Literal[2], N], numpy.dtype[numpy.float64]]', 'numpy.ndarray[tuple[typing.Literal[2], typing.Any], numpy.dtype[numpy.float64]]'); p.write_text(t)"
3737
python -c "from pathlib import Path; p=Path('python/rcs/_core/sim.pyi'); t=p.read_text(); t=t.replace('numpy.ndarray[tuple[typing.Literal[2], N], numpy.dtype[numpy.float64]]', 'numpy.ndarray[tuple[typing.Literal[2], typing.Any], numpy.dtype[numpy.float64]]'); t=t.replace(', max_buffer_frames: int = 100', ''); p.write_text(t)"
3838
python scripts/generate_common_typing.py
3939
ruff check --fix python/rcs/_core python/rcs/common_typing.py

python/rcs/_core/common.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class Pose:
197197
def pose_matrix(self) -> numpy.ndarray[tuple[typing.Literal[4], typing.Literal[4]], numpy.dtype[numpy.float64]]: ...
198198
def rotation_m(self) -> numpy.ndarray[tuple[typing.Literal[3], typing.Literal[3]], numpy.dtype[numpy.float64]]: ...
199199
def rotation_q(self) -> numpy.ndarray[tuple[typing.Literal[4]], numpy.dtype[numpy.float64]]: ...
200+
def rotation_q_wxyz(self) -> numpy.ndarray[tuple[typing.Literal[4]], numpy.dtype[numpy.float64]]: ...
200201
def rotation_rpy(self) -> RPY: ...
201202
def rotvec(self) -> numpy.ndarray[tuple[typing.Literal[6]], numpy.dtype[numpy.float64]]: ...
202203
def total_angle(self) -> float: ...

python/rcs/envs/tasks.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,8 @@ def reset(
132132
pose_in_world_frame = self.center2world * pose_in_center_frame
133133

134134
# qpos array format for a free joint: [x, y, z, qw, qx, qy, qz]
135-
quat_xyzw = pose_in_world_frame.rotation_q()
136-
quat_wxyz = np.array([quat_xyzw[3], quat_xyzw[0], quat_xyzw[1], quat_xyzw[2]])
137135
self.get_wrapper_attr("sim").data.joint(self.obj_joint_name).qpos = np.append(
138-
pose_in_world_frame.translation(), quat_wxyz
136+
pose_in_world_frame.translation(), pose_in_world_frame.rotation_q_wxyz()
139137
)
140138

141139
# reset of remaining stack, must happen after our reset!

python/rcs/sim/composer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ def _find_camera(self, name: str) -> Optional[mujoco._specs.MjsCamera]:
6565

6666
def _apply_pose(self, body: mujoco._specs.MjsBody, pose: Pose):
6767
body.pos = list(pose.translation())
68-
quat_xyzw = pose.rotation_q()
69-
body.quat = [quat_xyzw[3], quat_xyzw[0], quat_xyzw[1], quat_xyzw[2]]
68+
body.quat = list(pose.rotation_q_wxyz())
7069

7170
def add_camera(
7271
self,

0 commit comments

Comments
 (0)