Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views42 pages

Mapping

The document provides an overview of the Unified Robot Description Format (URDF), detailing its structure and components used to describe robot models in ROS. It compares URDF with the xacro model, emphasizing the latter's efficiency in handling complex robot descriptions. Additionally, it covers the basic syntax for defining links and joints, along with principles of SLAM for mapping and localization in robotic systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views42 pages

Mapping

The document provides an overview of the Unified Robot Description Format (URDF), detailing its structure and components used to describe robot models in ROS. It compares URDF with the xacro model, emphasizing the latter's efficiency in handling complex robot descriptions. Additionally, it covers the basic syntax for defining links and joints, along with principles of SLAM for mapping and localization in robotic systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Mapping

Hiwonder Website
1. URDF Model

1.1 URDF Model Introduction

The Unified Robot Description Format (URDF) is an XML file format widely
used in ROS (Robot Operating System) to comprehensively describe all
components of a robot.

Robots are typically composed of multiple links and joints. A link is defined as a
rigid object with certain physical properties, while a joint connects two links and
constrains their relative motion.

By connecting links with joints and imposing motion restrictions, a kinematic


model is formed. The URDF file specifies the relationships between joints and
links, their inertial properties, geometric characteristics, and collision models.

1.2 Comparison between Xacro and URDF Model

The URDF model serves as a description file for simple robot models, offering
a clear and easily understandable structure. However, when it comes to
describing complex robot structures, using URDF alone can result in lengthy
and unclear descriptions.

To address this limitation, the xacro model extends the capabilities of URDF
while maintaining its core features. The xacro format provides a more
advanced approach to describe robot structures. It greatly improves code
reusability and helps avoid excessive description length.

For instance, when describing the two legs of a humanoid robot, the URDF
model would require separate descriptions for each leg. On the other hand, the
xacro model allows for describing a single leg and reusing that description for
the other leg, resulting in a more concise and efficient representation.

2
1.3 Basic Syntax of URDF Model

1.3.1 XML Basic Syntax

The URDF model is written using XML standard.

Elements:

An element can be defined as desired using the following formula:

<element>

</element>

Properties:

Properties are included within elements to define characteristics and


parameters. Please refer to the following formula to define an element with
properties:

<element

property_1="property value1"

property_2="property value2">

</element>

Comments:

Comments have no impact on the definition of other properties and elements.


Please use the following formula to define a comment:

<!-- comment content -->

1.3.2 Link

The Link element describes the visual and physical properties of the robot's

3
rigid component. The following tags are commonly used to define the motion of
a link:

<visual>: Describe the appearance of the link, such as size, color and shape.

<inertial>: Describe the inertia parameters of the link, which will used in
dynamics calculation.

<collision>: Describe the collision inertia property of the link

Each tag contains the corresponding child tag. The functions of the tags are
listed below.

Tag Function

Describe the pose of the link. It contains

two parameters, including xyz and rpy.

origin Xyz describes the pose of the link in the

simulated map. Rpy describes the pose

of the link in the simulated map.

mess Describe the mess of the link

Describe the inertia of the link. As the

inertia matrix is symmetrical, these six

inertia parameters need to be input, ixx, ixy, ixz,

iyy, iyz and izz, as properties. These

parameters can be calculated.

4
Describe the shape of the link. It uses

mesh parameter to load texture file, and

