Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add params #4

Merged
merged 4 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions detector2d_bringup/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.8)
project(detector2d_bringup)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
set(ament_cmake_copyright_FOUND TRUE)
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

ament_auto_package(
INSTALL_TO_SHARE
launch
)
62 changes: 62 additions & 0 deletions detector2d_bringup/launch/detector_yolox.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import os

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch_ros.actions import ComposableNodeContainer
from launch_ros.descriptions import ComposableNode

def generate_launch_description():
container = ComposableNodeContainer(
name='detector_container',
namespace='',
package='rclcpp_components',
executable='component_container',
composable_node_descriptions=[
ComposableNode(
package='realsense2_camera',
plugin='realsense2_camera::RealSenseNodeFactory',
name='realsense2_camera',
namespace='',
parameters=[{
'align_depth.enable': True,
'enable_color': True,
'enable_depth': True
}]
),
ComposableNode(
package='detector2d_node',
plugin='detector2d_node::Detector2dNode',
name='detector2d_node',
namespace='',
parameters=[{
'yolox_trt_plugin.model_path': os.path.expanduser('~') + '/yolox_tiny.trt',
'load_target_plugin': 'detector2d_plugins::YoloxTrt'
}],
remappings=[
('image_raw', 'color/image_raw')
]
),
ComposableNode(
package='bbox2d_to_3d_node',
plugin='bbox2d_to_3d_node::BBox2DTo3DNode',
name='bbox2d_to_3d_node',
namespace='',
parameters=[{
'min_depth': 0.05,
'max_depth': 3.0,
'imshow_isshow': True
}],
remappings=[
('bbox2d', 'positions'),
('camera_info', 'aligned_depth_to_color/camera_info'),
('depth', 'aligned_depth_to_color/image_raw'),
('color', 'color/image_raw')
]
),
]
)

return LaunchDescription([
container
])
22 changes: 22 additions & 0 deletions detector2d_bringup/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>detector2d_bringup</name>
<version>0.0.0</version>
<description>Detector2d bringup node for CoRE-1</description>
<maintainer email="[email protected]">Ar-Ray-code</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>

<exec_depend>bbox2d_to_3d_node</exec_depend>
<exec_depend>detector2d_node</exec_depend>
<exec_depend>realsense2_camera</exec_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
7 changes: 7 additions & 0 deletions detector2d_node/src/detector2d_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ Detector2dNode::Detector2dNode(const rclcpp::NodeOptions & options)

void Detector2dNode::image_callback(const sensor_msgs::msg::Image::SharedPtr msg)
{
try {
cv::Mat image = cv_bridge::toCvShare(msg, "bgr8")->image;
} catch (std::exception & e) {
RCLCPP_ERROR(this->get_logger(), "exception: %s", e.what());
return;
}

vision_msgs::msg::Detection2DArray bboxes =
this->detector_->detect(cv_bridge::toCvShare(msg, "bgr8")->image);
for (size_t i = 0; i < bboxes.detections.size(); i++) {
Expand Down
10 changes: 10 additions & 0 deletions detector2d_param/src/detector2d_parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,13 @@ detector2d_parameters:
type: string
description: "panel color"
default_value: "red"
yolox_trt_plugin:
model_path:
type: string
description: "model path"
default_value: "./src/yolox_trt/weight/yolox_tiny.trt"
read_only: true
imshow_isshow:
type: bool
description: "imshow isshow"
default_value: false