Skip to content

Commit

Permalink
Merge pull request #3 from knorth55/eus10_state_aware_remove_rosargs
Browse files Browse the repository at this point in the history
(roseus_bt) add remove ros args in parse_command_line
  • Loading branch information
Affonso-Gui committed Nov 21, 2022
2 parents 7f8a41f + ee9298e commit 4d8793a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion roseus_bt/include/roseus_bt/command_line_argument_mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <fmt/format.h>
#include <boost/program_options.hpp>
#include <behaviortree_cpp_v3/bt_factory.h>
#include <ros/init.h>


namespace roseus_bt
Expand All @@ -19,6 +20,10 @@ bool parse_command_line(int argc, char** argv,
const std::string& program_description,
std::map<std::string, std::string>& argument_map)
{

std::vector<std::string> argv_vec;
ros::removeROSArgs(argc, argv, argv_vec);

std::string example_description =
fmt::format("example:\n {0} --arg var1 hello --arg var2 world\n", argv[0]);

Expand All @@ -29,7 +34,9 @@ bool parse_command_line(int argc, char** argv,
"Initial blackboard variable-value pairs");

po::positional_options_description pos;
po::parsed_options parsed_options = po::command_line_parser(argc, argv).
// when initializing from std::vector, we need to drop the program name
po::parsed_options parsed_options = po::command_line_parser(
std::vector<std::string>(argv_vec.begin() + 1, argv_vec.end())).
options(desc).
positional(pos).
style(po::command_line_style::unix_style ^ po::command_line_style::allow_short).
Expand Down

0 comments on commit 4d8793a

Please sign in to comment.