Ch 5: ROSKY2 SLAM and Gmapping - CIRCUSPi/ROSKY2 GitHub Wiki

In this note, user will use package "slam_gmapping"(thanks Adlink for providing) to build map for navigation.

Hardware user have to prepare before doing...

  1. ROSKY2

Note Navigation2 just can be used on Ubuntu 20.04

  1. A host machine with the operating system is Window 10(above) or Ubuntu.

Some things user should know before operating...

Please check the note and documentation below:

Now let’s go ahead to build map.


Step 1. Open Terminator in ROSKY2 through remote desktop

Step 1-1. Open terminal on the remote desktop

Because of the keyboard shortcut keys in NoMachine, user can not use the keyboard keys 【ctrl】+【alt】+【T】to open the terminal quickly.

Please right-click the mouse on the remote desktop to open the menu item and then choose【Open Terminal】to open terminal.

Once user see the roe_menu is shown on the terminal, please choose【2】to start the operating environment for ROSKY2.

Open terminal on the remote desktop

Step 1-2. Open terminator on the remote desktop

Terminator is a nice terminal emulator, please check the Terminator’s documentation to know more detail.

User can type the command command to start terminator:

$ terminator

Once start the terminator successfully, user can see ros_menu is shown on the terminator. Like the operation in step 1-1, user have to choose [2] to start the environment for ROSKY2.

Open terminator on the remote desktop

More keyboard shortcut in the terminator user can find on the Terminator’s documentation - Using the keyboard.

Step 2. Start the communication with all sensors, motor control board and more on ROSKY2

Now user just running the system on the SBC and it can not send/receive data from sensor and more. Hence, user have to start the communication with these to send/receive data.

Note Seneors on ROSKY2 will start running after typing the command below. Please make sure no more things result in stopping these sensor work, such as something is on the LiDAR, transfer cable connect between host machine and ROSKY2 and more.

Please type the command below in the terminator to start the communication:

$ ros2 launch rosky2_bringup bringup.launch.py

launch bringup.launch.py

Step 3. Start using gmapping to build map

Awesome! User start the communication between ROSKY2 and sensors. Now user can build map through topics published above.

From Step 1-2 in this note, user can know that use keyboard shortcut 【ctrl】+【shift】+【E】 in terminator to split terminal vertically. Next the same thing is choosing 【2】 to start the environment for ROSKY2 after user opening ros_menu successfully.

split terminal vertically

Now is ready to build map, please type the command below in terminal to launch the file "slam_gmapping.launch.py"

$ ros2 launch slam_gmapping slam_gmapping.launch.py

launch slam_gmapping.launch.py

Step 4. Visualize mapping in Rviz2

After launching file "slam_gmapping.launch.py" successfully, user can use Rviz2 to watch the mapping progress.

Step 4-1. Running Rviz2

From Step 1-2 in this note, user can know that use keyboard shortcut 【ctrl】+【shift】+【O】 in terminator to split terminal horizontally. Next the same thing is choosing 【2】 to start the environment for ROSKY2 after user opening ros_menu successfully.

split terminal horizontally

Please type command below in the terminal wait for receiving command to run Rviz2:

$ rviz2

type command "rviz2"

And then user can see the window RViz:

RViz

Step 4-2. Display information in Rviz2

There is noting in the default window. User can add some displays to watch the information they want. But in this step, user have to add these displays below:

Here is the example to add Map. Please click the button 【Add】buttom left, and then user can see the small window 【rviz2】for creating visualization:

Click button 【Add】buttom left

Rviz2 have to subscribe the topic "/map" to visualize map. Hence, please click the label 【By topic】top and then choose 【Map】 in the topic "/map":

Choose 【Map】

After checking and clicking the button 【OK】down right, user can see the map on Rviz2:

Map

Nice! But where is the ROSKY2? User can add TF to check it location, and user have to notice:

Note If user want to add TF to display, just click the label 【By display type】and choose 【TF】.

Add TF on the map

How about the laser? User can add LaserScan by the label 【By topic】, but user have to know:

Note The QOS of topic /scan is "Best effort". Hence, please choose "Besto Effort" in the topic /scan and then user can see red points on the map:

LaserScan on the map

Step 4-3. teleop ROSKY2 to build map

Please check the note CH 2. ROSKY2 - Keyboard teleop to teleop ROSKY2. After moving ROSKY2, user can build map through gmapping.

Step 5. Save map through Navigation2

After building map, user can save map through Navigation2. Navigation2 provides package "nav2_map_server" to help user to manipulate map. Please type the command below to save map user build:

$ ros2 run nav2_map_server map_saver_cli -f [map_dir]/[map_name] --ros-args -p save_map_timeout:=10000

And

  • [map_dir]: the directory that user want to save map. For this example will use "~/ROSKY2/ros2_ws/src/slam_gmapping/slam_gmapping/map"

  • [map_name]: the name that user want to use. For this example will use "test20220830"

According the examples metion above, the full command is shown below(the window bottom right):

save map

Finally, user can find the map in the directory:

map

Step 6. Shutdown all running node.

If user finished saving map, please remember to shutdown all running node through the shortcut key 【ctrl】+【C】 in terminal.

Next

To be continued...

I plan to do navigation with ROSKY2 through Navigation2.

Please have fun to use ROSKY2 :)

⚠️ **GitHub.com Fallback** ⚠️