mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-23 17:56:07 +00:00
ensure robot is connected before changing mode
This commit is contained in:
@@ -77,6 +77,7 @@ class G1_29_LowState: # noqa: N801
|
|||||||
motor_state: list[MotorState] = field(default_factory=lambda: [MotorState() for _ in range(G1_29_Num_Motors)])
|
motor_state: list[MotorState] = field(default_factory=lambda: [MotorState() for _ in range(G1_29_Num_Motors)])
|
||||||
imu_state: IMUState = field(default_factory=IMUState)
|
imu_state: IMUState = field(default_factory=IMUState)
|
||||||
wireless_remote: Any = None # Raw wireless remote data
|
wireless_remote: Any = None # Raw wireless remote data
|
||||||
|
mode_machine: int = 0 # Robot mode
|
||||||
|
|
||||||
|
|
||||||
class DataBuffer:
|
class DataBuffer:
|
||||||
@@ -142,8 +143,6 @@ class UnitreeG1(Robot):
|
|||||||
|
|
||||||
while not self.is_connected:
|
while not self.is_connected:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
logger.warning("[UnitreeG1] Waiting to connect to robot...")
|
|
||||||
logger.warning("[UnitreeG1] Connected to robot.")
|
|
||||||
|
|
||||||
# initialize hg's lowcmd msg
|
# initialize hg's lowcmd msg
|
||||||
self.crc = CRC()
|
self.crc = CRC()
|
||||||
@@ -156,8 +155,9 @@ class UnitreeG1(Robot):
|
|||||||
lowstate = self.lowstate_buffer.get_data()
|
lowstate = self.lowstate_buffer.get_data()
|
||||||
if lowstate is None:
|
if lowstate is None:
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
|
logger.warning("[UnitreeG1] Waiting for robot state...")
|
||||||
self.msg.mode_machine = lowstate.mode_machine if hasattr(lowstate, 'mode_machine') else 0
|
logger.warning("[UnitreeG1] Connected to robot.")
|
||||||
|
self.msg.mode_machine = lowstate.mode_machine
|
||||||
|
|
||||||
# initialize all motors with unified kp/kd from config
|
# initialize all motors with unified kp/kd from config
|
||||||
self.kp = np.array(config.kp, dtype=np.float32)
|
self.kp = np.array(config.kp, dtype=np.float32)
|
||||||
@@ -196,6 +196,9 @@ class UnitreeG1(Robot):
|
|||||||
# Capture wireless remote data
|
# Capture wireless remote data
|
||||||
lowstate.wireless_remote = msg.wireless_remote
|
lowstate.wireless_remote = msg.wireless_remote
|
||||||
|
|
||||||
|
# Capture mode_machine
|
||||||
|
lowstate.mode_machine = msg.mode_machine
|
||||||
|
|
||||||
self.lowstate_buffer.set_data(lowstate)
|
self.lowstate_buffer.set_data(lowstate)
|
||||||
|
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
|
|||||||
Reference in New Issue
Block a user