10
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【ROS2】python形式のlaunchでremapとparameterを記述する方法

Last updated at Posted at 2020-02-24

はじめに

ROS2からpythonでlaunchファイルを記述できるようになりましたが,まだチュートリアル以外の例があまり見つかりません.そこで,今回はROS2のGithub(ros2/launch_ros)からリマップとパラメータの使い方を探しました.

テスト環境

  • Ubuntu 18.04
  • ROS Eloquent

remapと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

argumentにremappingsを指定し,タプルをリストに連ねていきます.タプルは(remap前のtopic名, remap後のtopic名)で記述します.

parameter

argumentにparametersを指定し,辞書をリストの中に置きます.複数のパラメータを指定する場合は[{parameter1:value1, parameter2:value2, ... }]のように記述します.

yamlファイルで読み込みたい場合は
parameters=['parameter_dir/parameter.yaml']
のように書くとyamlファイルからparameterを設定できます.

参考

ros2/launch_ros

関連記事

10
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?