mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-23 17:56:07 +00:00
make precommit happy, add ignore flags
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
|
|
||||||
|
# ruff: noqa: N801, N815
|
||||||
|
# These enums follow Unitree SDK naming conventions (mixedCase with 'k' prefix)
|
||||||
|
|
||||||
|
|
||||||
class G1_29_JointArmIndex(IntEnum):
|
class G1_29_JointArmIndex(IntEnum):
|
||||||
# Left arm
|
# Left arm
|
||||||
|
|||||||
@@ -10,8 +10,9 @@ from unitree_sdk2py.core.channel import ChannelFactoryInitialize, ChannelPublish
|
|||||||
from unitree_sdk2py.idl.unitree_hg.msg.dds_ import LowCmd_ as hg_LowCmd, LowState_ as hg_LowState
|
from unitree_sdk2py.idl.unitree_hg.msg.dds_ import LowCmd_ as hg_LowCmd, LowState_ as hg_LowState
|
||||||
from unitree_sdk2py.utils.crc import CRC
|
from unitree_sdk2py.utils.crc import CRC
|
||||||
|
|
||||||
kTopicLowCommand_Debug = "rt/lowcmd" # action to robot
|
# DDS topic names follow Unitree SDK naming conventions
|
||||||
kTopicLowState = "rt/lowstate" # observation from robot
|
kTopicLowCommand_Debug = "rt/lowcmd" # action to robot # ruff: noqa: N816
|
||||||
|
kTopicLowState = "rt/lowstate" # observation from robot # ruff: noqa: N816
|
||||||
|
|
||||||
LOWCMD_PORT = 6000
|
LOWCMD_PORT = 6000
|
||||||
LOWSTATE_PORT = 6001
|
LOWSTATE_PORT = 6001
|
||||||
|
|||||||
@@ -42,8 +42,9 @@ from .config_unitree_g1 import UnitreeG1Config
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
kTopicLowCommand_Debug = "rt/lowcmd"
|
# DDS topic names follow Unitree SDK naming conventions
|
||||||
kTopicLowState = "rt/lowstate"
|
kTopicLowCommand_Debug = "rt/lowcmd" # ruff: noqa: N816
|
||||||
|
kTopicLowState = "rt/lowstate" # ruff: noqa: N816
|
||||||
|
|
||||||
G1_29_Num_Motors = 35
|
G1_29_Num_Motors = 35
|
||||||
G1_23_Num_Motors = 35
|
G1_23_Num_Motors = 35
|
||||||
@@ -81,11 +82,11 @@ class DataBuffer:
|
|||||||
self.data = None
|
self.data = None
|
||||||
self.lock = threading.Lock()
|
self.lock = threading.Lock()
|
||||||
|
|
||||||
def GetData(self):
|
def get_data(self):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
return self.data
|
return self.data
|
||||||
|
|
||||||
def SetData(self, data):
|
def set_data(self, data):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
||||||
@@ -149,7 +150,7 @@ class UnitreeG1(Robot):
|
|||||||
self.msg.mode_machine = self.lowstate_subscriber.Read().mode_machine
|
self.msg.mode_machine = self.lowstate_subscriber.Read().mode_machine
|
||||||
|
|
||||||
# initialize all motors with unified kp/kd from config
|
# initialize all motors with unified kp/kd from config
|
||||||
lowstate = self.lowstate_buffer.GetData()
|
lowstate = self.lowstate_buffer.get_data()
|
||||||
|
|
||||||
self.kp = np.array(config.kp, dtype=np.float32)
|
self.kp = np.array(config.kp, dtype=np.float32)
|
||||||
self.kd = np.array(config.kd, dtype=np.float32)
|
self.kd = np.array(config.kd, dtype=np.float32)
|
||||||
@@ -187,7 +188,7 @@ class UnitreeG1(Robot):
|
|||||||
# Capture wireless remote data
|
# Capture wireless remote data
|
||||||
lowstate.wireless_remote = msg.wireless_remote
|
lowstate.wireless_remote = msg.wireless_remote
|
||||||
|
|
||||||
self.lowstate_buffer.SetData(lowstate)
|
self.lowstate_buffer.set_data(lowstate)
|
||||||
|
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
all_t_elapsed = current_time - start_time
|
all_t_elapsed = current_time - start_time
|
||||||
@@ -211,7 +212,7 @@ class UnitreeG1(Robot):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def get_observation(self) -> dict[str, Any]:
|
def get_observation(self) -> dict[str, Any]:
|
||||||
return self.lowstate_buffer.GetData()
|
return self.lowstate_buffer.get_data()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_calibrated(self) -> bool:
|
def is_calibrated(self) -> bool:
|
||||||
@@ -219,7 +220,7 @@ class UnitreeG1(Robot):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_connected(self) -> bool:
|
def is_connected(self) -> bool:
|
||||||
return self.lowstate_buffer.GetData() is None
|
return self.lowstate_buffer.get_data() is None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _motors_ft(self) -> dict[str, type]:
|
def _motors_ft(self) -> dict[str, type]:
|
||||||
|
|||||||
Reference in New Issue
Block a user