ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I found a solution in the ROS 2 nav stack where in the constructor of a node there is the following
Costmap2DROS::Costmap2DROS(
const std::string & name,
const std::string & parent_namespace,
const std::string & local_namespace)
: nav2_util::LifecycleNode(name, "", true,
// NodeOption arguments take precedence over the ones provided on the command line
// use this to make sure the node is placed on the provided namespace
rclcpp::NodeOptions().arguments({
"--ros-args", "-r", std::string("__ns:=") +
nav2_util::add_namespaces(parent_namespace, local_namespace),
"--ros-args", "-r", name + ":" + std::string("__node:=") + name
})),
See https://github.com/ros-planning/navigation2/blob/main/nav2_costmap_2d/src/costmap_2d_ros.cpp#L61
this does not look the most elegant solution, but it's definitely working.
2 | No.2 Revision |
I found a solution in the ROS 2 nav stack where in the constructor of a node there is the following
Costmap2DROS::Costmap2DROS(
const std::string & name,
const std::string & parent_namespace,
const std::string & local_namespace)
: nav2_util::LifecycleNode(name, "", true,
// NodeOption arguments take precedence over the ones provided on the command line
// use this to make sure the node is placed on the provided namespace
rclcpp::NodeOptions().arguments({
"--ros-args", "-r", std::string("__ns:=") +
nav2_util::add_namespaces(parent_namespace, local_namespace),
"--ros-args", "-r", name + ":" + std::string("__node:=") + name
})),
See https://github.com/ros-planning/navigation2/blob/main/nav2_costmap_2d/src/costmap_2d_ros.cpp#L61https://github.com/ros-planning/navigation2/blob/c337ac22e6af2b81f7b515a201a0e553084887e3/nav2_costmap_2d/src/costmap_2d_ros.cpp#L61-L74
this does not look the most elegant solution, but it's definitely working.