本博客的运行环境为Ubuntu18.04,ROS为melodic。
进入ROS的工作区的src文件夹
cd ~/catkin_ws/src
克隆源码包
git clone https://github.com/xmy0916/racecar.git
然后回到ROS工作区
cd ..
编译一下
catkin_make
编译成功后,添加环境变量
source ./devel/setup.bash
运行racecar.launch文件。
roslaunch racecar_gazebo racecar.launch
运行结果如下:
运行racecar_runway.launch文件。
roslaunch racecar_gazebo racecar_runway.launch
注意!一定要用下列命令下载,其他方式会导致darknet文件夹里面是空的,编译会报错,但为什么会这样还不得而知。
git clone --recursive git@github.com:leggedrobotics/darknet_ros.git
yolov3.weight:https://wuhanshare-1252843818.cos.ap-guangzhou.myqcloud.com/yolov3.weights
yolov2.weight:https://wuhanshare-1252843818.cos.ap-guangzhou.myqcloud.com/yolov2.weights
yolov2-tiny.weight:https://wuhanshare-1252843818.cos.ap-guangzhou.myqcloud.com/yolov2-tiny.weight
将权重文件放到/home/xx/catkin_ws/src/darknet_ros/darknet_ros/yolo_network_config/weights目录下。
进入ROS工作区后,编译一下。
catkin_make -DCMAKE_BUILD_TYPE=Release
需要修改catkin_ws/src/darknet_ros/darknet_ros/config/ros.yaml文件中订阅的话题,将话题改为智能车上摄像头发布的话题。
如果不知道话题,可以到catkin_ws/src/racecar-master/racecar_description/urdf/racecar.gazebo来看一下。
启动rviz
roslaunch racecar_gazebo racecar_rviz.launch
启动gazebo
roslaunch racecar_gazebo racecar_runway_navigation.launch
修改catkin_ws/src/darknet_ros/darknet_ros/launch/darknet_ros.launch中为所需的.yaml文件。
启动yolov3检测摄像头识别目标
roslaunch darknet_ros darknet_ros.launch
问题1
CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by “driver_base” with
any of the following names:
driver_baseConfig.cmake
driver_base-config.cmake
解决方案
sudo apt-get install ros-melodic-driver-base
问题2
CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by “OpenCV” with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
解决方案
打开新的终端,运行下列代码找到该文件的位置
locate OpenCVConfig.cmake
打开/catkin_ws/src/racecar_gazebo/CMakeLists.txt文件,修改为自己对应的路径。
参考:https://www.guyuehome.com/6463