Skip to content
This repository was archived by the owner on Jun 7, 2026. It is now read-only.
明瑾 edited this page Mar 19, 2025 · 1 revision

Welcome to the SPR-Vision-2025 wiki!

SPR2025 Vision Project

中国石油大学SPR战队25赛季视觉项目主仓库

完全基于中南大学2024年视觉开源,很遗憾我们的开发规模不足以支持对现有的系统再做出除内部适配外更多的改动😢

该项目在原rm_vision项目上扩展了自瞄选板、能量机关识别与预测、哨兵定位、自主导航等功能,为RoboMaster机器人实现了一套通用的算法框架

各兵种针对部署备忘录

哨兵:不发送last_yaw&pitch 其他:发送

英雄:使用nonumber启动detector_test 其他:使用正常启动

各台车的相机内参以及相机-云台变换尺寸均需要手动替换修改

你可以根据以下指引配置环境:

基础环境部署

1. 安装Ubuntu 22.04 LTS

注意看好版本

2. fishros安装ros2 humble

wget http://fishros.com/install -O fishros && . fishros
sudo apt-get install ros-humble-image-transport-plugins
sudo apt install ros-humble-asio-cmake-module
sudo apt install ros-humble-foxglove-bridge
sudo apt install ros-humble-serial-driver
sudo apt remove brltty

一切安装进行完毕后,运行一次

sudo apt update && sudo apt upgrade

3. 编译安装CH341驱动

下载ch341驱动

https://www.wch.cn/download/CH341SER\_LINUX\_ZIP.html

uname -r获取linux内核版本

下载对应内核版本的ch341.c

https://elixir.bootlin.com/linux/v6.8/source/drivers/usb/serial/ch341.c

替换文件夹内ch341.c文件

进入driver文件夹

make

如果提示没有gcc-12,使用apt安装gcc-12

sudo make install

如果提示insmod: ERROR: could not insert module ch341.ko: Unknown symbol in module

进行

modinfo ch341.ko |grep depends depends: usbserial

然后sudo modprobe usbserial

问题应该解决

验证:lsmod | grep ch34 ch341 24576 0 usbserial 69632 1 ch341

4. 部署君瞄

拿到ros2程序包src文件夹,创建以兵种名称命名的文件夹,将src文件夹放入其中,在src上层运行

rosdepc update
rosdepc install --from-paths src --ignore-src -r -y
colcon build --symlink-install

5. 添加串口&相机的权限规则

sudo cp camera.rules /etc/udev/rules.d/

sudo cp serial.rules /etc/udev/rules.d/

添加后要重启生效

6. 启动相机节点与相机标定

使用USB连接相机

在工作文件夹运行

source install/setup.bash

👆记得这个命令每次新建终端都要执行一次

ros2 run mindvision_camera mindvision_camera_node

rqt添加

Plugins->Visualization->Image View

Plugins->Configurations->Dynamic Reconfigure

若没找到话题和节点记得点刷新

标定部分

安装 sudo apt install ros-humble-camera-calibration

然后运行

ros2 run camera_calibration cameracalibrator --size 7x10 --square 0.03 image:=/image_raw camera:=/mv_camera

按照进度条指示完全移动标定板,尽量使进度条变满,差不多后点击Calibrate;

计算完成后点击Save,结果文件位于/tmp/calibrationdata.tar.gz

7. 启动识别节点调试

ros2 run armor_detector armor_detector_node

rqt选择/armor_detector节点配置,打开debug选项,可在左侧image view看到/detector/result_img

调整相机对焦和光圈,使其能识别出装甲板且置信度稳定于98%-99%之间

8. 合并迈德威视相机节点

将我们的ros2-mindvision-camera和rm_vision_bringup如图拷贝至目录下

将bringup.launch_mvtest.py拷贝至rm_bringup节点对应目录下

注意分辨rm_vision_bringup和rm_bringup两个不同的名字

照常编译并source,使用以下命令启动迈德威视相机搭配中南的后端程序:

ros2 launch rm_bringup bringup.launch_mvtest.py

