openarm_ros2_ws/README.md

246 lines
8.7 KiB
Markdown
Raw Normal View History

2026-03-31 07:18:19 +00:00
# 设置代理
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
export PROXY="http://192.168.31.39:7890"
2026-03-31 07:32:53 +00:00
2026-03-31 07:18:19 +00:00
export http_proxy="$PROXY"
2026-03-31 07:32:53 +00:00
2026-03-31 07:18:19 +00:00
export https_proxy="$PROXY"
2026-03-31 07:32:53 +00:00
2026-03-31 07:18:19 +00:00
export ftp_proxy="$PROXY"
2026-03-31 07:32:53 +00:00
2026-03-31 07:18:19 +00:00
export socks_proxy="$PROXY"
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# 设置虚拟can接口
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
sudo ip link add dev can1 type vcan
2026-03-31 07:32:53 +00:00
2026-03-31 07:18:19 +00:00
sudo ip link set up can1
2026-03-31 07:32:53 +00:00
2026-03-31 07:18:19 +00:00
sudo ip link set can1 type vcan bitrate 1000000
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# 设置can波特率
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
ip link set can1 type can bitrate 1000000
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# 启动can
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
ip link set can0 up
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# 设置slcan
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
sudo slcand -o -c -s8 -S1000000 /dev/ttyACM0 can0
2026-03-31 07:32:53 +00:00
2026-03-31 07:18:19 +00:00
sudo slcand -o -c -s8 -S1000000 /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 can1
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# 查看can信息
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
ip -details -statistics link show can1
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# 绑定接口名
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
sudo vim /etc/udev/rules.d/72-gs-usb-can.rules
SUBSYSTEM=="net", ACTION=="add", ATTRS{serial}=="004F004F3630501120353355", NAME="can6"
2026-03-31 07:32:53 +00:00
2026-03-31 07:18:19 +00:00
SUBSYSTEM=="net", ACTION=="add", ATTRS{serial}=="004C004F4D4D501020383834", NAME="can7"
2026-03-31 07:32:53 +00:00
2026-03-31 07:18:19 +00:00
SUBSYSTEM=="net", ACTION=="add", ATTRS{serial}=="0061005A3945501620303651", NAME="can4"
2026-03-31 07:32:53 +00:00
2026-03-31 07:18:19 +00:00
SUBSYSTEM=="net", ACTION=="add", ATTRS{serial}=="006500573945501620303651", NAME="can5"
sudo udevadm control --reload-rules
2026-03-31 07:32:53 +00:00
2026-03-31 07:18:19 +00:00
sudo udevadm trigger
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# 安装ros依赖
2026-03-31 07:32:53 +00:00
``` shell
rosdepc install --from-paths src --ignore-src --rosdistro=humble -y
```
2026-03-31 07:18:19 +00:00
# 启动单臂
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
ros2 launch openarm_bringup openarm.launch.py arm_type:=v10 use_fake_hardware:=false can_interface:=can6
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# 设置单臂运动
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
ros2 action send_goal /joint_trajectory_controller/follow_joint_trajectory control_msgs/action/FollowJointTrajectory '{trajectory: {joint_names: ["openarm_joint1", "openarm_joint2", "openarm_joint3", "openarm_joint4", "openarm_joint5", "openarm_joint6", "openarm_joint7"], points: [{positions: [0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15], time_from_start: {sec: 1, nanosec: 0}}]}}'
ros2 action send_goal /joint_trajectory_controller/follow_joint_trajectory control_msgs/action/FollowJointTrajectory '{trajectory: {joint_names: ["openarm_joint1", "openarm_joint2", "openarm_joint3", "openarm_joint4", "openarm_joint5", "openarm_joint6", "openarm_joint7"], points: [{positions: [0, 0, 0, 0, 0, 0, 0], time_from_start: {sec: 1, nanosec: 0}}]}}'
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# 设置右臂运动
2026-03-31 07:32:53 +00:00
``` shell
ros2 action send_goal /right_joint_trajectory_controller
follow_joint_trajectory control_msgs/action/FollowJointTrajectory '{trajectory: {joint_names: ["openarm_right_joint1", "openarm_right_joint2", "openarm_right_joint3", "openarm_right_joint4", "openarm_right_joint5", "openarm_right_joint6", "openarm_right_joint7"], points: [{positions: [0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15], time_from_start: {sec: 1, nanosec: 0}}]}}'
2026-03-31 07:18:19 +00:00
ros2 action send_goal /right_joint_trajectory_controller/follow_joint_trajectory control_msgs/action/FollowJointTrajectory '{trajectory: {joint_names: ["openarm_right_joint1", "openarm_right_joint2", "openarm_right_joint3", "openarm_right_joint4", "openarm_right_joint5", "openarm_right_joint6", "openarm_right_joint7"], points: [{positions: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], time_from_start: {sec: 1, nanosec: 0}}]}}'
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# 启动双臂
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
ros2 launch openarm_bringup openarm.bimanual.launch.py arm_type:=v10 use_fake_hardware:=false gravity_compensation_enabled:=false gravity_compensation_use_kdl:=false gravity_torque_mode:=false enable_joint_state_udp_broadcast:=true joint_state_udp_payload_format:=json
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# 启动双臂位置控制器
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
ros2 launch openarm_bringup openarm.bimanual.launch.py arm_type:=v10 use_fake_hardware:=false gravity_compensation_enabled:=false gravity_compensation_use_kdl:=false gravity_torque_mode:=false robot_controller:=forward_position_controller enable_joint_state_udp_broadcast:=true joint_state_udp_payload_format:=json
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# 启动双臂重力补偿
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
ros2 launch openarm_bringup openarm.bimanual.launch.py arm_type:=v10 use_fake_hardware:=false gravity_compensation_enabled:=true gravity_compensation_use_kdl:=true gravity_torque_mode:=true gripper_gravity_compensation_enabled:=true enable_joint_state_udp_broadcast:=true joint_state_udp_payload_format:=json
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# 启动moveit
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
ros2 launch openarm_bimanual_moveit_config demo.launch.py use_fake_hardware:=false
2026-03-31 07:32:53 +00:00
ros2 launch openarm_bimanual_moveit_config demo.launch.py use_fake_hardware:=false robot_controller:=forward_velocity_controller
```
2026-03-31 07:18:19 +00:00
# 启动动作录制
2026-03-31 07:32:53 +00:00
## 启动节点
``` shell
2026-03-31 07:18:19 +00:00
ros2 launch openarm_joint_recorder joint_trajectory_recorder.launch.py
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
2026-03-31 07:32:53 +00:00
## 开始录制
``` shell
2026-03-31 07:18:19 +00:00
ros2 service call /joint_trajectory_recorder/set_recording std_srvs/srv/SetBool "{data: true}"
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
2026-03-31 07:32:53 +00:00
## 停止录制
``` shell
2026-03-31 07:18:19 +00:00
ros2 service call /joint_trajectory_recorder/set_recording std_srvs/srv/SetBool "{data: false}"
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
2026-03-31 07:32:53 +00:00
## 回放
``` shell
2026-03-31 07:18:19 +00:00
ros2 service call /joint_trajectory_recorder/play std_srvs/srv/Trigger "{}"
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
2026-03-31 07:32:53 +00:00
## 保存轨迹
``` shell
2026-03-31 07:18:19 +00:00
ros2 service call /joint_trajectory_recorder/save std_srvs/srv/Trigger "{}"
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
2026-03-31 07:32:53 +00:00
## 加载轨迹
``` shell
2026-03-31 07:18:19 +00:00
ros2 service call /joint_trajectory_recorder/load std_srvs/srv/Trigger "{}"
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
2026-03-31 07:32:53 +00:00
# 摄像头标定
``` shell
ros2 run camera_calibration cameracalibrator --size 9x6 --square 0.255 left:=/camera/left/image_raw right:=/camera/right/image_raw left_camera:=camera_frame_left right_camera:=camera_frame_right
```
2026-03-31 07:18:19 +00:00
2026-03-31 07:32:53 +00:00
# huggingface token
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
2026-03-31 07:18:19 +00:00
2026-03-31 07:32:53 +00:00
# 下载数据集
``` shell
2026-03-31 07:18:19 +00:00
export HF_ENDPOINT=https://hf-mirror.com
2026-03-31 07:32:53 +00:00
hf download --repo-type dataset --token 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 pixparse/cc3m-wds --local-dir /home/D/ --resume-download
```
# 上传数据集
``` shell
hf upload shenchenayng/lerobot_openarm_test . --repo-type=dataset
```
2026-03-31 07:18:19 +00:00
# 设置can
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
lerobot-setup-can --mode=setup --interfaces=can0,can2 --use_fd=false
2026-03-31 07:32:53 +00:00
2026-03-31 07:18:19 +00:00
lerobot-setup-can --mode=test --interfaces=can0,can2 --use_fd=false
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# 测试相机
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
lerobot-find-cameras opencv
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# 启动单臂
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
lerobot-teleoperate \
--robot.type=openarm_follower \
--robot.port=can0 \
--robot.side=right \
--robot.cameras="{ front: {type: opencv, index_or_path: 0, width: 640, height: 480, fps: 30, fourcc: "MJPG"}}" \
--robot.id=my_follower --robot.use_can_fd=false \
--teleop.type=openarm_leader \
--teleop.port=can2 \
--teleop.id=my_leader --teleop.use_can_fd=false \
--display_data=true
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# 录制单臂
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
lerobot-record \
--robot.type=openarm_follower \
--robot.port=can2 \
--robot.side=right \
--robot.cameras="{ front: {type: opencv, index_or_path: 0, width: 640, height: 480, fps: 30, fourcc: "MJPG"}}" \
--robot.id=my_follower --robot.use_can_fd=false \
--teleop.type=openarm_leader \
--teleop.port=can0 \
--teleop.id=my_leader --teleop.use_can_fd=false \
--display_data=true \
--dataset.repo_id=shenchenayng/lerobot_openarm_test \
--dataset.num_episodes=40 \
--dataset.single_task="Grab Oranges" \
--dataset.push_to_hub=false \
--dataset.episode_time_s=10 \
--dataset.reset_time_s=2
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
# wandb token
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
# 训练
2026-03-31 07:32:53 +00:00
``` shell
2026-03-31 07:18:19 +00:00
lerobot-train \
--dataset.repo_id=shenchenayng/lerobot_openarm_test \
--dataset.root=/home/shen/.cache/huggingface/lerobot/shenchenayng/lerobot_openarm_test \
--dataset.revision=v0.1.0 \
--dataset.streaming=false \
--policy.type=act \
--output_dir=~/lerobot_openarm_modle \
--job_name=lerobot_openarm_test \
--policy.device=cuda \
--wandb.enable=true \
--wandb.project=lerobot_openarm_test \
--policy.push_to_hub=false \
--steps=2000 \
--batch_size=8 \
--save_freq=100
lerobot-train --dataset.repo_id=shenchenayng/lerobot_openarm_test --dataset.root=/home/featurize/lerobot_openarm_test --dataset.revision=v0.1.0 --dataset.streaming=false --policy.type=act --output_dir=/home/featurize/lerobot_openarm_modle/a --job_name=lerobot_openarm_test --policy.device=cuda --wandb.enable=true --wandb.project=lerobot_openarm_test --policy.push_to_hub=false --steps=2000 --batch_size=8 --save_freq=100
2026-03-31 07:32:53 +00:00
```
2026-03-31 07:18:19 +00:00
2026-03-31 07:32:53 +00:00
# 推理
``` shell
2026-03-31 07:18:19 +00:00
lerobot-record \
--robot.type=openarm_follower \
--robot.port=can0 \
--robot.side=right \
--robot.use_can_fd=false \
--robot.cameras="{ front: {type: opencv, index_or_path: 0, width: 640, height: 480, fps: 30, fourcc: "MJPG"}}" \
--robot.id=my_follower \
--display_data=false \
--dataset.repo_id=shenchenayng/eval_lerobot_openarm_test \
--dataset.single_task="Grab Oranges" \
--dataset.episode_time_s=1000 \
--dataset.push_to_hub=false \
--policy.path=/home/shen/lerobot_openarm_modle/202603260100_model/202603260100/pretrained_model
2026-03-31 07:32:53 +00:00
```