From 5d0695abdfb47f1c6550caaf92bcef0ea32acc1d Mon Sep 17 00:00:00 2001 From: SamerKhshiboun Date: Tue, 29 Aug 2023 08:07:19 +0000 Subject: [PATCH 1/3] fix readme and nodefactory for ros2 run --- realsense2_camera/src/realsense_node_factory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/realsense2_camera/src/realsense_node_factory.cpp b/realsense2_camera/src/realsense_node_factory.cpp index 410aacc78f..46b1d13ce1 100644 --- a/realsense2_camera/src/realsense_node_factory.cpp +++ b/realsense2_camera/src/realsense_node_factory.cpp @@ -31,7 +31,7 @@ using namespace realsense2_camera; constexpr auto realsense_ros_camera_version = REALSENSE_ROS_EMBEDDED_VERSION_STR; RealSenseNodeFactory::RealSenseNodeFactory(const rclcpp::NodeOptions & node_options) : - Node("camera", "/", node_options), + Node("camera", "/camera", node_options), _logger(this->get_logger()) { init(); From 30a70e1e344ea0b97205e8ee5fdcb1f4cb96a964 Mon Sep 17 00:00:00 2001 From: Samer Khshiboun <99127997+SamerKhshiboun@users.noreply.github.com> Date: Tue, 29 Aug 2023 11:38:51 +0300 Subject: [PATCH 2/3] Update README.md --- README.md | 69 +++++++++++++++++++++++++ realsense2_camera/src/rs_node_setup.cpp | 6 +++ 2 files changed, 75 insertions(+) diff --git a/README.md b/README.md index d672e1d364..de23e1721c 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ * [Installation](#installation) * [Usage](#usage) * [Starting the camera node](#start-camera-node) + * [Camera name and namespace](#camera-name-and-namespace) * [Parameters](#parameters) * [ROS2-vs-Optical Coordination Systems](#coordination) * [TF from coordinate A to coordinate B](#tfs) @@ -183,6 +184,74 @@
+

+ Camera Name And Camera Namespace +

+ +### Usage +User can set the camera name and camera namespace, to distinguish between cameras and platforms, which helps identifying the right nodes and topics to work with. + +### Example +- If user have multiple cameras (might be of the same model) and multiple robots then user can choose to launch/run his nodes on this way. +- For the first robot and first camera he will run/launch it with these parameters: + - camera_namespace: + - robot1 + - camera_name + - D455_1 + + - With ros2 launch (via command line or by editing these two parameters in the launch file): + + ```ros2 launch realsense2_camera rs_launch.py camera_namespace:=robot1 camera_name:=D455_1``` + + - With ros2 run (using remapping mechanisim [Reference](https://docs.ros.org/en/foxy/How-To-Guides/Node-arguments.html)): + + ```ros2 run realsense2_camera realsense2_camera_node --ros-args -r __node:=D455_1 -r __ns:=robot1``` + + - Result + ``` + > ros2 node list + /robot1/D455_1 + + > ros2 topic list + /robot1/D455_1/color/camera_info + /robot1/D455_1/color/image_raw + /robot1/D455_1/color/metadata + /robot1/D455_1/depth/camera_info + /robot1/D455_1/depth/image_rect_raw + /robot1/D455_1/depth/metadata + /robot1/D455_1/extrinsics/depth_to_color + /robot1/D455_1/imu + + > ros2 service list + /robot1/D455_1/device_info + ``` + +### Default behavior if non of these parameters are given: + - camera_namespace:=camera + - camera_name:=camera + +``` +> ros2 node list +/camera/camera + +> ros2 topic list +/camera/camera/color/camera_info +/camera/camera/color/image_raw +/camera/camera/color/metadata +/camera/camera/depth/camera_info +/camera/camera/depth/image_rect_raw +/camera/camera/depth/metadata +/camera/camera/extrinsics/depth_to_color +/camera/camera/imu + +> ros2 service list +/camera/camera/device_info +``` + + +
+ +

Parameters

diff --git a/realsense2_camera/src/rs_node_setup.cpp b/realsense2_camera/src/rs_node_setup.cpp index 09740d7a1b..05cb8049a6 100755 --- a/realsense2_camera/src/rs_node_setup.cpp +++ b/realsense2_camera/src/rs_node_setup.cpp @@ -225,6 +225,8 @@ void BaseRealSenseNode::startPublishers(const std::vector& profi if (sensor.rs2::sensor::is()) rectified_image = true; + // adding "~/" to the topic name will add node namespace and node name to the topic + // see "Private Namespace Substitution Character" section on https://design.ros2.org/articles/topic_and_service_names.html image_raw << "~/" << stream_name << "/image_" << ((rectified_image)?"rect_":"") << "raw"; camera_info << "~/" << stream_name << "/camera_info"; @@ -316,6 +318,8 @@ void BaseRealSenseNode::startRGBDPublisherIfNeeded() { rmw_qos_profile_t qos = _use_intra_process ? qos_string_to_qos(DEFAULT_QOS) : qos_string_to_qos(IMAGE_QOS); + // adding "~/" to the topic name will add node namespace and node name to the topic + // see "Private Namespace Substitution Character" section on https://design.ros2.org/articles/topic_and_service_names.html _rgbd_publisher = _node.create_publisher("~/rgbd", rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(qos), qos)); } @@ -403,6 +407,8 @@ void BaseRealSenseNode::updateSensors() void BaseRealSenseNode::publishServices() { + // adding "~/" to the service name will add node namespace and node name to the service + // see "Private Namespace Substitution Character" section on https://design.ros2.org/articles/topic_and_service_names.html _device_info_srv = _node.create_service( "~/device_info", [&](const realsense2_camera_msgs::srv::DeviceInfo::Request::SharedPtr req, From 327e60255e814ce5bd6e1b1669c165f84089c050 Mon Sep 17 00:00:00 2001 From: Samer Khshiboun <99127997+SamerKhshiboun@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:48:02 +0300 Subject: [PATCH 3/3] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index d672e1d364..4b981efac1 100644 --- a/README.md +++ b/README.md @@ -268,7 +268,6 @@ - On occasions the device was not closed properly and due to firmware issues needs to reset. - If set to true, the device will reset prior to usage. - For example: `initial_reset:=true` -- ****_frame_id**, ****_optical_frame_id**, **aligned_depth_to_**_frame_id**: Specify the different frame_id for the different frames. Especially important when using multiple cameras. - **base_frame_id**: defines the frame_id all static transformations refers to. - **odom_frame_id**: defines the origin coordinate system in ROS convention (X-Forward, Y-Left, Z-Up). pose topic defines the pose relative to that system.