From f69d3f8b1a6aaf2282148d99b7aff5594c27ff44 Mon Sep 17 00:00:00 2001 From: Ruichao Wu <54799760+ipa-rwu@users.noreply.github.com> Date: Fri, 22 Mar 2024 17:16:55 +0100 Subject: [PATCH] Added support for custom parameter bridge node names #402 --- src/parameter_bridge.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/parameter_bridge.cpp b/src/parameter_bridge.cpp index a95d49a4..9af8ca9e 100644 --- a/src/parameter_bridge.cpp +++ b/src/parameter_bridge.cpp @@ -231,9 +231,6 @@ rclcpp::QoS qos_from_params(XmlRpc::XmlRpcValue qos_params) int main(int argc, char * argv[]) { - // ROS 1 node - ros::init(argc, argv, "ros_bridge"); - ros::NodeHandle ros1_node; // ROS 2 node rclcpp::init(argc, argv); @@ -243,6 +240,20 @@ int main(int argc, char * argv[]) std::list service_bridges_1_to_2; std::list service_bridges_2_to_1; + if (argc == 4) { + std::string argv_s = argv[argc-1]; + + std::string delimiter = "__node:="; + argv_s.erase(0, delimiter.length()); + argv_s.insert(0, "__name:="); + strcpy(argv[0], argv_s.c_str()); + argc = 1; + } + + // ROS 1 node + ros::init(argc, argv, "ros_bridge"); + ros::NodeHandle ros1_node; + // bridge all topics listed in a ROS 1 parameter // the topics parameter needs to be an array // and each item needs to be a dictionary with the following keys;