在 Client 启动推理
在 Client 启动推理
修改 client 版本(两种机型通用)
desktop 与 ex001 机型相同,desktop/ex001_client(desktop/ex001-client_robot_client-1)
当前 API 推理、bus2610 对应客户端最新版本为:v00.13.11,需要确保 client 为这个版本才可以。
修改方法:
-
可以打开浏览器(推荐使用最新版 Chrome),输入
机器 IP:9000进入容器(只输入 IP 则进入 WebUI)用户名:
admin,密码:xsquarerobot -
单击 local 进入 Portainer 内:

-
点击左侧 stack 找到 desktop_client/ex001_client,单击进入


也有第二种搜索方法,直接去找容器

是 v00.13.11 或更高版本即可继续(Orin 机器不要用 v00.13.09 / v00.13.10,这两个 arm64 镜像的相机不可用)。
推理参数见本教程「Client端启动推理配置参数」一节。
TeleTwin Desktop 推理
进入容器
这里有两种进入容器的方法:
-
网页进入终端,照前文找到 client 容器


connect 即可进入终端
-
自己的电脑 ssh 连接机器进入容器
ssh xr@ip,密码请咨询相关人士获取(没有密码也没关系,网页进入容器也是一模一样的)
通过如下命令进入容器:
docker exec -it desktop_client-robot_client-1 bash注意,某些机器容器名称可能为
desktop-robot_client-1,需要到网页上确认容器名称。
脚本发起推理
当前 desktop 机型使用的脚本为:
/opt/xr/bot/x2robot_client/share/x2robot_client/scripts/start_desktop.sh
紧接着即可发起推理,以下为示例。
同步模式
bash /opt/xr/bot/x2robot_client/share/x2robot_client/scripts/start_desktop.sh \
--attach \
--model-address Address(需要替换) \
--infer-type sync \
--instruction "put the spoon into the bowl" \
--embodiment teletwin_desktop/gripper-g \
--infer-params '{"action_horizon":32,"control_dt":0.005,"interpolate_multiplier":7,"async_params":{"algorithm":"sync","api_key":"<API_KEY>"}}' \
--home-on-stopCtrl + C 停止之后,机器会自动回零(这是因为加了 --home-on-stop)。
这里如果多摁了 Ctrl + C 或者其他情况机器未回零,可以参考附录回零命令。
RTC 推理模式
bash /opt/xr/bot/x2robot_client/share/x2robot_client/scripts/start_desktop.sh \
--attach \
--model-address Address(需要替换) \
--infer-type async \
--instruction "put the spoon into the bowl" \
--embodiment teletwin_desktop/gripper-g \
--camera-resize-width 448 \
--infer-params '{"action_horizon":32,"control_dt":0.005,"interpolate_multiplier":8,"async_params":{"algorithm":"training_time_rtc","api_key":"<API_KEY>"}}' \
--home-on-stop分析推理
这里提供一种方式:用容器的日志协助 Debug。依旧是容器内,单击即可。


Desktop 常用命令
-
机械臂控制器使能(一般用不到)
source /opt/xr/bot/setup.bash ros2 service call /realtime_controller_manager/hardware_enabled \ protocol/srv/HardwareEnabled "{enabled: true}" -
Desktop 手动回零(mode 11 → 1)
source /opt/xr/bot/setup.bash ros2 service call /realtime_controller_manager/switch_controller_mode \ protocol/srv/SwitchControllerMode "{mode: 11}" ros2 service call /realtime_controller_manager/switch_controller_mode \ protocol/srv/SwitchControllerMode "{mode: 1}"
Quanta_X1_Pro 推理

