0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ROS2 launchファイルの書き方

Last updated at Posted at 2024-11-22

状況

とりあえずlaunchファイルを書いて認識させたいとき,どうすればいいか忘れた.

やり方

参考
Launch ファイルによる複数プログラムの同時起動
から抜粋した.

1. launchディレクトリが無ければつくる.
2. setup.pyのインポート部分とdeta_filesに以下を追加

setup.py
import os
from glob import glob
setup.py
    data_files=[
        (),
        (os.path.join('share', package_name), glob('launch/*_launch.py'))
    ],

3. lauchディレクトリにlaunchファイルを追加する.
launchファイルの例

hoge.launch.py
from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    return LaunchDescription([
        Node(
            package='turtlesim',
            executable='turtlesim_node',
            name='turtlesim'
        ),
        Node(
            package='ros_practice',
            executable='autonomous_controller',
            name='autonomous_controller',
            remappings=[
                ('/pose', '/turtle1/pose'),
                ('/cmd_vel', '/turtle1/cmd_vel'),
            ]
        )
    ])

最後に

学習中の備忘録なので参考程度に.

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?