geometry em[ploys filename parameters to load

the path for texture file. It has three child

tags, namely box, cylinder and sphere.

Describe the material of the link. The

parameter name is the required filed.


material
The tag color can be used to change the

color and transparency of the link.

1.3.3 Joint

The "Joint" tag describes the kinematic and dynamic properties of the robot's
joints, including the joint's range of motion, target positions, and speed
limitations. In terms of motion style, joints can be categorized into six types.

The following tags will be used to write joint motion.

5
<parent_link>: Parent link

<child_link>: Child link

<calibration>: Calibrate the joint angle

<dynamics>: Describes some physical properties of motion

<limit>: Describes some limitations of the motion

The function of each tag is listed below. Each tag involves one or several child
tags.

Tag Function

Describe the pose of the parent link. It

involves two parameters, including xyz


origin
and rpy. Both xyz and rpy describe the

pose of the link in simulated map.

Control the child link to rotate around


axis
any axis of the parent link.

The motion of the child link is

constrained using the lower and upper


limit properties, which define the limits of

rotation for the child link. The effort

properties restrict the allowable force

6
range applied during rotation (values:

positive and negative; units: N). The

velocity properties confine the rotational

speed, measured in meters per second

(m/s).

mimic Describe the relationship between joints.

Describes the parameters of the safety

safety_controller controller used for protecting the joint

motion of the robot.

1.3.4 Robot Tag

The complete top tags of a robot, including the <link> and <joint> tags, must
be enclosed within the <robot> tag. The format is as follows:

1.3.5 gazebo Tag

This tag is used in conjunction with the Gazebo simulator. Within this tag, you
can define simulation parameters and import Gazebo plugins, as well as
specify Gazebo's physical properties, and more.

7
1.3.6 Write Simple URDF Model

Name the model of the robot

To start writing the URDF model, we need to set the name of the robot
following this format: “<robot name=“robot model name”>”. Lastly, input
“</robot>” at the end to represent that the model is written successfully.

1.3.7 Set links

1) To write the first link and use indentation to indicate that it is part of the
currently set model. Set the name of the link using the following format:
<link name="link name">. Finally, conclude with "</link>" to indicate the
successful completion of the link definition.

2) Write the link description and use indentation to indicate that it is part of the
currently set link, and conclude with "</visual>".

3) The "<geometry>" tag is employed to define the shape of a link. Once the
description is complete, include "</geometry>". Within the "<geometry>"
tag, indentation is used to specify the detailed description of the link's
shape. The following example demonstrates a link with a cylindrical shape:
"<cylinder length="0.01" radius="0.2"/>". In this instance,

8
"length="0.01"" signifies a length of 0.01 meters for the link, while
"radius="0.2"" denotes a radius of 0.2 meters, resulting in a cylindrical
shape.

4) The "<origin>" tag is utilized to specify the position of a link, with


indentation used to indicate the detailed description of the link's position.
The following example demonstrates the position of a link: "<origin
rpy="0 0 0" xyz="0 0 0" />". In this example, "rpy" represents the roll,
pitch, and yaw angles of the link, while "xyz" represents the coordinates of
the link's position. This particular example indicates that the link is
positioned at the origin of the coordinate system.

5) The "<material>" tag is used to define the visual appearance of a link, with
indentation used to specify the detailed description of the link's color. To
start describing the color, include "<material>", and end with "</material>"
when the description is complete. The following example demonstrates
setting a link color to yellow: "<color rgba="1 1 0 1" />". In this example,
"rgba="1 1 0 1"" represents the color threshold for achieving a yellow
color.

1.3.8 Set joint

1) To write the first joint, use indentation to indicate that the joint belongs to
the current model being set. Then, specify the name and type of the joint
as follows: "<joint name="joint name" type="joint type">". Finally,

9
include "</joint>" to indicate the completion of the joint definition.

Note: to learn about the type of the joint, please refer to “4.2 joint”.

2) Write the description section for the connection between the link and the
joint. Use indentation to indicate that it is part of the currently defined joint.
The parent parameter and child parameter should be set using the
following format: "<parent link="parent link"/>", and "<child link="child
link" />". With the parent link serving as the pivot, the joint rotates the child
link.

3) “<origin>” describes the position of the joint using indention. This example
describes the position of the joint: “<origin xyz=“0 0 0.1” />”. xyz is the
coordinate of the joint.

4) “<axis>” describes the position of the joint adopting indention.


“<axis xyz=“0 0 1” />” describes one posture of a joint. xyz specifies the
pose of the joint.

5) “<limit>” imposes restrictions on the joint using indention. The below


picture The "<limit>" tag is used to restrict the motion of a joint, with
indentation indicating the specific description of the joint angle limitations.
The following example describes a joint with a maximum force limit of 300
Newtons, an upper limit of 3.14 radians, and a lower limit of -3.14 radians.
The settings are defined as follows: "effort=“joint force (N)”,
velocity=“joint motion speed”, lower=“lower limit in radians”,

10
upper=“upper limit in radians”.

6) “<dynamics>” describes the dynamics of the joint using indention.


“<dynamics damping=“50” friction=“1” />” describes dynamics
parameters of a joint.

The complete codes are as below.

11
12
2. Explanation of ROS Robot URDF Model

2.1 Preparation

To grasp the URDF model, check out "1.3 Basic Syntax of URDF Model" for
the key syntax. This part quickly breaks down the robot model code and its
components.

2.2 Check Code of Robot Model

1) Start the robot, and access the robot system desktop using NoMachine.

2) Click-on to open the ROS2 command-line terminal.

3) Execute the command and hit Enter key to navigate to the folder
containing startup programs.

colcon_cd jetrover_description

4) Enter the command to navigate to the robot simulation model folder.

cd urdf

5) Execute the command to access the robot simulation model folder.

vim jetacker.xacro

6) Locate the code below:

13
Several URDF models are combined to create a full robot:

File Name Device

materials Color

inertial_matrix Inertia matrix

lidar_a1 A1 Lidar

lidar_g4 G4 Lidar

Imu Inertial measurement unit

jetacker Robot module

2.3 Brief Analysis of Robot's Main Body Model

Open a new command terminal and run the command to access the robot
model file, which contains the description of each part of the robot model.

vim jetacker.urdf.xacro

<?xml version="1.0" encoding="utf-8"?>

<robot name="jetacker" xmlns:xacro="http://ros.org/wiki/xacro" >

This is the beginning of the URDF file. It specifies the XML version and

14
encoding, and defines a robot model named "hiwonder". The xmlns:xacro
namespace is utilized here to generate URDF using Xacro macro definitions.

The following line of code defines a Xacro property named "M_PI" and assigns
the value of π to it.

2.3.1 Main Robot Body Model Basic Parameter

This section defines some basic parameters of the robot model:

The first parameter, base_link_mass, defines the weight of the robot's


main body model, in kilograms.

The second parameter, base_link_w, defines the width of the robot's main
body model, in meters.

The third parameter, base_link_h, defines the height of the robot's main
body model, in meters.

The fourth parameter, base_link_d, defines the length of the robot's main
body model, in meters.

The fifth parameter, wheel_link_mass, defines the weight of the robot's


wheels, in kilograms.

The sixth parameter, wheel_link_radius, defines the radius of the robot's


wheels, in meters.

15
2.3.2 Ackermann Wheel Simulation (taking the right front wheel as an
example)

Define the link wheel_front_right_link. This link is defined as a cylinder


and populated with the parameters defined earlier.

Define the visual description of the link wheel_front_right_link (keyword


visual) and within the visual description define: the position as the origin
(keyword origin), the introduction of the relevant dynamics configuration file
(keyword geometry), and the color as black (keyword material).

Define the collision (keyword collision), collision position (keyword origin),


and collision area (keyword geometry).

2.3.3 Robot lidar simulation model

Define the link lidar_link. Define the inertial properties (keyword inertial)
and within this definition, specify: the inertial origin (keyword origin), the mass
(keyword mass), and the inertial properties between the links (keyword inertia).

Define the visual description (keyword visual) and within this definition
specify: the position as the origin (keyword origin), the relevant dynamics
configuration file (keyword geometry), and the color as black (keyword
material).

16
Define the collision properties (keyword collision), the collision position
(keyword origin), and the collision geometry (keyword geometry).

3. Principles of SLAM Map Building

3.1 Introduction to SLAM

SLAM stands for Simultaneous Localization and Mapping.

Localization involves determining the pose of a robot in a coordinate system,,


The origin of orientation of the coordinate system can be obtained from the first
keyframe, existing global maps, landmarks or GPS data.

Mapping involves creating a map of the surrounding environment perceived by


the robot. The basic geometric elements of the map are points. The main
purpose of the map is for localization and navigation. Navigation can be
divided into guidance and control. Guidance includes global planning and local
planning, while control involves controlling the robot's motion after the planning
is done.

17
3.2 SLAM Mapping Principle

1 Preprocessing: Optimizing the raw data from the radar point cloud,
filtering out problematic data or performing filtering. Using laser as a signal
source, pulses of laser emitted by the laser are directed at surrounding
obstacles, causing scattering.

Some of the light waves will reflect back to the receiver of the lidar, and then,
according to the principle of laser ranging, the distance from the lidar to the
target point can be obtained.

Regarding point clouds: In simple terms, the surrounding environment


information obtained by lidar is called a point cloud. It reflects a portion of what
the 'eyes' of the robot can see in the environment where it is located. The
object information collected presents a series of scattered, accurate angle, and
distance information.

2 Matching: Matching the point cloud data of the current local environment
with the established map to find the corresponding position.
3 Map Fusion: Integrating new round data from the lidar into the original
map, ultimately completing the map update.

18
3.3 Notes

1.Begin the mapping process by positioning the robot in front of a straight


wall or within an enclosed box. This enhances the Lidar's capacity to capture a
higher density of scanning points.

2.Initiate a 360-degree scan of the environment using the Lidar to ensure a


comprehensive survey of the surroundings. This step is crucial to guarantee
the accuracy and completeness of the resulting map.

3.For larger areas, it's recommended to complete a full mapping loop before
focusing on scanning smaller environmental details. This approach enhances
the overall efficiency and precision of the mapping process.

3.4 Judge Mapping Result

Finally, assess the robot's navigation process against the following criteria
once the mapping is complete:
1) Ensure that the edges of obstacles within the map are distinctly defined.
2) Check for any disparities between the map and the actual environment,
such as the presence of closed loops or inconsistencies.
3) Verify the absence of gray areas within the robot's motion area, indicating
areas that haven't been adequately scanned.
4) Confirm that the map doesn't incorporate obstacles that won't exist during
subsequent localization.
5) Validate the map's coverage of the entire extent of the robot's motion area.

19
4. slam_toolbox Mapping Algorithm

4.1 Mapping Definition

Slam Toolbox software package combines information from laser rangefinders


in the form of LaserScan messages and performs TF transformation from
odom-> base link to create a two-dimensional map of space. This software
package allows for fully serialized reloadable data and pose graphs of SLAM
maps, used for continuous mapping, localization, merging, or other operations.
It allows Slam Toolbox to operate in synchronous (i.e., processing all valid
sensor measurements regardless of delay) and asynchronous (i.e., processing
valid sensor measurements whenever possible) modes.

ROS replaces functionalities like gmapping, cartographer, karto, hector,


providing comprehensive SLAM functionality built upon the powerful scan
matcher at the core of Karto, widely used and accelerated for this package. It
also introduces a new optimization plugin based on Google Ceres. Additionally,
it introduces a new localization method called 'elastic pose-graph localization,'
which takes measured sliding windows and adds them to the graph for
optimization and refinement. This allows for tracking changes in local features
of the environment instead of considering them as biases, and removes these
redundant nodes when leaving an area without affecting the long-term map.

Slam Toolbox is a suite of tools for 2D Slam, including:

 Mapping, saving map pgm files

 Map refinement, remapping, or continuing mapping on saved maps

 Long-term mapping: loading saved maps to continue mapping while


removing irrelevant information from new laser point clouds

 Optimizing positioning mode on existing maps. Localization mode can also


be run without mapping using the 'laser odometry' mode

20
 Synchronous, asynchronous mapping

 Dynamic map merging

 Plugin-based optimization solver, with a new optimization plugin based on


Google Ceres

 Interactive RVIZ plugin

 RVIZ graphical manipulation tools for manipulating nodes and connections


during mapping

 Map serialization and lossless data storage.

From the above diagram, it can be seen that the process is relatively
straightforward. The traditional soft real-time operation mechanism of slam
involves processing each frame of data upon entry and then returning.
Relevant source code and WIKI links for KartoSLAM:

 KartoSLAM ROS Wiki: http://wiki.ros.org/slam_karto


 slam_karto software package:

21
https://github.com/ros-perception/slam_karto
 open_karto open-source algorithm:
