Skip to content

Commit c8be6b6

Browse files
KuraZuzuYusukeKatoKuwamai
authored
Waypointによるナビゲーションサンプルの追加 (#16)
* waypointのサンプルプログラムとlaunchファイルを追加 * 初期位置のwとzを入れ替え * maintainerを修正 * package.xmlのmaintainerを修正 * コードフォーマットを修正 * README整備 * waypointサンプルの説明や文体を修正 * 見栄えのために改行を追加 * テーブルコンテンツやサンプル項目を修正 * ContributingをTable of Contentsに追加 * waypointの指定を関数からdegreeで指定するように変更 * 新規のルールにしたがってフォーマット * モジュールのimport順を修正 * コード修正にあたり、READMEを修正 * SLAMのサンプルをraspimouse_slamのREADME内に移動 * raspimouse_navigationパッケージのREADMEを更新 * WaypointSampleのREADMEを追加 * 目次を終始絵 * エスケープシーケンスを追加 * 過剰なリンクを削除して目次も整理 * 不要な目次の項目を削除 * リンクミスを修正 * 画像の改行を修正 * waypointフォロワーに変更してrvizの画角を変更 * waypoint指定のプログラムを整理 * コメントを追加 * メタデータや説明項目を修正 * fixed code format * 動作変更時の不具合を修正 * 再フォーマット修正 * レビューに沿って文章中の表現やtypoの修正 * コードブロックの指定ミスやtypoを修正 * リポジトリトップのREADMEのtypoなどを修正 * Quick Start 内の表現を修正 * raspimouse_slamの表現を修正 * リンクや表記ゆれを修正 * パッケージ動作の画像と動画を追加 * fixed typo Co-authored-by: YusukeKato <YusukeKato@users.noreply.github.com> * エディタの設定ファイルの追跡を削除 * 冗長な説明を削除 * Waypointで指定するPoseStampedにz=0を明示するように修正 Co-authored-by: YusukeKato <YusukeKato@users.noreply.github.com> * ファイルパスのリンク修正 Co-authored-by: YusukeKato <YusukeKato@users.noreply.github.com> * navigationのリンクを修正 * Waypointの座標やタイムアウトの設定を修正しました。 * WaypointサンプルのREADME内での説明を改良 * Navigation2の表記ゆれをNav2に統一 Co-authored-by: YusukeKato <YusukeKato@users.noreply.github.com> * Copyrightの年を修正 Co-authored-by: Kuwamai <kuwagata@rt-net.jp> * 章の階層偏光 Co-authored-by: Kuwamai <kuwagata@rt-net.jp> * 回りくどい言い回しを修正 Co-authored-by: Kuwamai <kuwagata@rt-net.jp> * Waypointを姿勢という言葉で表現するように偏光 Co-authored-by: Kuwamai <kuwagata@rt-net.jp> * Noteの項目を使用 Co-authored-by: Kuwamai <kuwagata@rt-net.jp> * 指示語を明確な表現に変更 Co-authored-by: Kuwamai <kuwagata@rt-net.jp> * ゲームパッドの注釈を追加 * raspimouse_navigation_examplesの概要を修正 * ゲームパッドの冒頭説明を削除 * <br>を削除 * 存在しない見出しの削除 * サンプルの概要を追加 * typoなどを修正 * サンプルプログラムの概要説明を修正 * Usageの削除と、その周辺を整備 * 冗長な文章を修正 * Nav2のリンク追加 * 実機とGazebo両方の手順を追加 * SLAMに実機とGazeboの手順を追加 * 過剰な改行を削除 * Navigationの起動を実行を分けた * 目次追加 * リンクミス修正 * 不要な太字部分を削除しました。 --------- Co-authored-by: YusukeKato <YusukeKato@users.noreply.github.com> Co-authored-by: Kuwamai <kuwagata@rt-net.jp>
1 parent 59e4fd4 commit c8be6b6

24 files changed

+881
-219
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,5 @@ Temporary Items
102102
# .nfs files are created when an open file is removed but is still being accessed
103103
.nfs*
104104

105-
105+
# editor's setting files
106+
.vscode/

README.md

Lines changed: 94 additions & 159 deletions
Large diffs are not rendered by default.

raspimouse_navigation/README.md

Lines changed: 120 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,122 @@
11
# raspimouse_navigation
22

3-
パラメータについては以下を参照すること。
4-
- [Navigation2:初めてのロボットセットアップガイド](https://docs.nav2.org/setup_guides/index.html)
5-
- [Navigation2:パラメータチューニング方法](https://docs.nav2.org/tuning/index.html)
6-
- [Navigation2:パラメータ一覧](https://docs.nav2.org/configuration/index.html)
3+
[Nav2](https://docs.nav2.org/)パッケージを使用してRaspberry Pi Mouseを自律移動させるパッケージです。
4+
5+
## Table of Contents
6+
7+
- [raspimouse\_navigation](#raspimouse_navigation)
8+
- [Table of Contents](#table-of-contents)
9+
- [Navigation](#navigation)
10+
- [Setup](#setup)
11+
- [Using Raspberry Pi Mouse](#using-raspberry-pi-mouse)
12+
- [Using Gazebo](#using-gazebo)
13+
- [Launching Navigation](#launching-navigation)
14+
- [Using Raspberry Pi Mouse](#using-raspberry-pi-mouse-1)
15+
- [Using Gazebo](#using-gazebo-1)
16+
- [Running Navigation](#running-navigation)
17+
- [Parameters](#parameters)
18+
19+
## Navigation
20+
21+
<img src=https://rt-net.github.io/images/raspberry-pi-mouse/navigation_ros2_with_raspimouse_model.png width=500 />
22+
23+
> [!NOTE]
24+
> サンプルの実行には、Raspberry Pi MouseとRemote PCが同じネットワーク上で同じ`ROS_DOMAIN_ID`を指定している必要があります。
25+
26+
### Setup
27+
28+
#### Using Raspberry Pi Mouse
29+
30+
Raspberry Pi Mouse上で、次のコマンドを実行します。Raspberry Pi MouseのモータとLiDARを制御するためのノードを起動します。
31+
32+
```sh
33+
# RPLIDAR A1の場合
34+
ros2 launch raspimouse_navigation robot_navigation.launch.py lidar:=rplidar
35+
# LDS-01の場合
36+
ros2 launch raspimouse_navigation robot_navigation.launch.py lidar:=lds
37+
# URG-04LX-UG01の場合
38+
ros2 launch raspimouse_navigation robot_navigation.launch.py lidar:=urg lidar_port:=/dev/ttyACM0
39+
```
40+
41+
#### Using Gazebo
42+
43+
以下のコマンドを実行し、Gazebo上でRaspberry Pi Mouseを起動します。Gazebo上での実行には、[raspimouse_sim](https://github.com/rt-net/raspimouse_sim/tree/jazzy)パッケージのインストールが必要です。
44+
45+
```sh
46+
# RPLIDAR A1の場合
47+
ros2 launch raspimouse_gazebo raspimouse_with_lakehouse.launch.py lidar:=rplidar
48+
# LDS-01の場合
49+
ros2 launch raspimouse_gazebo raspimouse_with_lakehouse.launch.py lidar:=lds
50+
# URG-04LX-UG01の場合
51+
ros2 launch raspimouse_gazebo raspimouse_with_lakehouse.launch.py lidar:=urg
52+
```
53+
54+
### Launching Navigation
55+
56+
自己位置推定と経路生成用のノードを起動し、RVizを立ち上げます。
57+
引数のmapパラメータには、SLAMで生成した地図(.yamlファイル)を指定してください。
58+
59+
#### Using Raspberry Pi Mouse
60+
61+
Remote PC上で、次のコマンドを実行します。
62+
63+
```sh
64+
ros2 launch raspimouse_navigation pc_navigation.launch.py map:=$HOME/MAP_NAME.yaml
65+
```
66+
67+
#### Using Gazebo
68+
69+
Gazebo上のRaspberry Pi Mouseに対して実行する場合は`use_sim_time:=true`オプションを指定します。
70+
71+
```sh
72+
ros2 launch raspimouse_navigation pc_navigation.launch.py map:=$HOME/MAP_NAME.yaml use_sim_time:=true
73+
```
74+
75+
### Running Navigation
76+
77+
RVizが起動したら、初期位置・姿勢を合わせます。RVizの画面上部の*2D Pose Estimate*をクリックします。
78+
79+
地図上でRaspberry Pi Mouseが存在すべき尤もらしい位置をクリックし、**そのままホールド**します。
80+
81+
ホールドしながらカーソルを動かし、表示されている矢印の向きをRaspberry Pi Mouseの尤もらしい向きに合わせてからボタンを離します。
82+
83+
<img src=https://rt-net.github.io/images/raspberry-pi-mouse/navigation_ros2_setting_initialpose.gif width=500 />
84+
85+
初期位置・姿勢の指示が完了したら、次は目標位置・姿勢を指示します。RVizの画面上部の*Navigation2 Goal*をクリックします。
86+
87+
地図上で、初期位置・姿勢を合わせた時と同様に、地図上をクリックして目標位置を、ホールドしたままカーソルを動かして目標姿勢を指示します。目標姿勢の指示が完了すると、Raspberry Pi Mouseが自律移動を開始します。
88+
89+
<img src=https://rt-net.github.io/images/raspberry-pi-mouse/navigation_ros2_setting_goalpose.gif width=500 />
90+
91+
### Stopping the robot
92+
93+
下記画像のようなナビゲーション用のパネルがRViz左下に表示されます。
94+
*Cancel*ボタンを押すと自律移動が中断されます。
95+
96+
<img src=https://rt-net.github.io/images/raspberry-pi-mouse/navigation_ros2_rviz_panel.png width=300 />
97+
98+
Raspberry Pi Mouseを停止させる別の方法として、モータへの電源供給を止める方法もあります。
99+
100+
次のコマンドを実行すると、ソフトウェア側からモータ電源をON / OFFできます。
101+
102+
```sh
103+
# モータ電源をOFFにする
104+
ros2 service call /motor_power std_srvs/srv/SetBool data:\ false
105+
# モータ電源をONにする
106+
ros2 service call /motor_power std_srvs/srv/SetBool data:\ true
107+
```
108+
109+
安全に気をつけながらRaspberry Pi Mouseに搭載されたスイッチを操作してモータ用電源をOFFにします。
110+
111+
## Parameters
112+
113+
- `use_sim_time`
114+
- Type: `bool`
115+
- Default: `false`
116+
- シミュレーション動作時は`true`、実機動作時は`false`を指定します。このパラメータは内部で起動される`Nav2`関連ノードで使用されます。
117+
118+
[Nav2](https://docs.nav2.org/)のパラメータについては、以下を参照してください。
119+
120+
- [Nav2:初めてのロボットセットアップガイド](https://docs.nav2.org/setup_guides/index.html)
121+
- [Nav2:パラメータチューニング方法](https://docs.nav2.org/tuning/index.html)
122+
- [Nav2:パラメータ一覧](https://docs.nav2.org/configuration/index.html)

raspimouse_navigation/launch/pc_navigation.launch.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ def generate_launch_description():
6565

6666
# Launch files and Nodes #
6767
nav2_node = IncludeLaunchDescription(
68-
PythonLaunchDescriptionSource([nav2_launch_file_dir, '/bringup_launch.py']),
68+
PythonLaunchDescriptionSource(
69+
[nav2_launch_file_dir, '/bringup_launch.py']
70+
),
6971
launch_arguments={
7072
'map': map_yaml_file,
7173
'params_file': params_file,

raspimouse_navigation/launch/robot_navigation.launch.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ def generate_launch_description():
3939
)
4040

4141
declare_arg_lidar_frame = DeclareLaunchArgument(
42-
'lidar_frame', default_value='laser', description='Set lidar frame name.'
42+
'lidar_frame',
43+
default_value='laser',
44+
description='Set lidar frame name.',
4345
)
4446

4547
declare_arg_namespace = DeclareLaunchArgument(
@@ -51,7 +53,8 @@ def generate_launch_description():
5153
PythonLaunchDescriptionSource(
5254
[
5355
os.path.join(
54-
get_package_share_directory('hls_lfcd_lds_driver'), 'launch'
56+
get_package_share_directory('hls_lfcd_lds_driver'),
57+
'launch',
5558
),
5659
'/hlds_laser.launch.py',
5760
]
@@ -71,7 +74,9 @@ def generate_launch_description():
7174
rplidar_launch = IncludeLaunchDescription(
7275
PythonLaunchDescriptionSource(
7376
[
74-
os.path.join(get_package_share_directory('rplidar_ros'), 'launch'),
77+
os.path.join(
78+
get_package_share_directory('rplidar_ros'), 'launch'
79+
),
7580
'/rplidar.launch.py',
7681
]
7782
),
@@ -92,7 +97,9 @@ def generate_launch_description():
9297
robot_description_launch = IncludeLaunchDescription(
9398
PythonLaunchDescriptionSource(
9499
[
95-
os.path.join(get_package_share_directory('raspimouse_slam'), 'launch/'),
100+
os.path.join(
101+
get_package_share_directory('raspimouse_slam'), 'launch/'
102+
),
96103
'description.launch.py',
97104
]
98105
),
@@ -107,7 +114,9 @@ def generate_launch_description():
107114
output='screen',
108115
parameters=[
109116
os.path.join(
110-
get_package_share_directory('raspimouse_slam'), 'config', 'mouse.yaml'
117+
get_package_share_directory('raspimouse_slam'),
118+
'config',
119+
'mouse.yaml',
111120
)
112121
],
113122
)

raspimouse_navigation/params/raspimouse.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ local_costmap:
165165
inflation_layer:
166166
plugin: "nav2_costmap_2d::InflationLayer"
167167
cost_scaling_factor: 8.0
168-
inflation_radius: 0.5
168+
inflation_radius: 0.1
169169
always_send_full_costmap: True
170170

171171
global_costmap:
@@ -202,7 +202,7 @@ global_costmap:
202202

203203
inflation_layer:
204204
plugin: "nav2_costmap_2d::InflationLayer"
205-
cost_scaling_factor: 8.0
205+
cost_scaling_factor: 16.0
206206
inflation_radius: 0.5
207207
always_send_full_costmap: True
208208

0 commit comments

Comments
 (0)