From e4c511cbf87d4f31142d3db80d0882a175133f28 Mon Sep 17 00:00:00 2001 From: LucasHaug Date: Tue, 21 Mar 2023 15:50:04 +0000 Subject: [PATCH] Add print pairs to parameter bridge Signed-off-by: LucasHaug --- src/parameter_bridge.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/parameter_bridge.cpp b/src/parameter_bridge.cpp index b781209a..22626a8f 100644 --- a/src/parameter_bridge.cpp +++ b/src/parameter_bridge.cpp @@ -258,6 +258,8 @@ bool parse_command_options( ss << std::endl; ss << "Options:" << std::endl; ss << " -h, --help: This message." << std::endl; + ss << " --print-pairs: Print a list of the supported ROS 2 <=> ROS 1 conversion pairs."; + ss << std::endl; ss << " --topics: Name of the parameter that contains the list of topics to bridge."; ss << std::endl; ss << " --services-1-to-2: Name of the parameter that contains the list of services to bridge from ROS 1 to ROS 2."; @@ -270,6 +272,28 @@ bool parse_command_options( return false; } + if (ros1_bridge::get_option_flag(args, "--print-pairs")) { + auto mappings_2to1 = ros1_bridge::get_all_message_mappings_2to1(); + if (mappings_2to1.size() > 0) { + printf("Supported ROS 2 <=> ROS 1 message type conversion pairs:\n"); + for (auto & pair : mappings_2to1) { + printf(" - '%s' (ROS 2) <=> '%s' (ROS 1)\n", pair.first.c_str(), pair.second.c_str()); + } + } else { + printf("No message type conversion pairs supported.\n"); + } + mappings_2to1 = ros1_bridge::get_all_service_mappings_2to1(); + if (mappings_2to1.size() > 0) { + printf("Supported ROS 2 <=> ROS 1 service type conversion pairs:\n"); + for (auto & pair : mappings_2to1) { + printf(" - '%s' (ROS 2) <=> '%s' (ROS 1)\n", pair.first.c_str(), pair.second.c_str()); + } + } else { + printf("No service type conversion pairs supported.\n"); + } + return false; + } + if (!ros1_bridge::get_option_value(args, "--topics", topics_parameter_name, true)) { printf("Using default topics parameter name: %s\n", topics_parameter_name); }