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

Adapt to '--ros-args ... [--]'-based ROS args extraction #816

Merged
merged 7 commits into from
Aug 7, 2019
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
Prev Previous commit
Next Next commit
Only add implicit --ros-args flag if not present already.
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
hidmic committed Aug 6, 2019
commit 68807d50d0ca44a0c9fe7fc36880c449d034291a
17 changes: 13 additions & 4 deletions rclcpp/src/rclcpp/node_options.cpp
Original file line number Diff line number Diff line change
@@ -93,11 +93,20 @@ NodeOptions::get_rcl_node_options() const
int c_argc = 0;
std::unique_ptr<const char *[]> c_argv;
if (!this->arguments_.empty()) {
c_argc = static_cast<int>(this->arguments_.size()) + 1;
auto it = std::find(
this->arguments_.cbegin(), this->arguments_.cend(), RCL_ROS_ARGS_FLAG);

c_argc = static_cast<int>(this->arguments_.size());
if (it == this->arguments_.cend()) c_argc += 1;

c_argv.reset(new const char *[c_argc]);
c_argv[0] = RCL_ROS_ARGS_FLAG;
for (std::size_t i = 0; i < this->arguments_.size(); ++i) {
c_argv[i + 1] = this->arguments_[i].c_str();

std::size_t i = 0;
if (it == this->arguments_.cend()) {
c_argv[i++] = RCL_ROS_ARGS_FLAG;
}
for (std::size_t j = 0; j < this->arguments_.size(); ++i, ++j) {
c_argv[i] = this->arguments_[j].c_str();
}
}