forked from ros2/openrobotics_darknet_ros
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: Port package to ROS Humble moving to currently maintained Darknet version instead of darknet_vendor * feat: Add automatic download of Yolo weights and configuration files to CMake list * feat: Add launch file for object detector node * feat: Expose remapping of detections topic * fix: Add handle for on set parameters callback * feat: Add automated download of Yolo V3, V4, V4-tiny and V7, default to V7-tiny in detector launch file * fix: Apply changes to CMake list and configuration files as requested in pull request * docs: Update read-me
- Loading branch information
Showing
17 changed files
with
291 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
config/yolo-v3/* | ||
!config/yolo-v3/params.yaml | ||
config/yolo-v3-tiny/* | ||
!config/yolo-v3-tiny/params.yaml | ||
config/yolo-v4/* | ||
!config/yolo-v4/params.yaml | ||
config/yolo-v4-tiny/* | ||
!config/yolo-v4-tiny/params.yaml | ||
config/yolo-v7/* | ||
!config/yolo-v7/params.yaml | ||
config/yolo-v7-tiny/* | ||
!config/yolo-v7-tiny/params.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# Download weights for Yolo v3, v4 and v7 | ||
|
||
# Yolo v3 | ||
# See https://pjreddie.com/darknet/yolo/ | ||
file(DOWNLOAD | ||
https://raw.githubusercontent.com/pjreddie/darknet/master/data/coco.names | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v3/coco.names | ||
SHOW_PROGRESS | ||
) | ||
file(DOWNLOAD | ||
https://github.com/AlexeyAB/darknet/blob/master/cfg/yolov3.cfg | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v3/yolov3.cfg | ||
SHOW_PROGRESS | ||
) | ||
file(DOWNLOAD | ||
https://pjreddie.com/media/files/yolov3.weights | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v3/yolov3.weights | ||
SHOW_PROGRESS | ||
) | ||
# Yolo v3 tiny | ||
file(DOWNLOAD | ||
https://raw.githubusercontent.com/pjreddie/darknet/master/data/coco.names | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v3-tiny/coco.names | ||
SHOW_PROGRESS | ||
) | ||
file(DOWNLOAD | ||
https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolov3-tiny.cfg | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v3-tiny/yolov3-tiny.cfg | ||
SHOW_PROGRESS | ||
) | ||
file(DOWNLOAD | ||
https://pjreddie.com/media/files/yolov3-tiny.weights | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v3-tiny/yolov3-tiny.weights | ||
SHOW_PROGRESS | ||
) | ||
|
||
# Yolo v4 | ||
# See https://github.com/AlexeyAB/darknet#pre-trained-models | ||
file(DOWNLOAD | ||
https://raw.githubusercontent.com/pjreddie/darknet/master/data/coco.names | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v4/coco.names | ||
SHOW_PROGRESS | ||
) | ||
file(DOWNLOAD | ||
https://raw.githubusercontent.com/AlexeyAB/darknet/master/cfg/yolov4.cfg | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v4/yolov4.cfg | ||
SHOW_PROGRESS | ||
) | ||
file(DOWNLOAD | ||
https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov4.weights | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v4/yolov4.weights | ||
SHOW_PROGRESS | ||
) | ||
# Yolo v4 tiny | ||
file(DOWNLOAD | ||
https://raw.githubusercontent.com/pjreddie/darknet/master/data/coco.names | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v4-tiny/coco.names | ||
SHOW_PROGRESS | ||
) | ||
file(DOWNLOAD | ||
https://raw.githubusercontent.com/AlexeyAB/darknet/master/cfg/yolov4-tiny.cfg | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v4-tiny/yolov4-tiny.cfg | ||
SHOW_PROGRESS | ||
) | ||
file(DOWNLOAD | ||
https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.weights | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v4-tiny/yolov4-tiny.weights | ||
SHOW_PROGRESS | ||
) | ||
|
||
# Yolo v7 | ||
# See https://github.com/AlexeyAB/darknet/issues/8595 | ||
file(DOWNLOAD | ||
https://raw.githubusercontent.com/pjreddie/darknet/master/data/coco.names | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v7/coco.names | ||
SHOW_PROGRESS | ||
) | ||
file(DOWNLOAD | ||
https://raw.githubusercontent.com/AlexeyAB/darknet/master/cfg/yolov7.cfg | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v7/yolov7.cfg | ||
SHOW_PROGRESS | ||
) | ||
file(DOWNLOAD | ||
https://github.com/AlexeyAB/darknet/releases/download/yolov4/yolov7.weights | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v7/yolov7.weights | ||
SHOW_PROGRESS | ||
) | ||
# Yolo v7 tiny | ||
file(DOWNLOAD | ||
https://raw.githubusercontent.com/pjreddie/darknet/master/data/coco.names | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v7-tiny/coco.names | ||
SHOW_PROGRESS | ||
) | ||
file(DOWNLOAD | ||
https://raw.githubusercontent.com/AlexeyAB/darknet/master/cfg/yolov7-tiny.cfg | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v7-tiny/yolov7-tiny.cfg | ||
SHOW_PROGRESS | ||
) | ||
file(DOWNLOAD | ||
https://github.com/AlexeyAB/darknet/releases/download/yolov4/yolov7-tiny.weights | ||
${CMAKE_CURRENT_BINARY_DIR}/config/yolo-v7-tiny/yolov7-tiny.weights | ||
SHOW_PROGRESS | ||
) | ||
|
||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/config/ DESTINATION share/${PROJECT_NAME}/config/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/**: | ||
ros__parameters: | ||
network: | ||
config: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v3-tiny/yolov3-tiny.cfg" | ||
weights: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v3-tiny/yolov3-tiny.weights" | ||
class_names: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v3-tiny/coco.names" | ||
detection: | ||
threshold: 0.25 | ||
nms_threshold: 0.45 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/**: | ||
ros__parameters: | ||
network: | ||
config: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v3/yolov3.cfg" | ||
weights: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v3/yolov3.weights" | ||
class_names: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v3/coco.names" | ||
detection: | ||
threshold: 0.25 | ||
nms_threshold: 0.45 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/**: | ||
ros__parameters: | ||
network: | ||
config: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v4-tiny/yolov4-tiny.cfg" | ||
weights: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v4-tiny/yolov4-tiny.weights" | ||
class_names: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v4-tiny/coco.names" | ||
detection: | ||
threshold: 0.25 | ||
nms_threshold: 0.45 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/**: | ||
ros__parameters: | ||
network: | ||
config: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v4/yolov4.cfg" | ||
weights: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v4/yolov4.weights" | ||
class_names: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v4/coco.names" | ||
detection: | ||
threshold: 0.25 | ||
nms_threshold: 0.45 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/**: | ||
ros__parameters: | ||
network: | ||
config: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v7-tiny/yolov7-tiny.cfg" | ||
weights: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v7-tiny/yolov7-tiny.weights" | ||
class_names: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v7-tiny/coco.names" | ||
detection: | ||
threshold: 0.25 | ||
nms_threshold: 0.45 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/**: | ||
ros__parameters: | ||
network: | ||
config: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v7/yolov7.cfg" | ||
weights: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v7/yolov7.weights" | ||
class_names: "$(find-pkg-share openrobotics_darknet_ros)/config/yolo-v7/coco.names" | ||
detection: | ||
threshold: 0.25 | ||
nms_threshold: 0.45 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import os | ||
|
||
from ament_index_python.packages import get_package_share_directory | ||
from launch import LaunchDescription | ||
from launch.actions import DeclareLaunchArgument | ||
from launch.substitutions import LaunchConfiguration | ||
from launch_ros.actions import Node | ||
from launch_ros.parameter_descriptions import ParameterFile | ||
|
||
|
||
def generate_launch_description(): | ||
detector_parameters_file = LaunchConfiguration('detector_parameters') | ||
rgb_image_topic = LaunchConfiguration('rgb_image') | ||
detections_topic = LaunchConfiguration('detections') | ||
|
||
default_detector_parameter_file = os.path.join( | ||
get_package_share_directory('openrobotics_darknet_ros'), | ||
'yolo-v7-tiny', | ||
'params.yaml' | ||
) | ||
detector_parameters_cmd = DeclareLaunchArgument( | ||
'detector_parameters', | ||
default_value=default_detector_parameter_file, | ||
description='YOLO object detection configuration file' | ||
) | ||
rgb_image_cmd = DeclareLaunchArgument( | ||
'rgb_image', | ||
description='RGB image that should be used for object detection with YOLO' | ||
) | ||
detections_topic_cmd = DeclareLaunchArgument( | ||
'detections', | ||
default_value='~/detections', | ||
description='Detections containing the bounding boxes of objects to be considered' | ||
) | ||
|
||
yolo_detector_node = Node( | ||
package='openrobotics_darknet_ros', | ||
executable='detector_node', | ||
name='detector_node', | ||
remappings=[ | ||
('~/images', rgb_image_topic), | ||
('~/detections', detections_topic) | ||
], | ||
parameters = [ParameterFile(detector_parameters_file, allow_substs=True)] | ||
) | ||
|
||
ld = LaunchDescription() | ||
ld.add_action(detector_parameters_cmd) | ||
ld.add_action(rgb_image_cmd) | ||
ld.add_action(detections_topic_cmd) | ||
ld.add_action(yolo_detector_node) | ||
return ld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.