ROS(ROS2)- Action - パッケージ


クラウディア 


1. 概要
2. パッケージ作成
3. 備考

1. 概要

 以下、「Ubuntu 24.04」の環境で。

2. パッケージ作成

 ワークスペース名を、「workspace」として、まずワークスペースのエリアを確保します。

mkdir -pv ~/workspace/src

3. パッケージ作成

 メッセージを定義するパッケージを「my_interfaces」として、パッケージを作成します。

cd ~/workspace/src

ros2 pkg create --build-type ament_cmake my_interfaces
 下記のようなメッセージが表示されます。

going to create a new package
package name: my_interfaces
destination directory: /home/hogehoge/workspace/src
package format: 3
version: 0.0.0
description: TODO: Package description
maintainer: ['hogehoge <hogehoge@todo.todo>']
licenses: ['TODO: License declaration']
build type: ament_cmake
dependencies: []
creating folder ./my_interfaces
creating ./my_interfaces/package.xml
creating source and include folder
creating folder ./my_interfaces/src
creating folder ./my_interfaces/include/my_interfaces
creating ./my_interfaces/CMakeLists.txt

[WARNING]: Unknown license 'TODO: License declaration'.  This has been set in the package.xml, but no LICENSE file has been created.
It is recommended to use one of the ament license identifiers:
Apache-2.0
BSL-1.0
BSD-2.0
BSD-2-Clause
BSD-3-Clause
GPL-3.0-only
LGPL-3.0-only
MIT
MIT-0
 プログラムを定義するパッケージを「my_action」として、パッケージを作成します。

ros2 pkg create --build-type ament_python my_action --dependencies my_interfaces
 下記のようなメッセージが表示されます。

going to create a new package
package name: my_action
destination directory: /home/hogehoge/workspace/src
package format: 3
version: 0.0.0
description: TODO: Package description
maintainer: ['hogehoge <hogehoge@todo.todo>']
licenses: ['TODO: License declaration']
build type: ament_python
dependencies: ['my_interfaces']
creating folder ./my_action
creating ./my_action/package.xml
creating source folder
creating folder ./my_action/my_action
creating ./my_action/setup.py
creating ./my_action/setup.cfg
creating folder ./my_action/resource
creating ./my_action/resource/my_action
creating ./my_action/my_action/__init__.py
creating folder ./my_action/test
creating ./my_action/test/test_copyright.py
creating ./my_action/test/test_flake8.py
creating ./my_action/test/test_pep257.py

[WARNING]: Unknown license 'TODO: License declaration'.  This has been set in the package.xml, but no LICENSE file has been created.
It is recommended to use one of the ament license identifiers:
Apache-2.0
BSL-1.0
BSD-2.0
BSD-2-Clause
BSD-3-Clause
GPL-3.0-only
LGPL-3.0-only
MIT
MIT-0

3. 備考

 本ページは、下記のサイトを参考にさせていただきました。
Creating an action — ROS 2 Documentation: Foxy documentation」
「Understanding actions — ROS 2 Documentation: Rolling documentation」
「Writing an action server and client (C++) — ROS 2 Documentation: Foxy documentation

AbemaTV 無料体験