Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter ROS arguments before gflags parsing #453

Merged
merged 3 commits into from
Nov 3, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions ros_gz_sim/src/create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,23 @@ DEFINE_double(Y, 0, "Yaw component of initial orientation, in radians.");
// If these are not needed, just use the `gz service` command line instead.
int main(int _argc, char ** _argv)
{
rclcpp::init(_argc, _argv);
auto filtered_arguments = rclcpp::init_and_remove_ros_arguments(_argc, _argv);
auto ros2_node = rclcpp::Node::make_shared("ros_gz_sim");

int filtered_argc = filtered_arguments.size();
std::vector<char *> filtered_argv;

for (auto arg: filtered_arguments)
{
filtered_argv.push_back(arg.c_str());
}

gflags::AllowCommandLineReparsing();
gflags::SetUsageMessage(
R"(Usage: create -world [arg] [-file FILE] [-param PARAM] [-topic TOPIC]
[-string STRING] [-name NAME] [-allow_renaming RENAMING] [-x X] [-y Y] [-z Z]
[-R ROLL] [-P PITCH] [-Y YAW])");
gflags::ParseCommandLineFlags(&_argc, &_argv, true);
gflags::ParseCommandLineFlags(&filtered_argc, &filtered_argv.data(), true);

// World
std::string world_name = FLAGS_world;
Expand Down
Loading