[ROS2] How to describe remap and parameter in python format launch

<!-# [ROS2] How to describe remap and parameter in python format launch->

Introduction

From ROS2, you can write launch files in python, but I haven't found many examples other than tutorials yet. So, this time, I searched for remapping and how to use parameters from Github (ros2 / launch_ros) of ROS2.

testing environment

How to describe remap and parameter

import launch
import launch_ros.actions

def generate_launch_description():
    return launch.LaunchDescription([
        launch_ros.actions.Node(
            package='demo_parameters_cpp',
            node_executable='string_talker',
            output='screen',
            node_name='string_talker',
            remappings=[('string_topic', '/talker')],
            parameters=[{'string_param':'changed'}]
        )
    ])

remap

Specify remappings in argument and add tuples to the list. Tuples are described by (topic name before remap, topic name after remap).

parameter

Specify parameters for argument and put the dictionary in the list. To specify multiple parameters, write as [{parameter1: value1, parameter2: value2, ...}].

If you want to read as a yaml file parameters=['parameter_dir/parameter.yaml'] You can set the parameter from the yaml file by writing like.

reference

ros2/launch_ros

Related article

-[ROS2] How to describe remap and parameters in xml format launch

Recommended Posts

[ROS2] How to describe remap and parameter in python format launch
How to use is and == in Python
[ROS2] How to play a bag file with python format launch
How to plot autocorrelation and partial autocorrelation in python
[Python] How to sort dict in list and instance in list
How to develop in Python
How to swap elements in an array in Python, and how to reverse an array.
[Introduction to Udemy Python 3 + Application] 36. How to use In and Not
[TF] How to load / save Model and Parameter in Keras
How to execute external shell scripts and commands in python
How to log in to AtCoder with Python and submit automatically
[Python] How to do PCA in Python
How to use SQLite in Python
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use PubChem in Python
How to handle Japanese in Python
Determine the date and time format in Python and convert to Unixtime
How to install OpenCV on Cloud9 and run it in Python
How to use functions in separate files Perl and Python versions
Difference in how to write if statement between ruby ​​and python
How to display bytes in the same way in Java and Python
How to package and distribute Python scripts
How to access environment variables in Python
How to dynamically define variables in Python
How to install and use pandas_datareader [Python]
How to do R chartr () in Python
[Itertools.permutations] How to put permutations in Python
How to work with BigQuery in Python
How to get a stacktrace in python
How to display multiplication table in python
How to extract polygon area in Python
How to check opencv version in python
python: How to use locals () and globals ()
How to switch python versions in cloud9
How to adjust image contrast in Python
How to use __slots__ in Python class
How to dynamically zero pad in Python
[Python] How to calculate MAE and RMSE
How to use Python zip and enumerate
How to use regular expressions in Python
How to convert DateTimeField format in Django
How to display Hello world in python
How to write Ruby to_s in Python
How to write the correct shebang in Perl, Python and Ruby scripts
How to get the date and time difference in seconds with python
How to get a value from a parameter store in lambda (using python)
How to format a list of dictionaries (or instances) well in Python
How to stop a program in python until a specific date and time
format in python
How to use the C library in Python
How to receive command line arguments in Python
How to clear tuples in a list (Python)
How to embed a variable in a python string
How to implement Discord Slash Command in Python
[Python] How to change the date format (display format)
Summary of how to import files in Python 3
How to simplify restricted polynomial fit in python
How to use Python Image Library in python3 series
How to implement shared memory in Python (mmap.mmap)