(I felt that it did not work well even if I followed the articles posted on the Internet, and I recorded it mainly for solutions by situation.)
What is ROS?
ROS(Robot Operating System)is an open-source, meta-operating system for your robot. It provides the services you would expect from an operating system, including hardware abstraction, low-level device control, implementation of commonly-used functionality, message-passing between processes, and package management. Basically, it works in the Ubunto environment.
If you want to install, go here and follow the instructions. http://wiki.ros.org/ROS/Installation
What is Zed? https://www.stereolabs.com/zed-2/ detail information for installation: https://www.stereolabs.com/docs/ros/
$ cd ~/catkin_ws/src
$ git clone https://github.com/stereolabs/zed-ros-wrapper.git
$ cd ../
$ rosdep install --from-paths src --ignore-src -r -y
$ catkin_make -DCMAKE_BUILD_TYPE=Release
$ source ./devel/setup.bash
ZED camera:
$ roslaunch zed_wrapper zed.launch
ZED Mini camera:
$ roslaunch zed_wrapper zedm.launch
ZED 2 camera:
$ roslaunch zed_wrapper zed2.launch
(On the teminal)
$ mkdir -p catkin_ws/src
$ cd catkin_ws/src
$ git clone --recursive git@github.com:leggedrobotics/darknet_ros.git
$ cd ../
$ catkin_make -DCMAKE_BUILD_TYPE=Release
$ roslaunch darknet_ros darknet_ros.launch
I mention that there are some people who have problems sometimes, but if there is a yolov3 folder in catkin_ws/src rather than a darknet_ros folder, you need to change the code a little and run it.
$ roslaunch darknet_ros yolov3.launch
The default version is yolov2tiny, but If you want to use a different version of the weights (go to https://github.com/leoll2/darknet_ros_zed and follow the weights download guide) and Find the darknet_ros.launch file among the files in catkin_ws.
$ cd catkin_ws/src/darknet_ros/darknet_ros/yolo_network_config/weights
- COCO data set(Yolov2)
wget http://pjreddie.com/media/files/yolov2.weights
wget http://pjreddie.com/media/files/yolov2-tiny.weights
- VOC data set(Yolov2)
wget http://pjreddie.com/media/files/yolov2-voc.weights
wget http://pjreddie.com/media/files/yolov2-tiny-voc.weights
- Yolov3
wget http://pjreddie.com/media/files/yolov3-tiny.weights
wget http://pjreddie.com/media/files/yolov3.weights
#Maybe here
$ cd catkin_ws/src/darknet_ros/darknet_ros/launch
#opend darknet_ros.launch with gedit
$ gedit darknet_ros.launch
For example, if you want to change from yolov2.tiny version to yolov3 Modify the dragged part
change from
arg name="network_param_file" default="$(find darknet_ros)/config/yolov2-tiny.yaml"/
to
arg name="network_param_file" default="$(find darknet_ros)/config/yolov3.yaml"/
yolov3 launch
$ roslaunch darknet_ros darknet_ros.launch
You have to set it up for each camera you use. Currently, I am using a ZED2 camera, so I will first tell you how to set up a ZED camera, and then write the code for the USB_CAM that is commonly used.
What is zed2 cmera?
https://www.stereolabs.com/docs/
Since the zed2 camera provides various functions such as depth, tracking, object recognition, etc., the user has to set the required topic.
Details on the topic:
https://www.stereolabs.com/docs/ros/zed-node/#zed-parameters
The topic code of the desired function must be written in the ros.yaml file.
subscribers: camera_reading: topic: /zed/left/image_raw_color queue_size: 1
sudo apt-get install ros-kinetic-usb-cam
subscribers: camera_reading: topic: /usb_cam/image_raw queue_size: 1
roslaunch usb_cam usb_cam-test.launch
$ cd catkin_ws $ source devel/setup.bash
$ roslaunch darknet_ros darknet_ros.launch
$ cd catkin_ws $ source ./devel/setup.bash
$ roslaunch zed_wrapper zed2.launch
Darkent_ROS is working, but When the desired camera (now using zed2) is not recognized and only wait for image is displayed on the terminal.
In this case, you need to find the ros.yaml file and yolov3.yaml file and make changes. The ros.yaml,yolov3.yaml files are here.
$ cd catkin_ws/src/darknet_ros/darknet_ros/config
subscribers: camera_reading: topic: /zed/left/image_raw_color queue_size: 1 actions: camera_reading: name: /darknet_ros/check_for_objects publishers: object_detector: topic: /darknet_ros/found_object queue_size: 1 latch: false bounding_boxes: topic: /darknet_ros/bounding_boxes queue_size: 1 latch: false detection_image: topic: /darknet_ros/detection_image queue_size: 1 latch: true image_view: enable_opencv: true wait_key_delay: 1 enable_console_output: true
Additionally, it can be visually helpful if you use RVIZ. RVIZ is a 3D visualization tool for ROS applications.
install The installation command differs depending on your ROS (in my case it was the melodic version).
$ sudo apt-get install ros-groovy-rviz # or $ sudo apt-get install ros-hydro-rviz # or $ sudo apt-get install ros-indigo-rviz # or $ sudo apt-get install ros-kinetic-rviz # or $ sudo apt-get install ros-melodic-rviz # or $ sudo apt-get install ros-noetic-rviz
build
$ source /opt/ros/melodic/setup.bash $ roscore
run
$ rosrun rviz rviz
If yolo_ros, zed camera is on, press ADD in RVIZ to see various functions.