代码部署

1.编译时若提示cmake版本过低,可按如下文章方法安装cmake 3.24

https://blog.csdn.net/tanmx219/article/details/123495065

主要是

chmod + x cmake-3.22.0-linux-x86_64.sh

sudo ./cmake的sh文件 --skip-license --exclude-subdir --prefix=/usr/local

这两句

cmake官网https://cmake.org/files/

2.其他库按照readme安装

3.安装spdlog库,版本1.14

git clone https://github.com/gabime/spdlog.git
cd spdlog && mkdir build && cd build
cmake .. && make -j
sudo make install

cmake之后如下方fmt一样,在CmakeCache.txt里面添加-fPIC选项

4.FMT库编译安装

修改armor_detector节点里armor_detector.cpp的代码,在include里添加#include <fmt/format.h>

下载fmt10.2.1,按如下步骤编译安装:

修改CMakeLists.txt,在指定位置添加如下行:

#Add -fPIC option
add_compile_options(-fPIC)

cd进去执行:

mkdir build && cd build cmake .. make sudo make install

然后编辑build/CMakeCache.txt,在此处添加如下参数

然后重新在build目录执行:

make

sudo make install

如此,编译应该通过

5.g2o(20241228_git)编译安装

性能过差卡死解决方案:将make -j改为make -j4或更小的数字,任何时候遇到编译性能问题都可如此尝试

编译时同样需要添加-fPIC选项

6.Ceres-Solver 2.0.0(可能2.2.0)安装

rosdep提示缺少ceres是正常现象不必理会,确保apt中ceres的版本为2.0.0 若编译中Cmake提示找不到tbb相关文件,则卸载当前的libtbb,并按顺序安装libtbb2,libtbb2-dev,libtbbmalloc2-dev

7.OpenVINO(2022-2024)部署

选Go to the latest documentation for up-to-date information导航至版本页面,最好是2022或者2024

选择Install OpenVINO

wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
echo "deb https://apt.repos.intel.com/openvino/2024 ubuntu22 main" | sudo tee /etc/apt/sources.list.d/intel-openvino-2024.list
sudo apt update
sudo apt install openvino

8.串口协议通信调试

所有的数据包均统一为16位的FixPacket,其中帧头0xFF,帧尾0xFE; 发送给电控格式为:帧头0xFF,开火(1字节),Yaw(4字节),Pitch(4字节),Distance(4字节),留空(1字节),帧尾0xFE 从电控接收格式为:帧头0xFF,颜色(1字节),填充(2字节)Pitch(4字节),Yaw(4字节),帧尾0xFE,留空(3字节)

9.描述模型尺寸修改

右手系,相机镜片平面中心与云台转动轴中心的相对位置

10.代码编译部署

若遇到类似 CMake Error at /opt/ros/humble/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:240 (list): list index: 1 out of range (-1, 0) 的问题,则表示路径中有非Unicode字符,将工作目录移动至无中文路径中删除build重新编译。

若遇到类似error while loading shared libraries: libg2o_core.so: cannot open shared object file 等g2o库等无法找到的问题,首先确保g2o已按照-fPIC参数正确编译并安装成功,若问题仍然存在,则使用如下命令编辑该文件: sudo gedit /etc/ld.so.conf 并在文本编辑器中添加如下行: /usr/local/lib 保存并退出,运行 sudo ldconfig 如此,问题应该解决。

                        欢迎交流,有评论就更

原文链接:https://blog.csdn.net/weixin_38258767/article/details/106875766

以下是原项目仓库中的部署指南:

一、项目结构

*表示不在本仓库中直接提供,这部分模块已在CSU-RM-Sentry开源