https://github.com/ros-perception/open_karto

4.2 Mapping Operation Steps

ROS2 mapping and navigation utilize virtual machine connectivity to enable


mapping and navigation with the robot on the same local network.

4.2.1 Install Virtual Machine Software and Import the Virtual Machine

4.2.1.1 Install Virtual Machine

Unzip the provided installation files, then click on the installation file to proceed
with the installation.

4.2.1.2 Import Virtual Machine Image

1) Click on to open the virtual machine.

2) Enter the virtual machine interface and click on "Open Virtual Machine."

3) Select the ubuntu_ros2_humble folder extracted locally (6 Virtual


Hosts\ubuntu_ros2_humble), choose the Ubuntu 22.04 ROS2.ovf file, and
click "Open."
22
4) Enter your desired virtual machine name, select your preferred path, and
click "Import."

5) The import process is underway, displaying the import progress.

23
6) After import completion, follow the prompts to complete the installation
process.

4.2.2 Copy Robot Files to the Virtual Machine

4.2.2.1 Export Files from the Robot

1) Start the robot, and access the robot system desktop using NoMachine.

2) Click-on to open the ROS1 command-line terminal.

3) Execute the command to disable the app auto-start service.

sudo systemctl stop start_app_node.service

4) Click-on to start the ROS2 command-line terminal.

5) Enter the command to navigate to the ros2_ws/src/ directory:

cd ros2_ws/src/

6) Enter the command to package the three files 'navigation', 'slam', and
'simulations' into a compressed file:

zip -r src.zip navigation slam simulations

24
7) Enter the command to move the compressed file to the shared directory:

mv src.zip /home/ubuntu/share/tmp

8) Run the command and return to ros2_ws directory:

cd ..

9) Enter the command to view the .typerc file in this directory:

ls -a

10) Enter the command to move the .typerc file to the shared directory:

cp .typerc /home/ubuntu/share/tmp

11) Click-on to open the file directory, then navigate to the

home/docker/tmp directory:

12) Use the shortcut 'Ctrl + H' to show the hidden .typerc file:

13) Drag the two files from the directory to the computer desktop.

25
4.2.2.2 Import Files into the Virtual Machine

1) Click-on to navigate to the home directory.

2) Drag and drop the .typerc and src.zip files from the computer desktop into
the virtual machine:

26
4.2.3 Create and Compile the Workspace

1) Click-on to start the virtual machine command-line terminal.

2) Enter the command to create the ros2_ws/src directory:

mkdir -p ros2_ws/src

3) Extract the file ‘src.zip’ to the directory ‘home/ubuntu’.

unzip src.zip

4) Move the simulations, slam, and navigation files to the ros2_ws/src


directory:

mv simulations slam navigation /home/ubuntu/ros2_ws/src/

5) Move the .typerc file to the ros2_ws directory:

mv .typerc ros2_ws/

27
6) Navigate to the ros2_ws directory:

cd ros2_ws/

7) Enter the command to check if .typerc has been moved to the ros2_ws
directory:

ls -a

8) Input the following command to compile the workspace:

colcon build

9) Change the .bashrc file, and input the following command:

gedit ~/.bashrc

Copy the content below to the file .bashrc

source /home/ubuntu/ros2_ws/.typerc
source /home/ubuntu/ros2_ws/install/setup.bash

10) After finishing writing, use the shortcut Ctrl + S or click the Save button in
the upper right corner to save and exit.

11) Run the command below to refresh the environment configuration.

28
source ~/.bashrc

4.2.4 Set the Robot to LAN Mode

1) Click-on to open the ROS1 command-line terminal.

2) Enter the command to modify the wifi configuration file, change it to LAN
mode, and update your own WIFI name and password.

gedit ~/hiwonder-toolbox/hiwonder_wifi_conf.py

#!/usr/bin/python3

#coding:utf8

HW_WIFI_MODE = 2 # WiFi operating mode, 1 for AP mode, 2 for

STA mode

# HW_WIFI_AP_SSID = 'HW-Robot1' # SSID in AP mode. Composed of

characters and numbers, must start with HW- to enable app functionality

