[ROS2] Set namespace and node name from launch file in rclpy
Hi, how to set namespace and node name from the launch file in rclpy?
Sample Launch File:
my_node = Node(
package='my_pkg',
namespace='my_ns',
executable='my_talker',
name='my_name',
output='screen',
)
Sample Node:
class Talker(Node):
def __init__(self):
super().__init__('talker')
self.i = 0
self.pub = self.create_publisher(String, 'chatter', 10)
timer_period = 1.0
self.tmr = self.create_timer(timer_period, self.timer_callback)
From the API, I can see that node_name
and namespace
are provided as input to the node. Furthermore, self.get_name()
and self.get_namespace()
returns the name and namespace of the node, respectively.
Therefore, my question is how to set namespace and node name from the launch file in rclpy?