Skip to content

Commit bb4ab63

Browse files
stereo_image_proc: disparity_node: Add parameter to control camera_info (#1051)
Add a parameter, use_image_transport_camera_info (default: true), to control whether DisparityNode uses image_transport::getCameraInfoTopic for deriving camera_info topics. Default Behavior (backward compatible): When use_image_transport_camera_info is true, the node continues using image_transport::getCameraInfoTopic for camera_info resolution, maintaining existing functionality. Custom Behavior: When use_image_transport_camera_info is false, the node directly uses the camera_info topics specified via remapping (e.g., left/camera_info and right/camera_info), bypassing image_transport's derivation logic. This solution allows users to explicitly remap the camera_info topics for both cameras, providing flexibility for scenarios where topic names are not unique or need customization. --------- Signed-off-by: Zhaoyuan Cheng <quic_zhaochen@quicinc.com> Signed-off-by: Zhaoyuan <quic_zhaochen@quicinc.com> Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
1 parent a7283c7 commit bb4ab63

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

stereo_image_proc/doc/components.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ Parameters
8989
over the network than camera info and/or the delay from disparity processing
9090
is too long.
9191

92+
*Common*
93+
* **use_image_transport_camera_info** (bool, default: true): To control whether DisparityNode uses image_transport::getCameraInfoTopic for deriving camera_info topics. To set false, the node directly uses the camera_info topics specified via remapping (e.g., left/camera_info and right/camera_info), bypassing image_transport's derivation logic.
94+
9295
stereo_image_proc::PointCloudNode
9396
---------------------------------
9497
Combines a rectified color image and disparity image to produce a

stereo_image_proc/src/stereo_image_proc/disparity_node.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class DisparityNode : public rclcpp::Node
7373
SEMI_GLOBAL_BLOCK_MATCHING
7474
};
7575

76+
bool use_image_transport_camera_info;
7677
// Subscriptions
7778
image_transport::SubscriberFilter sub_l_image_, sub_r_image_;
7879
message_filters::Subscriber<sensor_msgs::msg::CameraInfo> sub_l_info_, sub_r_info_;
@@ -170,6 +171,8 @@ DisparityNode::DisparityNode(const rclcpp::NodeOptions & options)
170171
bool approx = this->declare_parameter("approximate_sync", false);
171172
double approx_sync_epsilon = this->declare_parameter("approximate_sync_tolerance_seconds", 0.0);
172173
this->declare_parameter("use_system_default_qos", false);
174+
use_image_transport_camera_info = this->declare_parameter("use_image_transport_camera_info",
175+
true);
173176

174177
// Synchronize callbacks
175178
if (approx) {
@@ -307,12 +310,20 @@ DisparityNode::DisparityNode(const rclcpp::NodeOptions & options)
307310
std::string right_topic =
308311
node_base->resolve_topic_or_service_name("right/image_rect", false);
309312
// Allow also remapping camera_info to something different than default
310-
std::string left_info_topic =
311-
node_base->resolve_topic_or_service_name(
312-
image_transport::getCameraInfoTopic(left_topic), false);
313-
std::string right_info_topic =
314-
node_base->resolve_topic_or_service_name(
315-
image_transport::getCameraInfoTopic(right_topic), false);
313+
std::string left_info_topic;
314+
std::string right_info_topic;
315+
316+
if (use_image_transport_camera_info) {
317+
// Use image_transport to derive camera_info topics
318+
left_info_topic = node_base->resolve_topic_or_service_name(
319+
image_transport::getCameraInfoTopic(left_topic), false);
320+
right_info_topic = node_base->resolve_topic_or_service_name(
321+
image_transport::getCameraInfoTopic(right_topic), false);
322+
} else {
323+
// Use default camera_info topics
324+
left_info_topic = node_base->resolve_topic_or_service_name("left/camera_info", false);
325+
right_info_topic = node_base->resolve_topic_or_service_name("right/camera_info", false);
326+
}
316327

317328
// REP-2003 specifies that subscriber should be SensorDataQoS
318329
const auto sensor_data_qos = rclcpp::SensorDataQoS();

0 commit comments

Comments
 (0)