diff --git a/examples/unitree_g1/gr00t_locomotion.py b/examples/unitree_g1/gr00t_locomotion.py index 0f33d285c..48889e4e9 100644 --- a/examples/unitree_g1/gr00t_locomotion.py +++ b/examples/unitree_g1/gr00t_locomotion.py @@ -347,16 +347,16 @@ if __name__ == "__main__": ) # reset legs and start locomotion thread - groot_controller.reset_robot() - groot_controller.start_locomotion_thread() - - # log status - logger.info("Robot initialized with GR00T locomotion policies") - logger.info("Locomotion controller running in background thread") - logger.info("Press Ctrl+C to stop") - - # keep robot alive try: + groot_controller.reset_robot() + groot_controller.start_locomotion_thread() + + # log status + logger.info("Robot initialized with GR00T locomotion policies") + logger.info("Locomotion controller running in background thread") + logger.info("Press Ctrl+C to stop") + + # keep robot alive while True: time.sleep(1.0) except KeyboardInterrupt: diff --git a/src/lerobot/robots/unitree_g1/robot_server.py b/src/lerobot/robots/unitree_g1/robot_server.py index 053787c0b..c58853748 100644 --- a/src/lerobot/robots/unitree_g1/robot_server.py +++ b/src/lerobot/robots/unitree_g1/robot_server.py @@ -11,8 +11,9 @@ from unitree_sdk2py.idl.unitree_hg.msg.dds_ import LowCmd_ as hg_LowCmd, LowStat from unitree_sdk2py.utils.crc import CRC # DDS topic names follow Unitree SDK naming conventions -kTopicLowCommand_Debug = "rt/lowcmd" # action to robot # ruff: noqa: N816 -kTopicLowState = "rt/lowstate" # observation from robot # ruff: noqa: N816 +# ruff: noqa: N816 +kTopicLowCommand_Debug = "rt/lowcmd" # action to robot +kTopicLowState = "rt/lowstate" # observation from robot LOWCMD_PORT = 6000 LOWSTATE_PORT = 6001 diff --git a/src/lerobot/robots/unitree_g1/unitree_g1.py b/src/lerobot/robots/unitree_g1/unitree_g1.py index 348f55363..db00d82ba 100644 --- a/src/lerobot/robots/unitree_g1/unitree_g1.py +++ b/src/lerobot/robots/unitree_g1/unitree_g1.py @@ -43,8 +43,9 @@ from .config_unitree_g1 import UnitreeG1Config logger = logging.getLogger(__name__) # DDS topic names follow Unitree SDK naming conventions -kTopicLowCommand_Debug = "rt/lowcmd" # ruff: noqa: N816 -kTopicLowState = "rt/lowstate" # ruff: noqa: N816 +# ruff: noqa: N816 +kTopicLowCommand_Debug = "rt/lowcmd" +kTopicLowState = "rt/lowstate" G1_29_Num_Motors = 35 G1_23_Num_Motors = 35 diff --git a/src/lerobot/robots/unitree_g1/unitree_sdk2_socket.py b/src/lerobot/robots/unitree_g1/unitree_sdk2_socket.py index 24db40fe2..183765c2d 100644 --- a/src/lerobot/robots/unitree_g1/unitree_sdk2_socket.py +++ b/src/lerobot/robots/unitree_g1/unitree_sdk2_socket.py @@ -12,7 +12,7 @@ LOWCMD_PORT = 6000 LOWSTATE_PORT = 6001 -def ChannelFactoryInitialize(*args, **kwargs): # DDS to socket bridge #noqa : N802 +def ChannelFactoryInitialize(*args, **kwargs): # noqa: N802 global _ctx, _lowcmd_sock, _lowstate_sock # read socket config config = UnitreeG1Config() @@ -37,10 +37,10 @@ class ChannelPublisher: # send action to robot self.topic = topic self.msg_type = msg_type - def Init(self): #noqa : N802 + def Init(self): # noqa: N802 pass - def Write(self, msg): + def Write(self, msg): # noqa: N802 _lowcmd_sock.send(pickle.dumps((self.topic, msg))) @@ -49,9 +49,9 @@ class ChannelSubscriber: # read observation from robot self.topic = topic self.msg_type = msg_type - def Init(self): #noqa : N802 + def Init(self): # noqa: N802 pass - def Read(self): + def Read(self): # noqa: N802 topic, msg = pickle.loads(_lowstate_sock.recv()) return msg