Skip to content

Commit 3ca3831

Browse files
committed
fixed msg naming
1 parent 9dc0c69 commit 3ca3831

File tree

13 files changed

+82
-78
lines changed

13 files changed

+82
-78
lines changed

deep_msgs/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ find_package(rosidl_default_generators REQUIRED)
2727

2828
rosidl_generate_interfaces(${PROJECT_NAME}
2929
"msg/MultiImage.msg"
30-
"msg/MultiImageRaw.msg"
30+
"msg/MultiImageCompressed.msg"
3131
DEPENDENCIES std_msgs sensor_msgs
3232
)
3333

deep_msgs/msg/MultiImage.msg

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
# MultiImage.msg
2-
# A message that carries multiple compressed images together
3-
42
std_msgs/Header header
5-
sensor_msgs/CompressedImage[] images
3+
sensor_msgs/Image[] images
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# MultiImageCompressed.msg
2+
# A message that carries multiple compressed images together
3+
4+
std_msgs/Header header
5+
sensor_msgs/CompressedImage[] images

deep_msgs/msg/MultiImageRaw.msg

Lines changed: 0 additions & 3 deletions
This file was deleted.

deep_object_detection/README.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A deep learning object detection node for ROS 2. Simply provide any ONNX-compati
77
The `deep_object_detection` package provides:
88
- Model-agnostic object detection using ONNX models
99
- Automatic output format detection and adaptation
10-
- Multi-camera support via MultiImage messages (immediate batch processing)
10+
- Multi-camera support via MultiImage/MultiImageCompressed messages (immediate batch processing)
1111
- Configurable preprocessing and postprocessing pipelines
1212
- Plugin-based backend architecture (CPU, CUDA, TensorRT)
1313
- Full ROS 2 lifecycle node support
@@ -17,7 +17,7 @@ The `deep_object_detection` package provides:
1717
│ ROS 2 Topics │
1818
│ │
1919
│ ┌──────────────────────────────────┐ ┌──────────────────────────────┐ │
20-
│ │ MultiImage Topic │ │ Detection2DArray Topic │ │
20+
│ │ MultiImage/MultiImageCompressed │ │ Detection2DArray Topic │ │
2121
│ │ (synchronized multi-camera) │ │ (one per image in batch) │ │
2222
│ │ • KeepLast(1) QoS │ └──────────────────────────────┘ │
2323
│ │ • Immediate processing │ ┌──────────────────────────────┐ │
@@ -33,10 +33,10 @@ The `deep_object_detection` package provides:
3333
│ ┌──────────────────────────────────────────────────────────────────────────────┐ │
3434
│ │ Processing Pipeline (Per MultiImage Message) │ │
3535
│ │ │ │
36-
│ │ MultiImage Message │ │
36+
│ │ MultiImage/MultiImageCompressed Message │ │
3737
│ │ ┌──────────────────────────────────────────────────────────────────────┐ │ │
3838
│ │ │ 1. Decode Images (sequential) │ │ │
39-
│ │ │ • Extract all CompressedImage from MultiImage │ │ │
39+
│ │ │ • Extract all images from MultiImage/MultiImageCompressed │ │ │
4040
│ │ │ • Decode each to cv::Mat │ │ │
4141
│ │ └────────────────────┬───────────────────────────────────────────────────┘ │ │
4242
│ │ │ │ │
@@ -117,14 +117,12 @@ The `deep_object_detection` package provides:
117117
│ └──────────────────────────┘ └──────────────────────────────────────────┘ │
118118
└────────────────────────────────────────────────────────────────────────────────────┘
119119
120-
Note: Each MultiImage message is processed immediately. All images within a MultiImage
121-
message are processed as a single batch through inference. No queuing or batching of
122-
multiple MultiImage messages occurs.
120+
Note: Each MultiImage/MultiImageCompressed message is processed immediately. All images within a message are processed as a single batch through inference. No queuing or batching of multiple messages occurs.
123121
```
124122

125123
### Nodes
126124

127-
- **`deep_object_detection_node`**: A lifecycle node that subscribes to MultiImage messages (synchronized multi-camera input), runs object detection inference, and publishes detection results.
125+
- **`deep_object_detection_node`**: A lifecycle node that subscribes to MultiImage/MultiImageCompressed messages (synchronized multi-camera input), runs object detection inference, and publishes detection results.
128126

129127
### Configuration
130128

@@ -198,12 +196,12 @@ The object detection node requires the `camera_sync` node for synchronized multi
198196
input_topic:=/multi_camera_sync/multi_image_compressed
199197
```
200198

