mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-20 11:09:59 +00:00
Fix observation state
This commit is contained in:
@@ -60,7 +60,9 @@ REACHY2_MOTORS = {
|
|||||||
|
|
||||||
|
|
||||||
class Reachy2Robot(Robot):
|
class Reachy2Robot(Robot):
|
||||||
"""[Reachy 2](https://www.pollen-robotics.com/reachy/), by Pollen Robotics."""
|
"""
|
||||||
|
[Reachy 2](https://www.pollen-robotics.com/reachy/), by Pollen Robotics.
|
||||||
|
"""
|
||||||
|
|
||||||
config_class = Reachy2RobotConfig
|
config_class = Reachy2RobotConfig
|
||||||
name = "reachy2"
|
name = "reachy2"
|
||||||
@@ -115,11 +117,10 @@ class Reachy2Robot(Robot):
|
|||||||
|
|
||||||
# for cam in self.cameras.values():
|
# for cam in self.cameras.values():
|
||||||
# cam.connect()
|
# cam.connect()
|
||||||
# self.is_connected = self.is_connected and cam.is_connected
|
|
||||||
|
|
||||||
if not self.is_connected:
|
# if not self.is_connected:
|
||||||
print("Could not connect to the cameras, check that all cameras are plugged-in.")
|
# print("Could not connect to the cameras, check that all cameras are plugged-in.")
|
||||||
raise ConnectionError()
|
# raise ConnectionError()
|
||||||
|
|
||||||
self.configure()
|
self.configure()
|
||||||
|
|
||||||
@@ -142,17 +143,19 @@ class Reachy2Robot(Robot):
|
|||||||
|
|
||||||
# Read Reachy 2 state
|
# Read Reachy 2 state
|
||||||
before_read_t = time.perf_counter()
|
before_read_t = time.perf_counter()
|
||||||
state = self._get_state()
|
obs_dict = self._get_state()
|
||||||
self.logs["read_pos_dt_s"] = time.perf_counter() - before_read_t
|
self.logs["read_pos_dt_s"] = time.perf_counter() - before_read_t
|
||||||
|
|
||||||
state = np.asarray(list(state.values()))
|
# state = np.asarray(list(state.values()))
|
||||||
obs_dict[OBS_STATE] = state
|
# obs_dict[OBS_STATE] = state
|
||||||
|
|
||||||
# Capture images from cameras
|
# Capture images from cameras
|
||||||
# for cam_key, cam in self.cameras.items():
|
# for cam_key, cam in self.cameras.items():
|
||||||
# before_camread_t = time.perf_counter()
|
# before_camread_t = time.perf_counter()
|
||||||
# obs_dict[f"{OBS_IMAGES}.{cam_key}"] = cam.async_read()
|
# frame = cam.async_read(timeout_ms=200)
|
||||||
# self.logs[f"read_camera_{cam_key}_dt_s"] = cam.logs["delta_timestamp_s"]
|
# print(f"Async frame shape:", frame.shape)
|
||||||
|
|
||||||
|
# obs_dict[f"{OBS_IMAGES}.{cam_key}"] = cam.async_read(timeout_ms=200)
|
||||||
# self.logs[f"async_read_camera_{cam_key}_dt_s"] = time.perf_counter() - before_camread_t
|
# self.logs[f"async_read_camera_{cam_key}_dt_s"] = time.perf_counter() - before_camread_t
|
||||||
|
|
||||||
return obs_dict
|
return obs_dict
|
||||||
@@ -167,7 +170,8 @@ class Reachy2Robot(Robot):
|
|||||||
raise KeyError(f"Key '{key}' is not a valid motor key in Reachy 2.")
|
raise KeyError(f"Key '{key}' is not a valid motor key in Reachy 2.")
|
||||||
else:
|
else:
|
||||||
self.reachy.joints[REACHY2_MOTORS[key]].goal_position = val
|
self.reachy.joints[REACHY2_MOTORS[key]].goal_position = val
|
||||||
self.reachy.send_goal_positions()
|
# # We don't want the teleoperator reachy2_specific to send the goal positions
|
||||||
|
# self.reachy.send_goal_positions()
|
||||||
self.logs["write_pos_dt_s"] = time.perf_counter() - before_write_t
|
self.logs["write_pos_dt_s"] = time.perf_counter() - before_write_t
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user