Skip to content

[WIP] Gello code refactor#1766

Draft
wensi-ai wants to merge 12 commits intomainfrom
r1prot
Draft

[WIP] Gello code refactor#1766
wensi-ai wants to merge 12 commits intomainfrom
r1prot

Conversation

@wensi-ai
Copy link
Contributor

No description provided.

@wensi-ai wensi-ai requested a review from hang-yin June 25, 2025 00:44
@wensi-ai wensi-ai self-assigned this Jun 25, 2025
@wensi-ai wensi-ai requested a review from cremebrule June 26, 2025 21:01
Copilot AI review requested due to automatic review settings September 17, 2025 20:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request refactors the Gello codebase to introduce a device abstraction layer for teleop controllers. The refactor extracts robot control logic from the main OGRobotServer class into modular device classes, enabling support for multiple teleop interfaces.

  • Introduces a device abstraction pattern with BaseDevice and specific implementations (JoyLo and R1ProT)
  • Moves robot control logic from OGRobotServer into device-specific classes
  • Updates function signatures to use cleaner parameter names (base_cmd instead of joint_cmd)

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
joylo/gello/robots/sim_robot/og_teleop_utils.py Updates parameter names from joint_cmd to base_cmd for improved clarity
joylo/gello/robots/sim_robot/og_sim.py Major refactor to use device abstraction and move control logic to device classes
joylo/gello/devices/r1prot.py New R1ProT device implementation with ROS2 integration for robot control
joylo/gello/devices/joylo.py New JoyLo device implementation maintaining original ZMQ-based control logic
joylo/gello/devices/device_base.py Base device class providing common functionality for all teleop devices
joylo/gello/devices/init.py Device library registration for available teleop controllers
joylo/experiments/run_r1prot.py New experiment script for running R1ProT teleop configurations
joylo/experiments/launch_nodes.py Updates to support teleop parameter in node launching
joylo/configs/joycon_calibration_c8-48-05-86-17-0c.yaml New JoyCon calibration configuration
joylo/configs/joycon_calibration_48-31-77-90-f4-55.yaml Updated JoyCon calibration values
joylo/configs/joint_config_jellyfish_pro.yaml New joint configuration for jellyfish pro variant

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


action[self.robot.trunk_action_idx] = interpolated_trunk_pos

def get_base_cmd(self):
Copy link

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The get_base_cmd method returns self.base_cmd[:3] but self.base_cmd is a list that includes a timestamp as the 4th element. When self.base_cmd is None, this will raise an AttributeError. The method should handle the None case.

Suggested change
def get_base_cmd(self):
def get_base_cmd(self):
if self.base_cmd is None:
return [0.0, 0.0, 0.0]

Copilot uses AI. Check for mistakes.
theta3 = (theta1 + theta2 - self._current_trunk_tilt)
theta4 = 0.0

action[self.robot.trunk_action_idx] = th.tensor([theta1, theta2, theta3, theta4], dtype=th.float)
Copy link

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing return statement in the get_action method. The method should return the action tensor after all modifications are complete.

Copilot uses AI. Check for mistakes.
Comment on lines +188 to +194
# self._current_trunk_translate = np.clip(self._current_trunk_translate + self._joint_cmd["trunk"][0].item() * og.sim.get_sim_step_dt(), 0.25, 0.65)
# self._current_trunk_tilt = np.clip(self._current_trunk_tilt + self._joint_cmd["trunk"][1].item() * og.sim.get_sim_step_dt(), -np.pi / 2, np.pi / 2)
self._current_trunk_translate = np.clip(self._current_trunk_translate + torso_control_cmd[2] * og.sim.get_sim_step_dt(), 0.25, 0.65)
self._current_trunk_tilt = np.clip(self._current_trunk_tilt + torso_control_cmd[4] * og.sim.get_sim_step_dt(), -np.pi / 2, np.pi / 2)
# print(f" _current_trunk_translate { self._current_trunk_translate}")
# print(f" _current_trunk_tilt { self._current_trunk_tilt}")
# print(f" control trunk { torso_control_cmd}")
Copy link

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple commented-out code lines should be removed to improve code cleanliness and maintainability.

Copilot uses AI. Check for mistakes.
Comment on lines 130 to 131
if(self.current_left_arm_pos is None or self.current_left_arm_pos.dim()!= 1 or self.current_left_arm_pos.numel() != 7
or self.current_right_arm_pos is None or self.current_right_arm_pos.dim()!= 1 or self.current_right_arm_pos.numel() != 7):
Copy link

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition check has inconsistent spacing around operators. Should be 'dim() != 1' instead of 'dim()!= 1' for consistency with Python style guidelines.

Suggested change
if(self.current_left_arm_pos is None or self.current_left_arm_pos.dim()!= 1 or self.current_left_arm_pos.numel() != 7
or self.current_right_arm_pos is None or self.current_right_arm_pos.dim()!= 1 or self.current_right_arm_pos.numel() != 7):
if(self.current_left_arm_pos is None or self.current_left_arm_pos.dim() != 1 or self.current_left_arm_pos.numel() != 7
or self.current_right_arm_pos is None or self.current_right_arm_pos.dim() != 1 or self.current_right_arm_pos.numel() != 7):

Copilot uses AI. Check for mistakes.
Comment on lines 157 to 158
print(f"cmd_time: {cmd_time:.9f} s")
print(f" ✅ base cmd deltaT: {(current_time - cmd_time):.9f}")
Copy link

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug print statements should be removed or converted to proper logging to avoid cluttering production output.

Copilot uses AI. Check for mistakes.
@wensi-ai wensi-ai marked this pull request as draft September 17, 2025 20:42
@wensi-ai wensi-ai changed the title Gello code refactor [DO NOT MERGE] Gello code refactor Sep 17, 2025
@wensi-ai wensi-ai changed the title [DO NOT MERGE] Gello code refactor [WIP] Gello code refactor Sep 17, 2025
@wensi-ai wensi-ai added the enhancement New feature or request label Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant