Using a launch argument as python variable variable
I would like to be able to use a launch argument as a python variable. What i'm trying to do in this script is load a different model each time by passing it as an argument when i use the launch file. The problem is that i cant get the value of the argument
in the script below the string 'pelican' should be replaced each time i run the launch file with the name of the model i want to view.
def generate_launch_description():
package_dir = get_package_share_directory('rotors_description')
xacro_file = os.path.join(package_dir,'urdf','pelican.xacro')
rviz_file = os.path.join(package_dir,'config.rviz')
robot_description_raw = xacro.process_file(xacro_file,mappings=
{'namespace':'pelican'}).toxml()
robot_state_publisher = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher',
output='screen',
parameters=[{'robot_description': robot_description_raw}]
)
joint_state_publisher = Node(
package='joint_state_publisher_gui',
executable='joint_state_publisher_gui',
name='joint_state_publisher_gui',
output='screen'
)
rviz = Node(
package='rviz2',
executable='rviz2',
name='rviz2',
arguments=['-d',rviz_file],
output='screen')
return LaunchDescription([
robot_state_publisher,
joint_state_publisher,
rviz
])