# HW_WIFI_AP_PASSWORD = 'hiwonder' # WiFi password in AP mode, composed

of characters and numbers

HW_WIFI_STA_SSID = 'hiwonder' # SSID in STA mode

HW_WIFI_STA_PASSWORD = 'hiwonder' # WiFi password in STA mode

3) After finishing writing, use the shortcut “Ctrl + S” or click the Save button in

29
the upper right corner to save and exit.

4) Enter the command to restart the network, or reboot the system. It is


recommended to reboot the system. After that, check the IP address on
the robot's OLED screen for connection.

sudo systemctl restart hw_wifi.service

5) It is important to note that the virtual machine and the robot are connected
to the same LAN, and their IP addresses should be within the same
subnet:

Virtual Machine:

Robot:

6) After rebooting, click on to open the robot's ROS2 command line

30
terminal. You will notice that the ROS_DOMAIN_ID is 0, which is the same
as on the virtual machine.

Robot:

Virtual Machine:

4.2.5 slam Mapping Instructions

4.2.5.1 Robot Operations

1) Click-on to open the ROS1 command-line terminal.

2) Execute the following command to disable the app auto-start service.

sudo systemctl stop start_app_node.service

3) Click-on to open the ROS2 command-line terminal.

4) Run the command to initiate mapping:

ros2 launch slam slam.launch.py

31
4.2.5.2 Virtual Machine Instructions

1) Click-on to open the command line terminal of the virtual machine


system.

2) Enter the command to open the RViz tool and display the mapping
results.

ros2 launch slam rviz_slam.launch.py

4.2.5.3 Enable Keyboard Control

1) Click-on to open the ROS2 command-line terminal.

2) Enter the command to start the keyboard control node, and press Enter
key:

ros2 launch peripherals teleop_key_control.launch.py

32
If you see the prompt as shown in the following image, it means the keyboard
control service has been successfully started.

3) Control the robot to move in the current space to build a more complete
map. The table below lists the keyboard keys available for controlling robot
movement and their corresponding functions:

Key Robot Action

Short press to switch to forward state


W
and continuously move forward

Short press to switch to backward state


S
and continuously move backward

Long press to interrupt the forward or


A
backward state and turn left

Long press to interrupt the forward or


D
backward state and turn right

When controlling the robot's movement with the keyboard to map, it's
advisable to reduce the robot's movement speed appropriately. The slower the
robot's speed, the smaller the odometry relative error, leading to better
33
mapping results. As the robot moves, the map displayed in RVIZ will
continuously expand until the entire environment scene's map construction is
completed.

4.2.5.4 Save Map

1) Click-on to open the ROS2 command-line terminal.

2) Run the following command and hit Enter key:

cd ~/ros2_ws/src/slam/maps && ros2 run nav2_map_server


map_saver_cli -f "map_01" --ros-args -p
map_subscribe_transient_local:=true

4.2.5.5 Effect Optimization

If you desire a more precise mapping outcome, optimizing the odometry can
be beneficial. Mapping with the robot requires the use of odometry, which in
turn relies on the IMU.

The robot itself comes with pre-calibrated IMU data loaded, enabling it to
perform mapping and navigation functions effectively. However, calibrating the
IMU can still enhance accuracy further. The calibration method and steps for
the IMU can be found in the "3 Motion Control Course -> 2. Motion Control -> 1.
IMU, Linear Velocity and Angular Velocity Calibration" section.

4.2.6 Parameter Explanation

The parameter file can be found in the "ros2_ws\src\slam\config\slam.yaml"

34
directory.

For more detailed information about the parameters, please refer to the official
documentation: https://wiki.ros.org/slam_toolbox

4.2.7 Launch File Analysis

The launch file is located at:

/home/ubuntu/ros2_ws/src/slam/launch/slam.launch.py

 Import Library

The launch library can be explored in detail in the official ROS documentation:

https://docs.ros.org/en/humble/How-To-Guides/Launching-composable-nodes.
html

 Set the Storage Path

Use the `get_package_share_directory` function to obtain the path of the slam


package.

35
 Initiate Other Launch File

