本記事では nav2_bringup をコピーして custom_nav2_bringup というオリジナルパッケージを作成し、設定をカスタマイズしていきます。
※ 本記事はすでにこの記事の内容を実施していることを前提としています。
PC 環境
- Thinkpad X1 Intel Core i7
- Ubuntu 24.04
準備
この github repository を pull して、Docker コンテナを立ち上げ、コンテナ内に入りましょう。
$ git clone git@github.com:remmaTech12/ros2_nav2.git
$ git checkout article_7458
$ docker compose up -d --build
$ docker exec -it ros2_nav2 bash
コンテナの中で以下を実行します。
/workspace& mkdir -p src
/workspace$ cp -r /opt/ros/humble/share/nav2_bringup src
/workspace$ cd src
/workspace/src$ mv nav2_bringup custom_nav2_bringup
/workspace/src$ cd custom_nav2_bringup
リネームした custom_nav2_bringup ディレクトリの中に LICENCE というファイルを作り、以下を入力して保存します。
Copyright Remma
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
/workspace/src/custom_nav2_bringup に CMakeLists.txt ファイルを作成し、以下を記載します。
cmake_minimum_required(VERSION 3.5)
project(custom_nav2_bringup)
find_package(ament_cmake REQUIRED)
install(DIRECTORY launch params maps urdf rviz worlds
DESTINATION share/${PROJECT_NAME}
)
ament_package()
package.xml でパッケージ名を nav2_bringup から custom_nav2_bringup に変更します。
- <name>nav2_bringup</name>
+ <name>custom_nav2_bringup</name>
tb3_simulation_launch.py を修正し、share ディレクトリ(設定ファイル等を配置するディレクトリ)を変更します。これにより、/workspace/install/custom_nav2_bringup/share/custom_nav2_bringup 配下の設定ファイルがロードされます。
- bringup_dir = get_package_share_directory('nav2_bringup')
+ bringup_dir = get_package_share_directory('custom_nav2_bringup')
この状態で Docker コンテナ内から以下のコマンドを叩くと TurtleBot シミュレーションが起動することを確かめられると思います。パッケージ名はあえて、custom_nav2_bringup(今回コピーしてリネームしたパッケージ名)にしています。
/workspace$ cd /workspace
/workspace$ colcon build
/workspace$ source install/setup.bash
/workspace$ ros2 launch custom_nav2_bringup tb3_simulation_launch.py headless:=False
ライセンスについて
nav2 の各パッケージのライセンスに関してはこちらに明記されている通り、package.xml に記載されているそうです。
Portions of this repository are available under one of the following licenses
SPDX-ID:
* LGPL-2.1-or-later
* Apache-2.0
* BSD-3-Clause
* Apache-2.0 AND BSD-3-ClausePlease see the package.xml file for each package to see the specific license for that package.
https://github.com/ros-navigation/navigation2/blob/main/LICENSE
私達が編集する nav2_bringup パッケージを見てみると、Apache-2.0 ライセンスとなっていることがわかります(GitHub link)。
<license>Apache-2.0</license>
このライセンスは、こちらの記事にも記載されている通り、再頒布が許可されたライセンスです。今回のプロジェクトでは以下のように簡単に NOTICE ファイルを作成して、変更点を明記しておきました。
This project includes software developed by Remma.
Modifications:
- 2025.02-24: Change the package name.
ちょっとした変更を加える
/workspace/src/custom_nav2_bringup/params/nav2_params.yaml のパラメータにちょっとした変更を加えた上で、変更が反映されているかを確認します。local_costmap の inflation_radius を小さくするという変更を行いました。
@@ -197,7 +197,7 @@ local_costmap:
inflation_layer:
plugin: "nav2_costmap_2d::InflationLayer"
cost_scaling_factor: 3.0
- inflation_radius: 0.55
+ inflation_radius: 0.15


実際に inflation_radius が小さくなったことが確かめられました!
コメント