From b846174a3726e70f122e2527803bcfd157d63980 Mon Sep 17 00:00:00 2001 From: vege <15700729572@163.com> Date: Thu, 11 Sep 2025 20:42:02 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=A7=A3=E5=86=B3run=5Fppo=5Fgs.py?= =?UTF-8?q?=E7=9A=84keyError=E9=97=AE=E9=A2=98=EF=BC=8C=E5=AE=8C=E5=96=84t?= =?UTF-8?q?eleop=5Fwrapper.py=E7=9A=84=E6=9C=AB=E7=AB=AF=E6=97=8B=E8=BD=AC?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/run_ppo_gs.py | 2 +- src/agent/gs_agent/wrappers/teleop_wrapper.py | 26 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/examples/run_ppo_gs.py b/examples/run_ppo_gs.py index 07ddb295..28edde89 100644 --- a/examples/run_ppo_gs.py +++ b/examples/run_ppo_gs.py @@ -75,7 +75,7 @@ def main(num_envs: int = 2048, show_viewer: bool = False, train: bool = True) -> print("Training completed successfully!") print(f"Training completed in {train_summary_info['total_time']:.2f} seconds.") - print(f"Total episodes: {train_summary_info['total_episodes']}.") + print(f"Total iterations: {train_summary_info['total_iterations']}.") print(f"Total steps: {train_summary_info['total_steps']}.") print(f"Total reward: {train_summary_info['final_reward']:.2f}.") else: diff --git a/src/agent/gs_agent/wrappers/teleop_wrapper.py b/src/agent/gs_agent/wrappers/teleop_wrapper.py index f3f18260..86fc94cd 100644 --- a/src/agent/gs_agent/wrappers/teleop_wrapper.py +++ b/src/agent/gs_agent/wrappers/teleop_wrapper.py @@ -7,6 +7,7 @@ import numpy as np import torch from pynput import keyboard +from scipy.spatial.transform import Rotation as R from gs_agent.bases.env_wrapper import BaseEnvWrapper @@ -154,8 +155,8 @@ def start(self) -> None: print("→ - Move Right (East)") print("n - Move Up") print("m - Move Down") - print("j - Rotate Counterclockwise") - print("k - Rotate Clockwise") + print("j - Rotate around Z-axis (Left)") + print("k - Rotate around Z-axis (Right)") print("u - Reset Scene") print("space - Press to close gripper, release to open gripper") print("r - Start/Stop Recording Trajectory") @@ -255,6 +256,7 @@ def _process_input(self) -> KeyboardCommand: # get ee target pose is_close_gripper = False dpos = 0.005 + drot = 0.01 for key in pressed_keys: if key == keyboard.Key.up: self.target_position[0, 0] -= dpos @@ -269,9 +271,25 @@ def _process_input(self) -> KeyboardCommand: elif key == keyboard.KeyCode.from_char("m"): self.target_position[0, 2] -= dpos elif key == keyboard.KeyCode.from_char("j"): - raise NotImplementedError("Rotation not implemented") + # 围绕Z轴逆时针旋转(向左) + # 保持末端垂直向下,只改变围绕Z轴的旋转 + current_rotation = R.from_quat(self.target_orientation[0, :].cpu().numpy()) + # 获取当前Z轴旋转角度 + current_euler = current_rotation.as_euler("xyz", degrees=False) + # 只修改Z轴旋转角度 + new_euler = [current_euler[0] + drot, current_euler[1], current_euler[2]] + new_rotation = R.from_euler("xyz", new_euler) + self.target_orientation[0, :] = torch.from_numpy(new_rotation.as_quat()).to(self.target_orientation.device) elif key == keyboard.KeyCode.from_char("k"): - raise NotImplementedError("Rotation not implemented") + # 围绕x轴顺时针旋转(向右) + # 保持末端垂直向下,只改变围绕x轴的旋转 + current_rotation = R.from_quat(self.target_orientation[0, :].cpu().numpy()) + # 获取当前x轴旋转角度 + current_euler = current_rotation.as_euler("xyz", degrees=False) + # 只修改x轴旋转角度 + new_euler = [current_euler[0] - drot, current_euler[1], current_euler[2]] + new_rotation = R.from_euler("xyz", new_euler) + self.target_orientation[0, :] = torch.from_numpy(new_rotation.as_quat()).to(self.target_orientation.device) elif key == keyboard.Key.space: is_close_gripper = True From af9fcbabfa8367679f1dafd2b1814fbccb2866d3 Mon Sep 17 00:00:00 2001 From: vege <15700729572@163.com> Date: Thu, 11 Sep 2025 21:06:52 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=8B=E6=9C=AB?= =?UTF-8?q?=E7=AB=AF=E6=97=8B=E8=BD=AC=E5=8A=9F=E8=83=BD=E7=9A=84=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/agent/gs_agent/wrappers/teleop_wrapper.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/agent/gs_agent/wrappers/teleop_wrapper.py b/src/agent/gs_agent/wrappers/teleop_wrapper.py index 86fc94cd..2edded69 100644 --- a/src/agent/gs_agent/wrappers/teleop_wrapper.py +++ b/src/agent/gs_agent/wrappers/teleop_wrapper.py @@ -155,8 +155,8 @@ def start(self) -> None: print("→ - Move Right (East)") print("n - Move Up") print("m - Move Down") - print("j - Rotate around Z-axis (Left)") - print("k - Rotate around Z-axis (Right)") + print("j - Rotate Counterclockwise") + print("k - Rotate Clockwise") print("u - Reset Scene") print("space - Press to close gripper, release to open gripper") print("r - Start/Stop Recording Trajectory") @@ -271,12 +271,12 @@ def _process_input(self) -> KeyboardCommand: elif key == keyboard.KeyCode.from_char("m"): self.target_position[0, 2] -= dpos elif key == keyboard.KeyCode.from_char("j"): - # 围绕Z轴逆时针旋转(向左) - # 保持末端垂直向下,只改变围绕Z轴的旋转 + # 围绕x轴逆时针旋转(向左) + # 保持末端垂直向下,只改变围绕x轴的旋转 current_rotation = R.from_quat(self.target_orientation[0, :].cpu().numpy()) - # 获取当前Z轴旋转角度 + # 获取当前x轴旋转角度 current_euler = current_rotation.as_euler("xyz", degrees=False) - # 只修改Z轴旋转角度 + # 只修改x轴旋转角度 new_euler = [current_euler[0] + drot, current_euler[1], current_euler[2]] new_rotation = R.from_euler("xyz", new_euler) self.target_orientation[0, :] = torch.from_numpy(new_rotation.as_quat()).to(self.target_orientation.device) From 343a5f6946858ec2ea1acc09dcd79004cc46c531 Mon Sep 17 00:00:00 2001 From: vege <15700729572@163.com> Date: Fri, 12 Sep 2025 21:18:33 +0800 Subject: [PATCH 3/4] convert Chinese annotations to English annotations --- src/agent/gs_agent/wrappers/teleop_wrapper.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/agent/gs_agent/wrappers/teleop_wrapper.py b/src/agent/gs_agent/wrappers/teleop_wrapper.py index 2edded69..e725a5db 100644 --- a/src/agent/gs_agent/wrappers/teleop_wrapper.py +++ b/src/agent/gs_agent/wrappers/teleop_wrapper.py @@ -271,22 +271,20 @@ def _process_input(self) -> KeyboardCommand: elif key == keyboard.KeyCode.from_char("m"): self.target_position[0, 2] -= dpos elif key == keyboard.KeyCode.from_char("j"): - # 围绕x轴逆时针旋转(向左) - # 保持末端垂直向下,只改变围绕x轴的旋转 + # keep the end effector vertical down, only change the rotation around the x axis current_rotation = R.from_quat(self.target_orientation[0, :].cpu().numpy()) - # 获取当前x轴旋转角度 + # get the current x axis rotation angle current_euler = current_rotation.as_euler("xyz", degrees=False) - # 只修改x轴旋转角度 + # only change the x axis rotation angle new_euler = [current_euler[0] + drot, current_euler[1], current_euler[2]] new_rotation = R.from_euler("xyz", new_euler) self.target_orientation[0, :] = torch.from_numpy(new_rotation.as_quat()).to(self.target_orientation.device) elif key == keyboard.KeyCode.from_char("k"): - # 围绕x轴顺时针旋转(向右) - # 保持末端垂直向下,只改变围绕x轴的旋转 + # keep the end effector vertical down, only change the rotation around the x axis current_rotation = R.from_quat(self.target_orientation[0, :].cpu().numpy()) - # 获取当前x轴旋转角度 + # get the current x axis rotation angle current_euler = current_rotation.as_euler("xyz", degrees=False) - # 只修改x轴旋转角度 + # only change the x axis rotation angle new_euler = [current_euler[0] - drot, current_euler[1], current_euler[2]] new_rotation = R.from_euler("xyz", new_euler) self.target_orientation[0, :] = torch.from_numpy(new_rotation.as_quat()).to(self.target_orientation.device) From 02c75d51ab9b8bc97f3f928ba449312488b23e5d Mon Sep 17 00:00:00 2001 From: vege <15700729572@163.com> Date: Sat, 13 Sep 2025 21:12:01 +0800 Subject: [PATCH 4/4] Apply ruff auto-format --- src/agent/gs_agent/wrappers/teleop_wrapper.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/agent/gs_agent/wrappers/teleop_wrapper.py b/src/agent/gs_agent/wrappers/teleop_wrapper.py index e725a5db..4e7c2555 100644 --- a/src/agent/gs_agent/wrappers/teleop_wrapper.py +++ b/src/agent/gs_agent/wrappers/teleop_wrapper.py @@ -278,7 +278,9 @@ def _process_input(self) -> KeyboardCommand: # only change the x axis rotation angle new_euler = [current_euler[0] + drot, current_euler[1], current_euler[2]] new_rotation = R.from_euler("xyz", new_euler) - self.target_orientation[0, :] = torch.from_numpy(new_rotation.as_quat()).to(self.target_orientation.device) + self.target_orientation[0, :] = torch.from_numpy(new_rotation.as_quat()).to( + self.target_orientation.device + ) elif key == keyboard.KeyCode.from_char("k"): # keep the end effector vertical down, only change the rotation around the x axis current_rotation = R.from_quat(self.target_orientation[0, :].cpu().numpy()) @@ -287,7 +289,9 @@ def _process_input(self) -> KeyboardCommand: # only change the x axis rotation angle new_euler = [current_euler[0] - drot, current_euler[1], current_euler[2]] new_rotation = R.from_euler("xyz", new_euler) - self.target_orientation[0, :] = torch.from_numpy(new_rotation.as_quat()).to(self.target_orientation.device) + self.target_orientation[0, :] = torch.from_numpy(new_rotation.as_quat()).to( + self.target_orientation.device + ) elif key == keyboard.Key.space: is_close_gripper = True