这里脚本对应的机器型号是:quanta_x1_pro/gripper-g(EX001 G 夹爪)
脚本推理
同步
bash /opt/xr/bot/x2robot_client/share/x2robot_client/scripts/start_ex001.sh \
--attach \
--model-address Address(需要替换) \
--infer-type sync \
--instruction "put the spoon into the bowl" \
--embodiment quanta_x1_pro/gripper-g \
--infer-params '{"action_horizon":32,"control_dt":0.005,"interpolate_multiplier":7,"async_params":{"algorithm":"sync","api_key":"<API_KEY>"}}' \
--home-on-stopTraining time RTC 推理模式
bash /opt/xr/bot/x2robot_client/share/x2robot_client/scripts/start_ex001.sh \
--attach \
--model-address Address(需要替换) \
--infer-type async \
--instruction "put the spoon into the bowl" \
--embodiment quanta_x1_pro/gripper-g \
--camera-resize-width 448 \
--infer-params '{"action_horizon":32,"control_dt":0.005,"interpolate_multiplier":8,"async_params":{"algorithm":"training_time_rtc","api_key":"<API_KEY>"}}' \
--home-on-stop参数含义
两套都有的参数(命令里带 --embodiment 时自动启用 public_v2,并补齐 api_schema、image_wire_format=jpeg、use_history=true 和 RTC 默认值,不需要手写)
| 参数 | 含义 |
|---|---|
action_horizon: 32 | 模型每次推理返回 32 步动作,这是模型的步数 |
control_dt: 0.005 | 控制周期 5 ms(200 Hz),dispatcher 按这个频率给机械臂下发指令 |
interpolate_multiplier | 每一步模型动作插值成多少个控制周期。数字越小动作越快。默认 sync 7、RTC 8(每个模型步约 35~40 ms,接近训练节奏),选手可以按需修改 |
api_schema: public_v2 | 使用 Wall-X 形式二公开接口 |
algorithm | 选择 client 的执行路线:training_time_rtc 是异步 RTC,sync 是同步 |
embodiment: quanta_x1_pro/gripper-g | 告诉服务端机器人型号和夹爪类型(G 夹爪),服务端据此选择归一化方式和动作维度 |
image_wire_format: jpeg | 图像以 JPEG 原始字节发送,不转 base64,传输量更小 |
use_history: true | 让服务端在同一会话里保存历史观测,并结合历史帧推理 |
api_key | WebSocket 握手时放进 Authorization: Bearer 头,用于鉴权 |
只在异步里有的参数
| 参数 | 含义 |
|---|---|
camera_resize_width: 448 | 图像宽度超过 448 时,先等比缩到 448 再发送。同步里没有这个参数,发送的是原图 |
execute_horizon: 6 | 当前这段动作执行到第 6 步时,就开始请求下一段,以重叠的方式衔接 |
max_inference_delay: 4 | 允许推理延迟最多占 4 步模型动作。这段时间内机械臂继续执行旧动作,新动作会和旧动作的前缀对齐。自适应控制器内部会把它截到 4 以内 |
initial_delay_estimate: 4 | 还没有实测延迟时,第一次推理假设延迟为 4 步,之后改用实测值 |
auto_interpolate_by_latency: true | 打开自适应 RTC:根据实测端到端延迟自动调整插值倍数 M,延迟大时动作放慢,用来覆盖网络和推理耗时 |
hil_min_interpolate_multiplier: 8 | 自适应时 M 的下限。机械臂最快就是每步 40 ms |
sync_fallback_interpolate_multiplier: 8 | 延迟太大、M 已经到上限时,会自动降级为同步执行,这个值就是降级时使用的 M |
异步里没写、但会用默认值的参数
hil_max_interpolate_multiplier:默认 16,是 M 的上限。fallback_to_sync_on_max_interpolate:默认 true,即 M 到上限后允许降级为同步。sync_fallback_horizon:默认 16,即降级为同步后每段只执行 16 步。auto_jpeg_quality_by_latency:没写camera_jpeg_quality时默认开启。网络快时用 JPEG 质量 85,慢时用 75。interpolation_mode:默认 linear。只有 linear 模式下自适应 RTC 才会生效。
同步模式的行为
每次请求一段 32 步动作,执行完之后再请求下一段,中间会停顿一个推理耗时。没有 RTC 的重叠衔接,也没有自适应调速。
只动双臂的脚本推理(带 return_body)
同步
bash /opt/xr/bot/x2robot_client/share/x2robot_client/scripts/start_ex001.sh \
--attach \
--model-address Address(需要替换) \
--infer-type sync \
--instruction "put the spoon into the bowl" \
--embodiment quanta_x1_pro/gripper-g \
--return-body '{"car_pose":false,"head_pose":false,"lift":false}' \
--infer-params '{"action_horizon":32,"control_dt":0.005,"interpolate_multiplier":7,"async_params":{"algorithm":"sync","api_key":"<API_KEY>"}}' \
--home-on-stopTraining time RTC
bash /opt/xr/bot/x2robot_client/share/x2robot_client/scripts/start_ex001.sh \
--attach \
--model-address Address(需要替换) \
--infer-type async \
--instruction "put the spoon into the bowl" \
--embodiment quanta_x1_pro/gripper-g \
--camera-resize-width 448 \
--return-body '{"car_pose":false,"head_pose":false,"lift":false}' \
--infer-params '{"action_horizon":32,"control_dt":0.005,"interpolate_multiplier":8,"async_params":{"algorithm":"training_time_rtc","api_key":"<API_KEY>"}}' \
--home-on-stopreturn_body 的意思是让服务端不返回底盘(car_pose)、头部(head_pose)和升降(lift)的动作。服务端不返回,client 就不会驱动这三部分,它们保持推理开始时的位置。这样只有双臂和夹爪在动。
附录一:Quanta_X1_Pro 常用命令
-
硬件使能(一般用不到)
source /opt/xr/bot/setup.bash ros2 service call /realtime_controller_manager/hardware_enabled \ protocol/srv/HardwareEnabled "{enabled: true}" -
Quanta_X1_Pro 仅双臂回零(mode 9 → 1)
source /opt/xr/bot/setup.bash ros2 service call /realtime_controller_manager/switch_controller_mode \ protocol/srv/SwitchControllerMode "{mode: 9}" ros2 service call /realtime_controller_manager/switch_controller_mode \ protocol/srv/SwitchControllerMode "{mode: 1}" -
调整升降腰高度
source /opt/xr/bot/setup.bash # 使能绝对位置控制器 ros2 control switch_controllers \ --deactivate lift_relative_movej_controller lift_joint_trajectory_controller \ --activate lift_absolute_movej_controller \ --best-effort # 再发送目标位置(这里示例 0.40m) ros2 topic pub --once /lift_position_controller/commands \ std_msgs/msg/Float64MultiArray "{data: [0.40]}"查看当前升降腰高度:
source /opt/xr/bot/setup.bash ros2 topic echo --once /lift/joint_states -
头部回零(建议不要动头部)
source /opt/xr/bot/setup.bash ros2 service call /hal/head/pan_tilt_control \ protocol/srv/HeadPanTiltControl \ "{yaw_position: 0.0, yaw_velocity: 0.1, pitch_position: 0.0, pitch_velocity: 0.1}"
附录二:更新 client 版本
单独更新 client 的步骤如下:

把下面的版本替换成 v00.13.11 以上:

然后更新一下启动命令。启动命令如下:
'bash' '-i' '-c' 'source /opt/xr/bot/setup.bash && ros2 launch x2robot_infer infer_with_dispatcher.launch.py'
配置好后,点击 Deploy the container。