ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I think you need to do this:
ros2 run robot_control vehicle --ros-args -r __ns:=/drone_0 --log-level drone_0.vehicle:=DEBUG
To get it to work.
To test this, I modified the talker
demo in the demo_nodes_cpp
package, like this:
diff --git a/demo_nodes_cpp/src/topics/talker.cpp b/demo_nodes_cpp/src/topics/talker.cpp
index 30f97a0..01756d0 100644
--- a/demo_nodes_cpp/src/topics/talker.cpp
+++ b/demo_nodes_cpp/src/topics/talker.cpp
@@ -44,6 +44,7 @@ public:
{
msg_ = std::make_unique<std_msgs::msg::String>();
msg_->data = "Hello World: " + std::to_string(count_++);
+ RCLCPP_DEBUG(this->get_logger(), "Publishing: '%s'", msg_->data.c_str());
RCLCPP_INFO(this->get_logger(), "Publishing: '%s'", msg_->data.c_str());
// Put the message into a queue to be processed by the middleware.
// This call is non-blocking.
And to reproduce what you were trying to do, I did this:
$ ros2 run demo_nodes_cpp talker --ros-args -r __ns:=/drone_0 --log-level talker:=DEBUG
[DEBUG] [1625186542.873545147] [talker]: Load library libtopics_library.so
[DEBUG] [1625186542.875355119] [talker]: Instantiate class rclcpp_components::NodeFactoryTemplate<demo_nodes_cpp::Talker>
1625186542.876201 [87] talker: using network interface enp0s5 (udp/10.211.55.6) selected arbitrarily from: enp0s5, docker0
[INFO] [1625186543.880863775] [drone_0.talker]: Publishing: 'Hello World: 1'
...
$ ros2 run demo_nodes_cpp talker --ros-args -r __ns:=/drone_0 --log-level drone_0.talker:=DEBUG
1625186556.836825 [87] talker: using network interface enp0s5 (udp/10.211.55.6) selected arbitrarily from: enp0s5, docker0
[DEBUG] [1625186557.841640933] [drone_0.talker]: Publishing: 'Hello World: 1'
[INFO] [1625186557.841909375] [drone_0.talker]: Publishing: 'Hello World: 1'
Note that even though the node name is /drone_0/talker
(as reported by ros2 node list
), the logger name is separated by .
instead of /
.