.
│
├── rm_bringup (启动及参数文件)
│
├── rm_robot_description (机器人urdf文件,坐标系的定义)
│
├── rm_interfaces (自定义msg、srv)
│
├── rm_hardware_driver
│   ├── livox_ros_driver2 (*Livox激光雷达驱动)
│   │
│   ├── rm_camera_driver (相机驱动)
│   │
│   └── rm_serial_driver (串口驱动)
│
├── rm_auto_aim (自瞄算法)
│
├── rm_rune (打符算法)
│
├── rm_localization (*定位算法)
│
├── rm_perception (*感知算法)
│
├── rm_navigation (*导航算法)
│
├── rm_decision (*自主决策算法)
│
├── rm_utils (工具包) 
│   ├── math (包括PnP解算、弹道补偿等)
│   │
│   └── logger (日志库)
│
└── rm_upstart (自启动配置)

二、环境

如果你不需要完整功能,可以直接把相关的功能包删除掉

1. 基础

  • Ubuntu 22.04
  • ROS2 Humble
  • Mindvision相机驱动

2. 自瞄

  • fmt库
    sudo apt install libfmt-dev
  • Sophus库1.22.10 (G2O库依赖)
    git clone https://github.com/strasdat/Sophus
    cd Sophus
    mkdir build && cd build
    cmake ..
    make -j
    sudo make install
  • G2O库 (优化装甲板Yaw角度)
    sudo apt install libeigen3-dev libspdlog-dev libsuitesparse-dev qtdeclarative5-dev qt5-qmake libqglviewer-dev-qt5
    git clone https://github.com/RainerKuemmerle/g2o
    cd g2o
    mkdir build && cd build
    cmake ..
    make -j
    sudo make install

3. 能量机关

  • OpenVINO库 (能量机关识别)

    参考OpenVINO官方文档,建议同时安装GPU相关依赖

  • Ceres库 (能量机关曲线拟合)

    sudo apt install libceres-dev

4. 导航

  • Livox SDK2

    参考Livox官方仓库

  • Navigation2 (导航)

    sudo apt install ros-humble-navigation2 ros-humble-nav2-bringup
  • PCL库 (导航时对点云的处理)

    sudo apt install libpcl-dev
    

5. 其他

本文档中可能有缺漏,如有,可以用rosdep安装剩下依赖

rosdep install --from-paths src --ignore-src -r -y

三、编译与运行

修改rm_bringup/config/launch_params.yaml,选择需要启动的功能

# 编译
colcon build --symlink-install --parallel-workers 4 #本仓库包含的功能包过多,建议限制同时编译的线程数
# 运行
source install/setup.bash
ros2 launch rm_bringup bringup.launch.py

默认日志和内录视频路径为~/fyt2024-log/

我们的日志库是用fmt搓的,不使用ros2的日志库

四、自启动

  • 编译程序后,进入rm_upstart文件夹
cd rm_upstart
  • 修改rm_watch_dog.sh中的NAMESPACE(ros命名空间)、NODE_NAMES(需要看门狗监控的节点)和WORKING_DIR (代码路径)

  • 注册服务

sudo chmod +x ./register_service.sh
sudo ./register_service.sh

# 正常时有如下输出
# Creating systemd service file at /etc/systemd/system/rm.service...
# Reloading systemd daemon...
# Enabling service rm.service...
# Starting service rm.service...
# Service rm.service has been registered and started.
  • 查看程序状态
systemctl status rm
  • 查看终端输出
查看screen.output或~/fyt2024-log下的日志
  • 关闭程序
systemctl stop rm
  • 取消自启动
systemctl disable rm

维护者及开源许可证

赛季结束开源

Maintainer : FYT Vision Group

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

致谢

感谢这个赛季视觉组的每一个成员的付出,感谢以下开源项目:

更新日志

  • 参考上交开源,实现了EKF的自动求Jacobian矩阵
  • 增加了粒子滤波器,为状态估计提供新的选择
  • 修复了打符崩溃的问题(OpenVINO在推理时不能创建新的InferRequest,通过互斥锁解决)
  • 将自瞄解算修改为定时器回调,固定解算的频率
  • 增加手动补偿器ManualCompensator
  • 重写PnP选解逻辑
  • 修改了BA优化的代码,抽象出新的类ArmorPoseEstimator
  • 为中国石油大学SPR机器人队代码做了适应性部署