201-
Configure the detection node to subscribe to the MultiImage topic either via:
199+
Configure the detection node to subscribe to the MultiImage/MultiImageCompressed topic either via:
202200
- **Remapping** (recommended): `input_topic:=/multi_camera_sync/multi_image_compressed` in launch command
203201
- **Parameter**: Set `input_topic: "/multi_camera_sync/multi_image_compressed"` in config file
204202

205-
The node processes all images in each MultiImage message as a batch. The batch size
206-
is determined by the number of images in the MultiImage message (typically equal to
203+
The node processes all images in each MultiImage/MultiImageCompressed message as a batch. The batch size
204+
is determined by the number of images in the message (typically equal to
207205
the number of synchronized cameras).
208206

209207
### Zero-Copy Component Container (High Performance)
@@ -308,7 +306,7 @@ The node automatically detects and adapts to various ONNX model output formats:
308306
- `[batch, channels, anchors]` - anchor-based models
309307
- Any other layout - automatically detected and handled
310308

311-
**Input:** The node expects MultiImage messages (deep_msgs/MultiImage) containing synchronized compressed images from multiple cameras.
309+
**Input:** The node expects MultiImageCompressed messages (deep_msgs/MultiImageCompressed) containing synchronized compressed images, or MultiImage messages (deep_msgs/MultiImage) containing synchronized uncompressed images from multiple cameras.
312310

313311
**Output:** Detection2DArray messages containing bounding boxes, scores, and class IDs for each image in the batch.
314312

@@ -325,7 +323,7 @@ The node automatically detects and adapts to various ONNX model output formats:
325323

326324
### Required Parameters
327325
- **`model_path`** (string): Absolute path to ONNX model file (e.g., `/workspaces/deep_ros/yolov8m.onnx`).
328-
- **`input_topic`** (string): MultiImage topic name to subscribe to.
326+
- **`input_topic`** (string): MultiImage/MultiImageCompressed topic name to subscribe to.
329327

330328
### Key Parameters
331329
- **`class_names_path`** (string, optional): Absolute path to text file with class names, one per line (e.g., `/workspaces/deep_ros/deep_object_detection/config/coco_classes.txt`). If not provided, class IDs will be used in output messages.
@@ -349,9 +347,9 @@ See `config/generic_model_params.yaml` for a complete parameter reference.
349347
Topic names can be configured either via parameters in the config file or via remappings in the launch file. Remappings take precedence over parameter values.
350348

351349
### Input Topics
352-
- **`input_topic`**: MultiImage messages (deep_msgs/MultiImage) containing synchronized compressed images from multiple cameras.
350+
- **`input_topic`**: MultiImageCompressed messages (deep_msgs/MultiImageCompressed) containing synchronized compressed images, or MultiImage messages (deep_msgs/MultiImage) containing synchronized uncompressed images from multiple cameras.
353351

354-
**Note:** The node only supports MultiImage messages. Individual camera topics are not supported.
352+
**Note:** The node only supports MultiImage/MultiImageCompressed messages. Individual camera topics are not supported.
355353

356354
**Configuration:**
357355
- Via parameter: Set `input_topic` in the config file
@@ -382,8 +380,8 @@ Topic names can be configured either via parameters in the config file or via re
382380

383381
## Limitations
384382

385-
1. **MultiImage input only**: The node only supports MultiImage messages. Individual camera topics are not supported.
386-
2. **MultiImage input format**: The node processes MultiImage messages immediately upon receipt. All images within a MultiImage message are processed as a single batch. No queuing or accumulation of multiple MultiImage messages occurs.
383+
1. **MultiImage/MultiImageCompressed input only**: The node only supports MultiImage/MultiImageCompressed messages. Individual camera topics are not supported.
384+
2. **Message processing**: The node processes MultiImage/MultiImageCompressed messages immediately upon receipt. All images within a message are processed as a single batch. No queuing or accumulation of multiple messages occurs.
387385
3. **No dynamic reconfiguration**: Parameters cannot be changed at runtime. Node must be reconfigured to change parameters.
388386

389387
## Testing

deep_object_detection/include/deep_object_detection/deep_object_detection_node.hpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @brief ROS 2 lifecycle node for object detection using ONNX models
1818
*
1919
* This header defines the main DeepObjectDetectionNode class which:
20-
* - Subscribes to MultiImage messages (synchronized multi-camera input)
20+
* - Subscribes to MultiImage/MultiImageCompressed messages (synchronized multi-camera input)
2121
* - Processes MultiImage messages directly without additional batching
2222
* - Runs preprocessing, inference, and postprocessing
2323
* - Publishes Detection2DArray messages with bounding boxes and scores
@@ -33,7 +33,7 @@
3333
#include <deep_core/deep_node_base.hpp>
3434
#include <deep_core/types/tensor.hpp>
3535
#include <deep_msgs/msg/multi_image.hpp>
36-
#include <deep_msgs/msg/multi_image_raw.hpp>
36+
#include <deep_msgs/msg/multi_image_compressed.hpp>
3737
#include <opencv2/core/mat.hpp>
3838
#include <rclcpp/node_options.hpp>
3939
#include <rclcpp/rclcpp.hpp>
@@ -53,9 +53,9 @@ namespace deep_object_detection
5353
/**
5454
* @brief ROS2 lifecycle node for object detection using ONNX models
5555
*
56-
* This node performs object detection on synchronized multi-camera streams via MultiImage messages.
56+
* This node performs object detection on synchronized multi-camera streams via MultiImage/MultiImageCompressed messages.
5757
* It supports:
58-
* - MultiImage input: synchronized compressed images from multiple cameras
58+
* - MultiImage/MultiImageCompressed input: synchronized images from multiple cameras
5959
* - Direct processing: processes MultiImage messages immediately without queuing
6060
* - Multiple backends: CPU, CUDA, or TensorRT execution providers
6161
* - Configurable preprocessing: resizing, normalization, color format conversion
@@ -145,20 +145,20 @@ class DeepObjectDetectionNode : public deep_ros::DeepNodeBase
145145
void setupSubscription();
146146

147147
/**
148-
* @brief Callback for MultiImage messages (compressed)
149-
* @param msg Shared pointer to MultiImage message containing synchronized compressed images
148+
* @brief Callback for MultiImageCompressed messages (compressed)
149+
* @param msg Shared pointer to MultiImageCompressed message containing synchronized compressed images
150150
*
151151
* Converts compressed images to cv::Mat and processes them.
152152
*/
153-
void onMultiImage(const deep_msgs::msg::MultiImage::ConstSharedPtr & msg);
153+
void onMultiImage(const deep_msgs::msg::MultiImageCompressed::ConstSharedPtr & msg);
154154

155155
/**
156-
* @brief Callback for MultiImageRaw messages (uncompressed)
157-
* @param msg Shared pointer to MultiImageRaw message containing synchronized uncompressed images
156+
* @brief Callback for MultiImage messages (uncompressed)
157+
* @param msg Shared pointer to MultiImage message containing synchronized uncompressed images
158158
*
159159
* Converts uncompressed images to cv::Mat and processes them.
160160
*/
161-
void onMultiImageRaw(const deep_msgs::msg::MultiImageRaw::ConstSharedPtr & msg);
161+
void onMultiImageRaw(const deep_msgs::msg::MultiImage::ConstSharedPtr & msg);
162162

163163
/**
164164
* @brief Process images through the inference pipeline
@@ -232,10 +232,10 @@ class DeepObjectDetectionNode : public deep_ros::DeepNodeBase
232232
/// Class names loaded from file
233233
std::vector<std::string> class_names_;
234234

235-
/// Subscription to MultiImage topic (synchronized multi-camera compressed input)
236-
rclcpp::Subscription<deep_msgs::msg::MultiImage>::SharedPtr multi_image_sub_;
237-
/// Subscription to MultiImageRaw topic (synchronized multi-camera uncompressed input)
238-
rclcpp::Subscription<deep_msgs::msg::MultiImageRaw>::SharedPtr multi_image_raw_sub_;
235+
/// Subscription to MultiImageCompressed topic (synchronized multi-camera compressed input)
236+
rclcpp::Subscription<deep_msgs::msg::MultiImageCompressed>::SharedPtr multi_image_sub_;
237+
/// Subscription to MultiImage topic (synchronized multi-camera uncompressed input)
238+
rclcpp::Subscription<deep_msgs::msg::MultiImage>::SharedPtr multi_image_raw_sub_;
239239
/// Input topic name (can be set via parameter or remapping)
240240
std::string input_topic_;
241241
/// Input topic name for uncompressed images (can be set via remapping)

deep_object_detection/src/deep_object_detection_node.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include <deep_core/deep_node_base.hpp>
3333
#include <deep_core/types/tensor.hpp>
3434
#include <deep_msgs/msg/multi_image.hpp>
35-
#include <deep_msgs/msg/multi_image_raw.hpp>
35+
#include <deep_msgs/msg/multi_image_compressed.hpp>
3636
#include <lifecycle_msgs/msg/state.hpp>
3737
#include <opencv2/imgcodecs.hpp>
3838
#include <rclcpp/rclcpp.hpp>
@@ -389,33 +389,33 @@ void DeepObjectDetectionNode::setupSubscription()
389389
options.callback_group = callback_group_;
390390

391391
if (use_compressed_images_) {
392-
// Subscribe to compressed MultiImage
393-
multi_image_sub_ = this->create_subscription<deep_msgs::msg::MultiImage>(
392+
// Subscribe to compressed MultiImageCompressed
393+
multi_image_sub_ = this->create_subscription<deep_msgs::msg::MultiImageCompressed>(
394394
input_topic_,
395395
qos_profile,
396-
[this](const deep_msgs::msg::MultiImage::ConstSharedPtr msg) {
396+
[this](const deep_msgs::msg::MultiImageCompressed::ConstSharedPtr msg) {
397397
try {
398398
this->onMultiImage(msg);
399399
} catch (const std::exception & e) {
400400
RCLCPP_ERROR(this->get_logger(), "Exception in onMultiImage callback: %s", e.what());
401401
}
402402
},
403403
options);
404-
RCLCPP_INFO(this->get_logger(), "Subscribed to MultiImage (compressed) topic: %s", input_topic_.c_str());
404+
RCLCPP_INFO(this->get_logger(), "Subscribed to MultiImageCompressed (compressed) topic: %s", input_topic_.c_str());
405405
} else {
406-
// Subscribe to uncompressed MultiImageRaw
407-
multi_image_raw_sub_ = this->create_subscription<deep_msgs::msg::MultiImageRaw>(
406+
// Subscribe to uncompressed MultiImage
407+
multi_image_raw_sub_ = this->create_subscription<deep_msgs::msg::MultiImage>(
408408
input_topic_raw_,
409409
qos_profile,
410-
[this](const deep_msgs::msg::MultiImageRaw::ConstSharedPtr msg) {
410+
[this](const deep_msgs::msg::MultiImage::ConstSharedPtr msg) {
411411
try {
412412
this->onMultiImageRaw(msg);
413413
} catch (const std::exception & e) {
414414
RCLCPP_ERROR(this->get_logger(), "Exception in onMultiImageRaw callback: %s", e.what());
415415
}
416416
},
417417
options);
418-
RCLCPP_INFO(this->get_logger(), "Subscribed to MultiImageRaw (uncompressed) topic: %s", input_topic_raw_.c_str());
418+
RCLCPP_INFO(this->get_logger(), "Subscribed to MultiImage (uncompressed) topic: %s", input_topic_raw_.c_str());
419419
}
420420
}
421421

@@ -435,7 +435,7 @@ cv::Mat DeepObjectDetectionNode::decodeImage(const sensor_msgs::msg::Image & img
435435
}
436436
}
437437

438-
void DeepObjectDetectionNode::onMultiImage(const deep_msgs::msg::MultiImage::ConstSharedPtr & msg)
438+
void DeepObjectDetectionNode::onMultiImage(const deep_msgs::msg::MultiImageCompressed::ConstSharedPtr & msg)
439439
{
440440
RCLCPP_DEBUG(this->get_logger(), "Received MultiImage message with %zu images", msg->images.size());
441441
try {
@@ -465,9 +465,9 @@ void DeepObjectDetectionNode::onMultiImage(const deep_msgs::msg::MultiImage::Con
465465
}
466466
}
467467

468-
void DeepObjectDetectionNode::onMultiImageRaw(const deep_msgs::msg::MultiImageRaw::ConstSharedPtr & msg)
468+
void DeepObjectDetectionNode::onMultiImageRaw(const deep_msgs::msg::MultiImage::ConstSharedPtr & msg)
469469
{
470-
RCLCPP_DEBUG(this->get_logger(), "Received MultiImageRaw message with %zu images", msg->images.size());
470+
RCLCPP_DEBUG(this->get_logger(), "Received MultiImage message with %zu images", msg->images.size());
471471
try {
472472
std::vector<cv::Mat> images;
473473
std::vector<std_msgs::msg::Header> headers;
@@ -487,10 +487,10 @@ void DeepObjectDetectionNode::onMultiImageRaw(const deep_msgs::msg::MultiImageRa
487487
if (!images.empty()) {
488488
processImages(images, headers);
489489
} else {
490-
RCLCPP_WARN(this->get_logger(), "No valid images after decoding, skipping MultiImageRaw");
490+
RCLCPP_WARN(this->get_logger(), "No valid images after decoding, skipping MultiImage");
491491
}
492492
} catch (const std::exception & e) {
493-
RCLCPP_ERROR(this->get_logger(), "Exception processing MultiImageRaw: %s", e.what());
493+
RCLCPP_ERROR(this->get_logger(), "Exception processing MultiImage: %s", e.what());
494494
}
495495
}
496496

deep_object_detection/test/launch_tests/test_deep_object_detection_cpu_backend.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import numpy as np
2929
import pytest
3030
import rclpy
31-
from deep_msgs.msg import MultiImage
31+
from deep_msgs.msg import MultiImageCompressed
3232
from sensor_msgs.msg import CompressedImage
3333
from std_msgs.msg import Header
3434
from vision_msgs.msg import Detection2DArray
@@ -126,7 +126,7 @@ def test_detection_with_dummy_multiimage(self, proc_output):
126126

127127
# Create publisher for MultiImage messages
128128
multi_image_pub = self.node.create_publisher(
129-
MultiImage, "/multi_camera_sync/multi_image_compressed", 10
129+
MultiImageCompressed, "/multi_camera_sync/multi_image_compressed", 10
130130
)
131131

132132
# Variable to track if we received detections
@@ -158,7 +158,7 @@ def detection_callback(msg):
158158

159159
# Create MultiImage message with 1 image (for testing)
160160
# Note: max_batch_size is 6, but node will process when batch timer fires
161-
multi_image_msg = MultiImage()
161+
multi_image_msg = MultiImageCompressed()
162162
multi_image_msg.header = Header()
163163
multi_image_msg.header.stamp = self.node.get_clock().now().to_msg()
164164
multi_image_msg.header.frame_id = "camera"

deep_object_detection/test/launch_tests/test_deep_object_detection_gpu_backend.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import numpy as np
3434
import pytest
3535
import rclpy
36-
from deep_msgs.msg import MultiImage
36+
from deep_msgs.msg import MultiImageCompressed
3737
from sensor_msgs.msg import CompressedImage
3838
from std_msgs.msg import Header
3939
from vision_msgs.msg import Detection2DArray
@@ -139,7 +139,7 @@ def test_gpu_detection_with_dummy_multiimage(self, proc_output):
139139

140140
# Create publisher for MultiImage messages
141141
multi_image_pub = self.node.create_publisher(
142-
MultiImage, "/multi_camera_sync/multi_image_compressed", 10
142+
MultiImageCompressed, "/multi_camera_sync/multi_image_compressed", 10
143143
)
144144

145145
# Variable to track if we received detections
@@ -166,7 +166,7 @@ def detection_callback(msg):
166166
_, encoded_image = cv2.imencode(".jpg", dummy_image, encode_param)
167167

168168
# Create MultiImage message with 1 image
169-
multi_image_msg = MultiImage()
169+
multi_image_msg = MultiImageCompressed()
170170
multi_image_msg.header = Header()
171171
multi_image_msg.header.stamp = self.node.get_clock().now().to_msg()
172172
multi_image_msg.header.frame_id = "camera"

0 commit comments

Comments
 (0)