Views
No views yet
insert carrot into the hole。1git clone https://github.com/huggingface/lerobot.git
2cd lerobot
3git checkout e40b58a8dfa9e7b86918c374791599d070518d11
4uv sync --extra pi --extra feetechmodel.safetensors。front 和 side。请把串口和视频设备改成实际值;若使用 SO-101,将 so100_follower 改为 so101_follower。1uv run lerobot-rollout \
2 --strategy.type=base \
3 --inference.type=rtc \
4 --inference.rtc.execution_horizon=10 \
5 --inference.rtc.max_guidance_weight=10.0 \
6 --policy.path=Aikwed/pi0.5-insert-carrot-epoch-3 \
7 --robot.type=so100_follower \
8 --robot.port=/dev/ttyACM0 \
9 --robot.cameras="{front: {type: opencv, index_or_path: /dev/video0, width: 640, height: 480, fps: 30}, side: {type: opencv, index_or_path: /dev/video2, width: 640, height: 480, fps: 30}}" \
10 --task="insert carrot into the hole" \
11 --fps=30 \
12 --duration=60 \
13 --device=cuda--inference.type=rtc。该 checkpoint 使用相对动作,而此 LeRobot 版本的同步 inference engine 不支持相对动作策略;RTC 会正确处理 action chunk 及相对动作的重新锚定。observation.state: 6 维 float32,顺序为 shoulder_pan.pos, shoulder_lift.pos, elbow_flex.pos, wrist_flex.pos, wrist_roll.pos, gripper.pos。observation.images.front: 640×480 RGB。observation.images.side: 640×480 RGB。insert carrot into the hole。1import numpy as np
2import torch
3
4from lerobot.configs import PreTrainedConfig
5from lerobot.policies import (
6 get_policy_class,
7 make_pre_post_processors,
8 prepare_observation_for_inference,
9)
10
11model_id = "Aikwed/pi0.5-insert-carrot-epoch-3"
12device = torch.device("cuda")
13
14cfg = PreTrainedConfig.from_pretrained(model_id)
15cfg.device = str(device)
16policy = get_policy_class(cfg.type).from_pretrained(model_id, config=cfg).to(device).eval()
17preprocessor, postprocessor = make_pre_post_processors(
18 policy_cfg=cfg,
19 pretrained_path=model_id,
20 preprocessor_overrides={"device_processor": {"device": str(device)}},
21)
22
23# 每个 episode 开始时重置缓存。
24policy.reset()
25preprocessor.reset()
26postprocessor.reset()
27
28# front_rgb 和 side_rgb: np.uint8, shape (480, 640, 3)
29# joint_state: np.float32, shape (6,)
30raw_observation = {
31 "observation.state": joint_state.astype(np.float32),
32 "observation.images.front": front_rgb.astype(np.uint8),
33 "observation.images.side": side_rgb.astype(np.uint8),
34}
35
36observation = prepare_observation_for_inference(
37 raw_observation,
38 device=device,
39 task="insert carrot into the hole",
40 robot_type="so_follower",
41)
42observation = preprocessor(observation)
43
44with torch.inference_mode():
45 relative_chunk = policy.predict_action_chunk(observation) # (1, 50, 6)
46 absolute_chunk = postprocessor(relative_chunk).squeeze(0) # (50, 6), CPU
47
48first_absolute_action = absolute_chunk[0]
49print(first_absolute_action)