[ROS2] what is different between DeclareLaunchArgument and LaunchConfiguration
I had tested ros2 launch with arguments.
The arguments are successfully implemented using only set LaunchConfiguration
exclude DeclareLaunchArgument
.
For example, attached launch files worked excluding DeclareLaunchArgument
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.substitutions import LaunchConfiguration, EnvironmentVariable
from launch.actions import DeclareLaunchArgument
from launch_ros.actions import Node
TURTLEBOT3_MODEL = os.environ['TURTLEBOT3_MODEL']
def generate_launch_description():
use_sim_time = LaunchConfiguration('use_sim_time', default='false')
urdf_file_name = 'turtlebot3_' + TURTLEBOT3_MODEL + '.urdf'
print("urdf_file_name : {}".format(urdf_file_name))
urdf = os.path.join(get_package_share_directory('turtlebot3_description'), 'urdf', urdf_file_name)
return LaunchDescription([
#DeclareLaunchArgument(
# 'use_sim_time',
# default_value='false',
# description='Use simulation (Gazebo) clock if true'),
Node(
package='robot_state_publisher',
node_executable='robot_state_publisher',
node_name='robot_state_publisher',
output='screen',
parameters=[{' use_sim_time': use_sim_time}],
arguments=[urdf]),
])
However, most examples of ros2 launch are included DeclareLaunchArgument
when user want to use arguments.
So, my main questions is What is different btw LaunchConfiguration
and DeclareLaunchArgument
?