Skip to content

Commit

Permalink
Merge pull request #52 from Ar-Ray-code/feat/update_params_and_interface
Browse files Browse the repository at this point in the history
Feat/update params and interface
  • Loading branch information
Ar-Ray-code authored Aug 12, 2024
2 parents 9184a21 + 6a43456 commit 9576428
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 54 deletions.
3 changes: 1 addition & 2 deletions yolox_ros_cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ ros2 launch yolox_ros_cpp yolox_tflite.launch.py
- See [here](https://github.com/fateshelled/YOLOX-ROS/blob/dev_cpp/yolox_ros_cpp/yolox_ros_cpp/labels/coco_names.txt) for label format.
- `num_classes`: 80
- `model_version`: 0.1.1rc0
- `openvino/device`: CPU
- `conf`: 0.3
- `openvino/device`: AUTO
- `nms`: 0.45
- `imshow_isshow`: true
- `src_image_topic_name`: /image_raw
Expand Down
2 changes: 1 addition & 1 deletion yolox_ros_cpp/yolox_cpp/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>yolox_cpp</name>
<version>0.3.3</version>
<version>0.4.0</version>
<description>The yolox_cpp package</description>
<maintainer email="53618876+fateshelled@users.noreply.github.com">fateshelled</maintainer>
<license>Apache-2.0 License</license>
Expand Down
6 changes: 6 additions & 0 deletions yolox_ros_cpp/yolox_cpp/src/yolox_openvino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ namespace yolox_cpp{
const auto network = ie.read_model(path_to_model);

// Step 3. Loading a model to the device
std::vector<std::string> available_devices = ie.get_available_devices();
std::cout << "======= AVAILABLE DEVICES FOR OPENVINO =======" << std::endl;
for (auto device : available_devices) {
std::cout << "- " << device << std::endl;
}
std::cout << "==============================================" << std::endl;
std::cout << "Loading a model to the device: " << device_name_ << std::endl;
auto compiled_model = ie.compile_model(network, device_name);

Expand Down
2 changes: 1 addition & 1 deletion yolox_ros_cpp/yolox_param/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>yolox_param</name>
<version>0.3.2</version>
<version>0.4.0</version>
<description>YOLOX-ROS Parameter Package</description>
<maintainer email="ray255ar@gmail.com">Ar-Ray-code</maintainer>
<license>Apache-2.0</license>
Expand Down
14 changes: 11 additions & 3 deletions yolox_ros_cpp/yolox_param/src/yolox_parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ yolox_parameters:
model_path:
type: string
description: "Path to the model file."
default_value: "./src/YOLOX-ROS/weights/tflite/model.tflite"
default_value: "example.onnx"
class_labels_path:
type: string
description: "Path to the class labels file."
Expand Down Expand Up @@ -38,9 +38,9 @@ yolox_parameters:
openvino_device:
type: string
description: "OpenVINO device."
default_value: "CPU"
default_value: "AUTO"
validation: {
one_of<>: [["CPU", "GPU", "MYRIAD"]]
one_of<>: [["AUTO", "CPU", "GPU", "NPU", "MYRIAD"]]
}
onnxruntime_use_cuda:
type: bool
Expand Down Expand Up @@ -86,3 +86,11 @@ yolox_parameters:
type: string
description: "Publish bounding box topic name."
default_value: "yolox/bounding_boxes"
use_bbox_ex_msgs:
type: bool
description: "Enable or disable bbox_ex_msgs. If true, disable vision_msgs::Detection2DArray."
default_value: false
publish_resized_image:
type: bool
description: "Enable or disable resized image."
default_value: false
23 changes: 13 additions & 10 deletions yolox_ros_cpp/yolox_ros_cpp/include/yolox_ros_cpp/yolox_ros_cpp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
#include <cmath>
#include <chrono>

#include <image_transport/image_transport.hpp>
#include <cv_bridge/cv_bridge.hpp>
#include <image_transport/image_transport.hpp>
#include <rclcpp/rclcpp.hpp>
#include <rclcpp_components/register_node_macro.hpp>

#include <sensor_msgs/msg/image.hpp>
#include <std_msgs/msg/header.hpp>
#include <vision_msgs/msg/detection2_d_array.hpp>

#include "bboxes_ex_msgs/msg/bounding_box.hpp"
#include "bboxes_ex_msgs/msg/bounding_boxes.hpp"
Expand All @@ -17,28 +19,29 @@
#include "yolox_param/yolox_param.hpp"

namespace yolox_ros_cpp{

class YoloXNode : public rclcpp::Node
{
public:
YoloXNode(const rclcpp::NodeOptions&);
YoloXNode(const rclcpp::NodeOptions &);
private:
void onInit();
void colorImageCallback(const sensor_msgs::msg::Image::ConstSharedPtr &);

static bboxes_ex_msgs::msg::BoundingBoxes objects_to_bboxes(const cv::Mat &, const std::vector<yolox_cpp::Object> &, const std_msgs::msg::Header &);
static vision_msgs::msg::Detection2DArray objects_to_detection2d(const std::vector<yolox_cpp::Object> &, const std_msgs::msg::Header &);

protected:
std::shared_ptr<yolox_parameters::ParamListener> param_listener_;
yolox_parameters::Params params_;
private:
void onInit();
rclcpp::TimerBase::SharedPtr init_timer_;

std::unique_ptr<yolox_cpp::AbcYoloX> yolox_;
std::vector<std::string> class_names_;

rclcpp::TimerBase::SharedPtr init_timer_;
image_transport::Subscriber sub_image_;
void colorImageCallback(const sensor_msgs::msg::Image::ConstSharedPtr&);

rclcpp::Publisher<bboxes_ex_msgs::msg::BoundingBoxes>::SharedPtr pub_bboxes_;
rclcpp::Publisher<vision_msgs::msg::Detection2DArray>::SharedPtr pub_detection2d_;
image_transport::Publisher pub_image_;

bboxes_ex_msgs::msg::BoundingBoxes objects_to_bboxes(const cv::Mat&, const std::vector<yolox_cpp::Object>&, const std_msgs::msg::Header&);
};
}
20 changes: 16 additions & 4 deletions yolox_ros_cpp/yolox_ros_cpp/launch/yolox_onnxruntime.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ def generate_launch_description():
default_value='/yolox/bounding_boxes',
description='topic name for publishing bounding box message.'
),
DeclareLaunchArgument(
'use_bbox_ex_msgs',
default_value='false',
description='use BoundingBoxArray message type.'
),
DeclareLaunchArgument(
'publish_resized_image',
default_value='false',
description='use BoundingBoxArray message type.'
),
]
container = ComposableNodeContainer(
name='yolox_container',
Expand All @@ -113,12 +123,12 @@ def generate_launch_description():
executable='component_container',
composable_node_descriptions=[
ComposableNode(
package='v4l2_camera',
plugin='v4l2_camera::V4L2Camera',
name='v4l2_camera',
package='usb_cam',
plugin='usb_cam::UsbCamNode',
name='usb_cam_node',
parameters=[{
'video_device': LaunchConfiguration('video_device'),
'image_size': [640, 480]
'brightness': 100
}]),
ComposableNode(
package='yolox_ros_cpp',
Expand All @@ -142,6 +152,8 @@ def generate_launch_description():
'src_image_topic_name': LaunchConfiguration('src_image_topic_name'),
'publish_image_topic_name': LaunchConfiguration('publish_image_topic_name'),
'publish_boundingbox_topic_name': LaunchConfiguration('publish_boundingbox_topic_name'),
'publish_resized_image': LaunchConfiguration('publish_resized_image'),
'use_bbox_ex_msgs': LaunchConfiguration('use_bbox_ex_msgs'),
}],
),
],
Expand Down
20 changes: 16 additions & 4 deletions yolox_ros_cpp/yolox_ros_cpp/launch/yolox_openvino.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ def generate_launch_description():
default_value='/yolox/bounding_boxes',
description='topic name for publishing bounding box message.'
),
DeclareLaunchArgument(
'use_bbox_ex_msgs',
default_value='false',
description='use BoundingBoxArray message type.'
),
DeclareLaunchArgument(
'publish_resized_image',
default_value='false',
description='use BoundingBoxArray message type.'
),
]
container = ComposableNodeContainer(
name='yolox_container',
Expand All @@ -79,12 +89,12 @@ def generate_launch_description():
executable='component_container',
composable_node_descriptions=[
ComposableNode(
package='v4l2_camera',
plugin='v4l2_camera::V4L2Camera',
name='v4l2_camera',
package='usb_cam',
plugin='usb_cam::UsbCamNode',
name='usb_cam_node',
parameters=[{
'video_device': LaunchConfiguration('video_device'),
'image_size': [640, 480]
'brightness': 100
}]),
ComposableNode(
package='yolox_ros_cpp',
Expand All @@ -104,6 +114,8 @@ def generate_launch_description():
'src_image_topic_name': LaunchConfiguration('src_image_topic_name'),
'publish_image_topic_name': LaunchConfiguration('publish_image_topic_name'),
'publish_boundingbox_topic_name': LaunchConfiguration('publish_boundingbox_topic_name'),
'publish_resized_image': LaunchConfiguration('publish_resized_image'),
'use_bbox_ex_msgs': LaunchConfiguration('use_bbox_ex_msgs'),
}],
),
],
Expand Down
23 changes: 17 additions & 6 deletions yolox_ros_cpp/yolox_ros_cpp/launch/yolox_tensorrt.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ def generate_launch_description():
default_value='/yolox/bounding_boxes',
description='topic name for publishing bounding box message.'
),
DeclareLaunchArgument(
'use_bbox_ex_msgs',
default_value='false',
description='use BoundingBoxArray message type.'
),
DeclareLaunchArgument(
'publish_resized_image',
default_value='false',
description='use BoundingBoxArray message type.'
),
]
container = ComposableNodeContainer(
name='yolox_container',
Expand All @@ -80,14 +90,13 @@ def generate_launch_description():
executable='component_container',
composable_node_descriptions=[
ComposableNode(
package='v4l2_camera',
plugin='v4l2_camera::V4L2Camera',
name='v4l2_camera',
package='usb_cam',
plugin='usb_cam::UsbCamNode',
name='usb_cam_node',
parameters=[{
'video_device': LaunchConfiguration('video_device'),
'image_size': [640, 480]
}]
),
'brightness': 100
}]),
ComposableNode(
package='yolox_ros_cpp',
plugin='yolox_ros_cpp::YoloXNode',
Expand All @@ -106,6 +115,8 @@ def generate_launch_description():
'src_image_topic_name': LaunchConfiguration('src_image_topic_name'),
'publish_image_topic_name': LaunchConfiguration('publish_image_topic_name'),
'publish_boundingbox_topic_name': LaunchConfiguration('publish_boundingbox_topic_name'),
'publish_resized_image': LaunchConfiguration('publish_resized_image'),
'use_bbox_ex_msgs': LaunchConfiguration('use_bbox_ex_msgs'),
}],
),
],
Expand Down
20 changes: 16 additions & 4 deletions yolox_ros_cpp/yolox_ros_cpp/launch/yolox_tflite.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ def generate_launch_description():
default_value='/yolox/bounding_boxes',
description='topic name for publishing bounding box message.'
),
DeclareLaunchArgument(
'use_bbox_ex_msgs',
default_value='false',
description='use BoundingBoxArray message type.'
),
DeclareLaunchArgument(
'publish_resized_image',
default_value='false',
description='use BoundingBoxArray message type.'
),
]
container = ComposableNodeContainer(
name='yolox_container',
Expand All @@ -85,12 +95,12 @@ def generate_launch_description():
executable='component_container',
composable_node_descriptions=[
ComposableNode(
package='v4l2_camera',
plugin='v4l2_camera::V4L2Camera',
name='v4l2_camera',
package='usb_cam',
plugin='usb_cam::UsbCamNode',
name='usb_cam_node',
parameters=[{
'video_device': LaunchConfiguration('video_device'),
'image_size': [640, 480]
'brightness': 100
}]),
ComposableNode(
package='yolox_ros_cpp',
Expand All @@ -111,6 +121,8 @@ def generate_launch_description():
'src_image_topic_name': LaunchConfiguration('src_image_topic_name'),
'publish_image_topic_name': LaunchConfiguration('publish_image_topic_name'),
'publish_boundingbox_topic_name': LaunchConfiguration('publish_boundingbox_topic_name'),
'publish_resized_image': LaunchConfiguration('publish_resized_image'),
'use_bbox_ex_msgs': LaunchConfiguration('use_bbox_ex_msgs'),
}],
),
],
Expand Down
15 changes: 9 additions & 6 deletions yolox_ros_cpp/yolox_ros_cpp/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>yolox_ros_cpp</name>
<version>0.3.2</version>
<version>0.4.0</version>
<description>The yolox_ros_cpp package</description>
<maintainer email="53618876+fateshelled@users.noreply.github.com">fateshelled</maintainer>
<license>Apache-2.0 License</license>
<author email="53618876+fateshelled@users.noreply.github.com">fateshelled</author>

<buildtool_depend>ament_cmake_auto</buildtool_depend>

<depend>rclcpp</depend>
<depend>rclcpp_components</depend>
<depend>OpenCV</depend>
<depend>bboxes_ex_msgs</depend>
<depend>cv_bridge</depend>
<depend>image_transport</depend>
<depend>std_msgs</depend>
<depend>libopencv-dev</depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>
<depend>sensor_msgs</depend>
<depend>bboxes_ex_msgs</depend>
<depend>std_msgs</depend>
<depend>vision_msgs</depend>
<depend>yolox_cpp</depend>
<depend>yolox_param</depend>

<exec_depend>usb_cam</exec_depend>

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

Expand Down
Loading

0 comments on commit 9576428

Please sign in to comment.