Skip to content

Commit 90fd430

Browse files
YusukeKatoShota Aoki
andauthored
シミュレータ環境でSLAMとNavigationを実行 (#77)
* LakeHouseのモデルをワールドに配置 * bridgeにscanトピックを追加 * センサのプラグインを追加 * READMEにカメラライントレースとSLAM&Navigationの実行方法を追記 * lakehouseワールドに30cmの黒いキューブを複数配置 * READMEに画像を追加 * 不足していた依存関係を追加 * コピペできるようにコマンドを修正 Co-authored-by: Shota Aoki <s.aoki@rt-net.jp> * 引数mapの説明を修正 Co-authored-by: Shota Aoki <s.aoki@rt-net.jp> * Copyrightの文面を修正 Co-authored-by: Shota Aoki <s.aoki@rt-net.jp> * 英語版READMEのコマンドもコピペできるように修正 --------- Co-authored-by: Shota Aoki <s.aoki@rt-net.jp>
1 parent ef26922 commit 90fd430

File tree

8 files changed

+344
-5
lines changed

8 files changed

+344
-5
lines changed

README.en.md

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,79 @@ ros2 launch raspimouse_ros2_examples object_tracking.launch.py mouse:=false use_
9393

9494
![](https://rt-net.github.io/images/raspberry-pi-mouse/raspimouse_sim_object_tracking.gif)
9595

96+
### camera_line_follower
97+
98+
Terminal 1:
99+
100+
```sh
101+
ros2 launch raspimouse_gazebo raspimouse_with_line_follower_field.launch.py use_rgb_camera:=true camera_downward:=true
102+
```
103+
104+
Terminal 2:
105+
106+
```sh
107+
ros2 launch raspimouse_ros2_examples camera_line_follower.launch.py mouse:=false use_camera_node:=false
108+
```
109+
110+
Terminal 3: Start
111+
112+
```sh
113+
ros2 topic pub --once /switches raspimouse_msgs/msg/Switches "{switch0: false, switch1: false, switch2: true}"
114+
```
115+
116+
Terminal 3: Stop
117+
```sh
118+
ros2 topic pub --once /switches raspimouse_msgs/msg/Switches "{switch0: true, switch1: false, switch2: false}"
119+
```
120+
121+
For information on parameters in camera line follower, click [here](https://github.com/rt-net/raspimouse_ros2_examples/blob/master/README.en.md#parameters).
122+
123+
![](https://rt-net.github.io/images/raspberry-pi-mouse/raspimouse_sim_camerafollower_short.gif)
124+
125+
### SLAM & Navigation
126+
127+
#### SLAM
128+
129+
Terminal 1:
130+
```sh
131+
ros2 launch raspimouse_gazebo raspimouse_with_lakehouse.launch.py lidar:=urg
132+
```
133+
The lidar option supports `urg`, `lds`, and `rplidar`.
134+
135+
Terminal 2:
136+
```sh
137+
ros2 launch raspimouse_ros2_examples teleop_joy.launch.py joydev:="/dev/input/js0" joyconfig:=f710 mouse:=false
138+
```
139+
140+
Terminal 3:
141+
```sh
142+
ros2 launch raspimouse_slam pc_slam.launch.py
143+
```
144+
145+
![](https://rt-net.github.io/images/raspberry-pi-mouse/raspimouse_sim_slam.png)
146+
147+
Terminal 4:
148+
```sh
149+
ros2 run nav2_map_server map_saver_cli -f ~/MAP_NAME
150+
```
151+
152+
![](https://rt-net.github.io/images/raspberry-pi-mouse/raspimouse_sim_slam_short.gif)
153+
154+
#### Navigation
155+
156+
Terminal 1:
157+
```sh
158+
ros2 launch raspimouse_gazebo raspimouse_with_lakehouse.launch.py lidar:=urg
159+
```
160+
The lidar option supports `urg`, `lds`, and `rplidar`.
161+
162+
Terminal 2:
163+
```sh
164+
ros2 launch raspimouse_navigation pc_navigation.launch.py map:=$HOME/MAP_NAME.yaml
165+
```
166+
167+
![](https://rt-net.github.io/images/raspberry-pi-mouse/raspimouse_sim_navigation_short.gif)
168+
96169
## Model data list
97170

98171
### course_curve_50x50cm
@@ -108,12 +181,12 @@ Panel size is 50 cm x 50 cm and line width is 4 cm.
108181
![](./raspimouse_gazebo/models/course_straight_50x50cm/meshes/course_straight.jpg)
109182

110183
### cube_*cm_color-name
111-
Each cube is 5 cm, 7.5 cm, 10 cm, and 15 cm on a side.
112-
The cube colors are red, yellow, blue, and green.
184+
Each cube is 5 cm, 7.5 cm, 10 cm, and 15 cm, 30 cm on a side.
185+
The cube colors are red, yellow, blue, green and black.
113186

114187
![](https://rt-net.github.io/images/raspberry-pi-mouse/color_objects.png)
115188

116-
### daeファイルについて
189+
### about dae files
117190
The dae file is edited in Blender 4.0.
118191

119192
## License

README.md

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ git clone -b ros2 https://github.com/rt-net/raspimouse_sim.git
3939
```sh
4040
cd ~/ros2_ws/src
4141
git clone https://github.com/rt-net/raspimouse_ros2_examples.git
42+
git clone https://github.com/rt-net/raspimouse_slam_navigation_ros2.git
4243
git clone -b ros2 https://github.com/rt-net/raspimouse_description.git
4344
rosdep install -r -y -i --from-paths raspimouse*
4445
```
@@ -93,6 +94,78 @@ ros2 launch raspimouse_ros2_examples object_tracking.launch.py mouse:=false use_
9394

9495
![](https://rt-net.github.io/images/raspberry-pi-mouse/raspimouse_sim_object_tracking.gif)
9596

97+
### RGBカメラを用いたライントレースサンプル
98+
99+
端末1で次のコマンドを実行すると、ライントレースのサンプルコースが配置されたワールドが表示されます。
100+
```sh
101+
ros2 launch raspimouse_gazebo raspimouse_with_line_follower_field.launch.py use_rgb_camera:=true camera_downward:=true
102+
```
103+
104+
端末2で次のコマンドを実行すると、カメラライントレースのノードが起動します。
105+
```sh
106+
ros2 launch raspimouse_ros2_examples camera_line_follower.launch.py mouse:=false use_camera_node:=false
107+
```
108+
109+
端末3で次のコマンドを実行すると、Raspberry Pi Mouseが走行を開始します。
110+
```sh
111+
ros2 topic pub --once /switches raspimouse_msgs/msg/Switches "{switch0: false, switch1: false, switch2: true}"
112+
```
113+
114+
次のコマンドを実行すると、Raspberry Pi Mouseが停止します。
115+
```sh
116+
ros2 topic pub --once /switches raspimouse_msgs/msg/Switches "{switch0: true, switch1: false, switch2: false}"
117+
```
118+
119+
カメラライントレースにおけるパラメータは[こちら](https://github.com/rt-net/raspimouse_ros2_examples?tab=readme-ov-file#parameters)を参照してください。
120+
121+
![](https://rt-net.github.io/images/raspberry-pi-mouse/raspimouse_sim_camerafollower_short.gif)
122+
123+
### LiDARを用いたSLAMとNavigationのサンプル
124+
125+
#### SLAM
126+
127+
端末1で次のコマンドを実行すると、`Lake House`のモデルが配置されたワールドが表示されます。
128+
```sh
129+
ros2 launch raspimouse_gazebo raspimouse_with_lakehouse.launch.py lidar:=urg
130+
```
131+
`lidar``urg``lds``rplidar`のいずれかを指定してください。
132+
133+
端末2で次のコマンドを実行すると、Raspberry Pi Mouseをジョイスティックコントローラで操作できます。
134+
```sh
135+
ros2 launch raspimouse_ros2_examples teleop_joy.launch.py joydev:="/dev/input/js0" joyconfig:=f710 mouse:=false
136+
```
137+
138+
端末3で次のコマンドを実行すると、SLAMが実行されます。
139+
```sh
140+
ros2 launch raspimouse_slam pc_slam.launch.py
141+
```
142+
143+
![](https://rt-net.github.io/images/raspberry-pi-mouse/raspimouse_sim_slam.png)
144+
145+
端末4で次のコマンドを実行すると、作成した地図を保存できます。
146+
```sh
147+
ros2 run nav2_map_server map_saver_cli -f ~/MAP_NAME
148+
```
149+
`MAP_NAME`は任意の名前を指定できます。
150+
151+
![](https://rt-net.github.io/images/raspberry-pi-mouse/raspimouse_sim_slam_short.gif)
152+
153+
#### Navigation
154+
155+
端末1で次のコマンドを実行すると、`Lake House`のモデルが配置されたワールドが表示されます。
156+
```sh
157+
ros2 launch raspimouse_gazebo raspimouse_with_lakehouse.launch.py lidar:=urg
158+
```
159+
`lidar``urg``lds``rplidar`のいずれかを指定してください。
160+
161+
端末2で次のコマンドを実行すると、Navigationが実行されます。
162+
```sh
163+
ros2 launch raspimouse_navigation pc_navigation.launch.py map:=$HOME/MAP_NAME.yaml
164+
```
165+
引数`map`にはSLAMで作成した地図ファイルのパスを指定してください。
166+
167+
![](https://rt-net.github.io/images/raspberry-pi-mouse/raspimouse_sim_navigation_short.gif)
168+
96169
## モデルデータ一覧
97170

98171
### course_curve_50x50cm
@@ -110,8 +183,8 @@ ros2 launch raspimouse_ros2_examples object_tracking.launch.py mouse:=false use_
110183
![](./raspimouse_gazebo/models/course_straight_50x50cm/meshes/course_straight.jpg)
111184

112185
### cube_*cm_color-name
113-
それぞれ一辺5cm、7.5cm、10cm、15cmの立方体です
114-
色は赤、黄、青、緑です
186+
それぞれ一辺5cm、7.5cm、10cm、15cm、30cmの立方体です
187+
色は赤、黄、青、緑、黒です
115188

116189
![](https://rt-net.github.io/images/raspberry-pi-mouse/color_objects.png)
117190

raspimouse_gazebo/launch/raspimouse_with_emptyworld.launch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def generate_launch_description():
135135
package='ros_gz_bridge',
136136
executable='parameter_bridge',
137137
arguments=['/clock@rosgraph_msgs/msg/Clock[ignition.msgs.Clock',
138+
'/scan@sensor_msgs/msg/LaserScan@ignition.msgs.LaserScan',
138139
'/camera/color/image_raw@sensor_msgs/msg/Image@gz.msgs.Image',
139140
'/camera_info@sensor_msgs/msg/CameraInfo@gz.msgs.CameraInfo'],
140141
output='screen'
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright 2024 RT Corporation <support@rt-net.jp>
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
# this software and associated documentation files (the "Software"), to deal in
7+
# the Software without restriction, including without limitation the rights to
8+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
# the Software, and to permit persons to whom the Software is furnished to do so,
10+
# subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
22+
import os
23+
24+
from ament_index_python.packages import get_package_share_directory
25+
from launch import LaunchDescription
26+
from launch.actions import IncludeLaunchDescription
27+
from launch_ros.actions import SetParameter
28+
from launch.launch_description_sources import PythonLaunchDescriptionSource
29+
30+
31+
def generate_launch_description():
32+
world_file = os.path.join(
33+
get_package_share_directory('raspimouse_gazebo'),
34+
'worlds',
35+
'lakehouse.sdf')
36+
world_launch = IncludeLaunchDescription(
37+
PythonLaunchDescriptionSource([
38+
get_package_share_directory('raspimouse_gazebo'),
39+
'/launch/raspimouse_with_emptyworld.launch.py']),
40+
launch_arguments={
41+
'world_name': world_file
42+
}.items()
43+
)
44+
45+
return LaunchDescription([
46+
SetParameter(name='use_sim_time', value=True),
47+
world_launch
48+
])
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" ?>
2+
3+
<model>
4+
<name>Black Cube 30cm</name>
5+
<version>1.0</version>
6+
<sdf version="1.6">model.sdf</sdf>
7+
8+
<author>
9+
<name>YusukeKato</name>
10+
<email>yusuke.kato@rt-net.jp</email>
11+
</author>
12+
13+
<description>
14+
Cube
15+
</description>
16+
</model>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" ?>
2+
<sdf version="1.6">
3+
<model name="cube_30cm_black">
4+
<link name="cube_black_link">
5+
<inertial>
6+
<inertia>
7+
<ixx>1</ixx>
8+
<ixy>0</ixy>
9+
<ixz>0</ixz>
10+
<iyy>1</iyy>
11+
<iyz>0</iyz>
12+
<izz>1</izz>
13+
</inertia>
14+
<mass>1.0</mass>
15+
</inertial>
16+
<collision name="cube_black_collision">
17+
<geometry>
18+
<box>
19+
<size>0.3 0.3 0.3</size>
20+
</box>
21+
</geometry>
22+
</collision>
23+
<visual name="cube_black_visual">
24+
<material>
25+
<ambient>0 0 0 1</ambient>
26+
<diffuse>0 0 0 1</diffuse>
27+
<specular>0 0 0 0</specular>
28+
<emissive>0 0 0 1</emissive>
29+
</material>
30+
<geometry>
31+
<box>
32+
<size>0.3 0.3 0.3</size>
33+
</box>
34+
</geometry>
35+
</visual>
36+
</link>
37+
</model>
38+
</sdf>

raspimouse_gazebo/package.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
<depend>raspimouse_fake</depend>
2121
<depend>raspimouse_description</depend>
2222
<depend>robot_state_publisher</depend>
23+
<depend>diff_drive_controller</depend>
24+
<depend>joint_state_broadcaster</depend>
2325

2426
<export>
2527
<build_type>ament_cmake</build_type>

0 commit comments

Comments
 (0)