集成多类型相机驱动、MoveIt2机械臂控制和YOLO目标检测
robot_toolkit/
├── D435i/ # Intel D435i 独立录制工具
│ ├── camera.cpp # 视频录制程序
│ └── CMakeLists.txt
│
├── ros2_camera_calibration/ # ROS2 相机驱动与标定
│ ├── d435_publisher/ # D435i ROS2驱动节点
│ ├── hk_cam_node/ # 海康威视相机节点
│ ├── usb_cam_publisher/ # USB相机节点
│ └── camera_driver/ # 海康SDK封装库
│
├── my_moveit/ # MoveIt2 机械臂控制
│ ├── src/
│ │ ├── hello_moveit/ # 基础运动规划示例
│ │ └── mtc_tutorial/ # MTC抓取任务示例
│ └── urdf/ # 机械臂URDF模型库
│ ├── arm_five/ # 五轴机械臂
│ ├── ur3/ # UR3机械臂
│ └── ur_description/ # UR系列完整模型
│
└── yolo_tool/ # YOLO目标检测工具
├── 数据集处理/ # 数据集制作GUI工具
├── classify_dir.py # 文件分类脚本
└── split_dataset.py # 数据集划分脚本
| 组件 | 版本 | 说明 |
|---|---|---|
| Ubuntu | 22.04 LTS | 操作系统 |
| ROS2 | Humble Hawksbill | 机器人中间件 |
| OpenCV | 4.7.0+ | 计算机视觉库 |
| MoveIt2 | 最新版 | 运动规划框架 |
| RealSense SDK | 2.0+ | D435i驱动 |
# 安装ROS2 Humble (如未安装)
sudo apt update && sudo apt install -y curl gnupg lsb-release
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu jammy main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
sudo apt update
sudo apt install ros-humble-desktop
# 安装项目依赖
sudo apt install -y \
ros-humble-moveit \
ros-humble-camera-calibration \
ros-humble-camera-info-manager \
ros-humble-cv-bridge \
ros-humble-image-transport \
librealsense2-dev \
librealsense2-utils \
python3-pip \
python3-opencv
# 安装Python依赖
pip3 install ultralytics torch torchvision# 创建工作空间
mkdir -p ~/robot_ws/src
cd ~/robot_ws/src
<<<<<<< HEAD
- [相机标定指南](ros2_camera_calibration/README.md)
- [MoveIt2开发经验](my_moveit/机械臂开发经验.md)
- [YOLO工具使用](yolo_tool/数据集处理/README.md)
=======
# 克隆项目 (替换为实际仓库地址)
git clone <your-repo-url> .
# 编译
cd ~/robot_ws
source /opt/ros/humble/setup.bash
colcon build --symlink-install
# 设置环境
source install/setup.bash# 启动D435i发布节点
ros2 launch d435_publisher d435_launch.py
# 查看图像
ros2 run rqt_image_view rqt_image_view /d435/color/image_raw# 启动USB相机 (默认/dev/video2)
ros2 launch usb_cam_publisher usb_cam_launch.py
# 或使用默认参数
ros2 run usb_cam_publisher usb_cam_publisher# 确保配置文件路径正确
camera_driver/camera_init/HIKcamera0.yaml
# 启动海康相机节点
ros2 run hk_cam_node hk_cam_node# 五轴机械臂
ros2 launch arm_five display.launch.py
# UR3机械臂
ros2 launch ur3 display.launch.py# 基础点规划示例
ros2 run hello_moveit hello_moveit_2
# MTC抓取任务示例
ros2 run mtc_tutorial mtc_node# 安装标定工具
sudo apt install ros-humble-camera-calibration
# 启动相机并运行标定
ros2 launch d435_publisher d435_calibration_launch.py
# 运行标定程序 (8x6棋盘格,方格大小4cm)
ros2 run camera_calibration cameracalibrator \
--size 8x6 \
--square 0.04 \
image:=/camera/image_raw \
camera:=/cameracd yolo_tool/数据集处理
# 安装依赖
pip install -r requirements.txt
# 启动GUI工具
python3 main.py功能选项:
- Record Video - 录制训练视频 (按A开始,S停止)
- Extract Frames - 从视频提取帧
- Rename Frames - 批量重命名图像
- Delete Unpaired Labels - 清理无效标签
- Labeling - 使用YOLO模型自动标注
| 模块 | 文档 | 说明 |
|---|---|---|
| 相机标定 | ros2_camera_calibration/README.md | 三种相机的标定流程 |
| 机械臂开发 | my_moveit/机械臂开发经验.md | MoveIt2配置与开发经验 |
| YOLO工具 | yolo_tool/数据集处理/README.md | 数据集制作完整指南 |
# 只编译指定包
colcon build --packages-select d435_publisher
# 编译并允许警告
colcon build --packages-select hello_moveit --cmake-args -DCMAKE_CXX_FLAGS="-Wno-dev"# 查看TF树
ros2 run tf2_tools view_frames
# 查看话题列表
ros2 topic list
# 查看节点图
ros2 run rqt_graph rqt_graph
# 检查相机内参
ros2 topic echo /camera/camera_info┌─────────────────────────────────────────────────────────────┐
│ 应用层 (Application) │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ 视觉检测 │ │ 运动规划 │ │ 相机标定 │ │
│ │ (YOLO) │ │ (MoveIt2) │ │ (camera_calibration)│ │
│ └──────┬──────┘ └──────┬──────┘ └──────────┬──────────┘ │
└─────────┼────────────────┼────────────────────┼─────────────┘
│ │ │
┌─────────▼────────────────▼────────────────────▼─────────────┐
│ 中间件 (ROS2 Humble) │
│ 话题通信 / 服务调用 / Action / TF变换 │
└─────────┬────────────────┬────────────────────┬─────────────┘
│ │ │
┌─────────▼────────────────▼────────────────────▼─────────────┐
│ 硬件接口层 (Hardware) │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ D435i相机 │ │ 海康相机 │ │ USB相机 │ │
│ │ (RealSense)│ │ (GigE/USB3)│ │ (V4L2) │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
│ ┌─────────────────────────────────────────────────────────┐│
│ │ 机械臂控制器 (ROS2 Control) ││
│ │ arm_controller / gripper_controller ││
│ └─────────────────────────────────────────────────────────┘│
└─────────────────────────────────────────────────────────────┘
# 检查USB连接
lsusb | grep Intel
# 检查权限
sudo usermod -a -G dialout $USER
# 重新登录后生效- 检查目标点是否在机械臂可达范围内
- 增加规划时间和尝试次数
- 检查是否有碰撞物体干扰
- 确认配置文件路径正确
- 检查相机IP地址和网线连接
- 确认海康SDK库文件存在
本项目采用 MIT License 开源许可证。
- ROS2 - 机器人操作系统
- MoveIt2 - 运动规划框架
- Intel RealSense - 深度相机SDK
- Ultralytics YOLO - 目标检测框架
Made with ❤️ for robotics enthusiasts