2025-06-05 17:48:43 +02:00
|
|
|
import time
|
|
|
|
|
|
2025-07-01 16:34:46 +02:00
|
|
|
from lerobot.datasets.lerobot_dataset import LeRobotDataset
|
|
|
|
|
from lerobot.robots.lekiwi.config_lekiwi import LeKiwiClientConfig
|
|
|
|
|
from lerobot.robots.lekiwi.lekiwi_client import LeKiwiClient
|
|
|
|
|
from lerobot.utils.robot_utils import busy_wait
|
2025-07-02 11:41:20 +02:00
|
|
|
from lerobot.utils.utils import log_say
|
|
|
|
|
|
|
|
|
|
EPISODE_IDX = 0
|
2025-06-05 17:48:43 +02:00
|
|
|
|
|
|
|
|
robot_config = LeKiwiClientConfig(remote_ip="172.18.134.136", id="lekiwi")
|
|
|
|
|
robot = LeKiwiClient(robot_config)
|
|
|
|
|
|
2025-07-02 11:41:20 +02:00
|
|
|
dataset = LeRobotDataset("<hf_username>/<dataset_repo_id>", episodes=[EPISODE_IDX])
|
|
|
|
|
actions = dataset.hf_dataset.select_columns("action")
|
2025-06-05 17:48:43 +02:00
|
|
|
|
|
|
|
|
robot.connect()
|
|
|
|
|
|
2025-07-02 11:41:20 +02:00
|
|
|
if not robot.is_connected:
|
|
|
|
|
raise ValueError("Robot is not connected!")
|
|
|
|
|
|
|
|
|
|
log_say(f"Replaying episode {EPISODE_IDX}")
|
|
|
|
|
for idx in range(dataset.num_frames):
|
2025-06-05 17:48:43 +02:00
|
|
|
t0 = time.perf_counter()
|
|
|
|
|
|
2025-07-02 11:41:20 +02:00
|
|
|
action = {
|
|
|
|
|
name: float(actions[idx]["action"][i]) for i, name in enumerate(dataset.features["action"]["names"])
|
|
|
|
|
}
|
2025-06-05 17:48:43 +02:00
|
|
|
robot.send_action(action)
|
|
|
|
|
|
|
|
|
|
busy_wait(max(1.0 / dataset.fps - (time.perf_counter() - t0), 0.0))
|
|
|
|
|
|
|
|
|
|
robot.disconnect()
|