base_launch: Launch for hardware initialization

slam_launch: Launch for basic mapping

bringup_launch: Launch for initial pose setup

36
5. RTAB-VSLAM 3D Vision Mapping & Navigation

5.1 RTAB-VSLAM Description

RTAB-VSLAM is a appearance-based real-time 3D mapping system, it's an


open-source library that achieves loop closure detection through memory
management methods. It limits the size of the map to ensure that loop closure
detection is always processed within a fixed time limit, thus meeting the
requirements for long-term and large-scale environment online mapping.

5.2 RTAB-VSLAM Working Principle

RTAB-VSLAM 3D mapping employs feature mapping, offering the advantage


of rich feature points in general scenes, good scene adaptability, and the ability
to use feature points for localization. However, it has drawbacks, such as a
time-consuming feature point calculation method, limited information usage
leading to loss of image details, diminished effectiveness in weak-texture
areas, and susceptibility to feature point matching errors, impacting results
significantly.

After extracting features from images, the algorithm proceeds to match


features at different timestamps, leading to loop detection. Upon completion of
matching, data is categorized into long-term memory and short-term memory.
Long-term memory data is utilized for matching future data, while short-term
memory data is employed for matching current time-continuous data.

During the operation of the RTAB-VSLAM algorithm, it initially uses short-term


memory data to update positioning points and build maps. As data from a
specific future timestamp matches long-term memory data, the corresponding
long-term memory data is integrated into short-term memory data for updating
positioning and map construction.

37
RTAB-VSLAM software package link: https://github.com/introlab/rtabmap

5.3 RTAB-VSLAM 3D Mapping Instructions

5.3.1 Robot Operations

1) Click on on the system desktop to open the ROS1 command-line


terminal.

2) Run the command to disable the app auto-start service:

sudo systemctl stop start_app_node.service

3) Click-on to open the ROS2 command-line terminal.

4) Execute the command to start mapping:

ros2 launch slam rtabmap_slam.launch.py

5.3.2 Virtual Machine Operation

1) Click-on to open the command-line terminal.

2) Enter the command to open the RViz tool and display the mapping effect:

ros2 launch slam rviz_rtabmap.launch.py

38
5.3.3 Enable Keyboard Control

1) Click-on to open the ROS2 command-line terminal.

2) Enter the command to start the keyboard control node, and press Enter.

ros2 launch peripherals teleop_key_control.launch.py

If you encounter the prompt as shown in the figure below, it means that the
keyboard control service has been successfully activated.

39
3) Control the robot to move in the current space to build a more complete
map. The table below shows the keyboard keys available for controlling
robot movement and their corresponding functions:

Key Robot Action

Short press to switch to the forward


W
state and continuously move forward

Short press to switch to the backward


S
state and continuously move backward

Long press to interrupt the forward or


A
backward state and turn left

Long press to interrupt the forward or


D
backward state and turn right

When controlling the robot's movement for mapping using the keyboard, it's
advisable to appropriately reduce the robot's movement speed. The smaller
the robot's running speed, the smaller the relative error of the odometry,
resulting in a better mapping effect. As the robot moves, the map displayed in
RVIZ will continuously expand until the entire environmental scene's map
construction is completed.

5.3.4 Map Saving

After mapping is completed, you can use the shortcut "Ctrl+C" in each
command-line terminal window to close the currently running program.

Note: For 3D mapping, there's no need to manually save the map. When you use

"Ctrl+C" to close the mapping command, the map will be automatically saved.

40
5.4 lanunch File Analysis

The launch file is located at:

/home/ubuntu/ros2_ws/src/slam/launch/rtabmap_slam.launch.py

 Import Library:

You can refer to the ROS official documentation for detailed analysis of the
launch library:

“https://docs.ros.org/en/humble/How-To-Guides/Launching-composable-node
s.html”

 Set the Storage Path

Use `get_package_share_directory` to obtain the path of the slam package.

 Initiate Other Launch File

41
base_launch: Launch for hardware initialization

slam_launch: Basic mapping launch

rtabmap_launch: RTAB mapping launch

bringup_launch: Initial pose launch

42

You might also like