Skip to content

Commit

Permalink
Add print pairs to parameter bridge
Browse files Browse the repository at this point in the history
Signed-off-by: LucasHaug <[email protected]>
  • Loading branch information
LucasHaug committed Jul 7, 2023
1 parent daf83db commit e4c511c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/parameter_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
Expand All @@ -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);
}
Expand Down

0 comments on commit e4c511c

Please sign in to comment.