Parameters from yaml file from launch.py not passed to node
Hello,
I am trying to create a node to control a robot using joystick and want to pass parameters such as max speed, rotational speed and etc from a parameter file.
For this project I am running ROS2 foxy on ubuntu 20.04 system.
I added a teleop_joy.yaml file under 'my_teleop/param' and added to the package.
teleop_joy_node: ros__parameters:
test:
array: ['1','2','3']
max_fwd_m_s: 0.23
max_rev_m_s: 0.20
max_deg_s: 20.0
use_sim_time: true
I tried to read this file in my launch.py as below. This launch file run teleop_joy and joy_node simultaneously to control a robot.
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration
from launch.substitutions import TextSubstitution
from launch_ros.actions import Node
def generate_launch_description():
teleop_joy_params = LaunchConfiguration(
'my_teleop_joy_parameter',
default=os.path.join(
get_package_share_directory('my_teleop'),
'param',
'teleop_joy.yaml'
)
)
joy_config = LaunchConfiguration('joy_config')
joy_dev = LaunchConfiguration('joy_dev')
return LaunchDescription([
DeclareLaunchArgument(
'my_teleop_joy_parameter',
default_value=teleop_joy_params
),
Node(
package='my_teleop',
namespace='',
executable='teleop_joy',
name='teleop_joy_node',
output='screen',
emulate_tty=True,
parameters=[teleop_joy_params],
),
DeclareLaunchArgument(
'joy_config',
default_value='xbox'
),
DeclareLaunchArgument(
'joy_dev',
default_value='/dev/input/js0'
),
DeclareLaunchArgument(
'config_filepath',
default_value=[
TextSubstitution(text=os.path.join(
get_package_share_directory(
'teleop_twist_joy'),
'config', '')),
joy_config, TextSubstitution(text='.config.yaml')
]
),
Node(
package='joy',
executable='joy_node',
name='joy_node',
parameters=[{
'dev': joy_dev,
'deadzone': 0.3,
'autorepeat_rate': 20.0,
}]
)
])
I see both node is running however I could not see parameters except "use_sim_time" I checked this by running
$ ros2 param dump /teleop_joy_node --print
/teleop_joy_node:
ros__parameters:
use_sim_time: true
I double check this by changing use_sim_time to false in yaml file and it does reveals the changed parameter. I don't know why other parameters not showing. Any suggestions or comments would be much appreciated.