[ROS2] Any idea on how to pass parameters (YAML) to a Xacro file via launch python script?
In my launch
python script I can load and pass parameters from a .yaml
file into my code without any problem:
from ament_index_python.packages import get_package_share_path
from launch_ros.parameter_descriptions import ParameterValue
from launch_ros.actions import Node
from launch.substitutions import Command, LaunchConfiguration
from launch.actions import DeclareLaunchArgument, ExecuteProcess
from launch import LaunchDescription
import os
def generate_launch_description():
package_p = get_package_share_path('my_pkg')
urdf_path = os.path.join(package_p, 'my_robot.urdf')
config_path = os.path.join(package_p, 'my_params.yaml')
prog = Node(package = "my_pkg",
executable = "my_pkg",
output = "screen",
parameters = [config_path])
return LaunchDescription([prog])
The parameters defined in the my_params.yaml
file are passed to my node.
The problem is that I need to pass the same parameters to my xacro file, where I defined my robot.
<?xml version="1.0"?>
<robot name="my_robot" xmlns:xacro="http://www.ros.org/wiki/xacro">
<xacro:arg name="first_parameter"/>
</robot>
As you can see I don't know how to "catch" the parameters into the xacro/urdf file.
Do you have any idea?