Tải bản đầy đủ (.pdf) (71 trang)

design an automatic mapping vehicle using rplidar

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (5 MB, 71 trang )

<span class="text_page_counter">Trang 1</span><div class="page_container" data-page="1">

<b> </b>

<b>GRADUATION PROJECT </b>

<b>ELECTRONICS AND COMMUNICATIONS</b>

<b>DESIGN AN AUTOMATIC MAPPING VEHICLE USING RPLIDAR </b>

<b>LECTURER: TRUONG NGOC SONSTUDENT: TRAN QUANG THIEN TRAN PHI VU</b>

<b>Ho Chi Minh City, September 2023</b>

<small>S K L 0 1 2 4 9 6 </small>

</div><span class="text_page_counter">Trang 3</span><div class="page_container" data-page="3">

<b><small>Independence – Freedom– Happiness </small></b>

---

<i><small>Ho Chi Minh City, September ..., 2023</small></i>

<b>GRADUATION PROJECT ASSIGNMENT </b>

Major: Electronics and Communications Engineering

Class: 19161CLA

1. Project title: DESIGN AN AUTOMATIC MAPPING VEHICLE USING RPLIDAR

2. Content of the project:

- Research and implement omni wheel into the Mobile Robot. - Research and implement ROS into the Mobile Robot.

- Research a solution to supervise and remotely control robot. - Design and build hardware robot.

- Programming to control the robot’s movement. - Experiment and improve robot’s flexibility. - Evaluate result and write thesis.

3. Final product: The complete of an automatic mapping vehicle

<b>CHAIR OF THE PROGRAM </b>

<i><b>(Sign with full name) </b></i>

<b>ADVISOR </b>

<i><b>(Sign with full name) </b></i>

</div><span class="text_page_counter">Trang 4</span><div class="page_container" data-page="4">

<b><small>Independence – Freedom– Happiness </small></b>

---

<i><small>Ho Chi Minh City, September …, 2023</small></i>

<b>ADVISOR’S EVALUATION SHEET </b>

Major: Electronics and Communications Engineering

Project title: DESIGN AN AUTOMATIC MAPPING VEHICLE USING RPLIDAR Advisor: Ph.D Truong Ngoc Son

<b>EVALUATION </b>

... ... ... ... ...

2. Strengths:

... ... ... ...

... ... ... ...

</div><span class="text_page_counter">Trang 5</span><div class="page_container" data-page="5">

<b><small>Independence – Freedom– Happiness </small></b>

---

<i><small>Ho Chi Minh City, September …, 2023</small></i>

<b>PRE-DEFENSE EVALUATION SHEET </b>

Student name: Tran Quang Thien Student ID: 19161005 Student name: Tran Phi Vu Student ID: 19161003 Major: Electronics and Communications EngineeringProject title: DESIGN AN AUTOMATIC MAPPING VEHICLE USING RPLIDARName of Reviewer: ...

<b>EVALUATION </b>1. Content and workload of the project ...

...

...

2. Strengths: ...

...

3. Weaknesses: ...

<b>REVIEWER </b>

<i><small>(Sign with full name) </small></i>

</div><span class="text_page_counter">Trang 6</span><div class="page_container" data-page="6">

First and foremost, we want to convey our sincere gratitude to the educators at Ho Chi Minh City University of Technology and Education, especially those in the High-Quality Engineering Department.

Our heartfelt thanks go to Dr. Truong Ngoc Son, whose unwavering support and encouragement, as well as diligent monitoring of our research progress, have been invaluable. We also appreciate the thesis examiners and members of the defense committee for their time, feedback, and assistance during the thesis defense.

We extend our thanks to our families, friends, and classmates in the 19161CLA, whose mutual support has been crucial throughout our four years of study.

In conclusion, we extend our best wishes to the students, faculty, and staff of Ho Chi Minh City University of Technology and Education. We wish them good health and continued success in the university's future development.

</div><span class="text_page_counter">Trang 7</span><div class="page_container" data-page="7">

The thesis project “DESIGN AN AUTOMATIC MAPPING VEHICLE USING RPLIDAR” have the main task is to design a mobile robot model with compact design, the ability to build indoor environment maps and move to other areas point on the map. Utilizing a fusion of Lidar technology sensors and algorithms to determine the most efficient route to a destination, the system is constructed on the ROS platform—Robot Operating System, an open operating system that incorporates various tools for facilitating robot development. Additionally, researchers have crafted an omni-wheel robot system designed for optimal indoor mobility. They implemented a PID controller to regulate the robot's speed and rotational angular speed, ensuring it attains the desired velocity.

Furthermore, programming was executed to seamlessly integrate ROS into the holonomic robot, empowering it with mapping and obstacle avoidance capabilities. Another notable feature involves the manual supervision and control of the robot's speed and location through a local monitor.

</div><span class="text_page_counter">Trang 8</span><div class="page_container" data-page="8">

<small>2.1.2 Compare omni wheel robot with normal wheel robot ... 5 </small>

<small>2.1.3 Compare omni 3 wheel with 4 wheels ... 7 </small>

<small>2.1.4 Dynamic Kinematic of the mobile robot ... 9 </small>

<small>2.3.3.2 Costmap configuration process ...16 </small>

<small>2.4 Algorithm for global planner and local planner ...17 </small>

<small>2.4.1 A* algorithm for global planner ...17 </small>

<small>2.4.2 Dynamic Window Approach algorithm to avoid object for local planner ...21 </small>

<small>2.4.2.1 The search spaces ...21 </small>

<small>2.4.2.2 Optimize ...22 </small>

<small>2.5 Protocol ...23 </small>

</div><span class="text_page_counter">Trang 9</span><div class="page_container" data-page="9">

<small>2.6.2 Ziggler Nichol II: Tunning PID parameters Ziggler – Nichols II ...26 </small>

<small>2.7 Low-pass Filter ...27 </small>

<small>2.7.1 Calculation...27 </small>

<small>CHAPTER 3. DESIGN OF ROBOT ...29 </small>

<small>3.1 Overview robot hardware...29 </small>

<small>3.1.1 General diagram of the system ...29 </small>

<small>3.1.2 Wiring diagram ...29 </small>

<small>3.2 Devices used in the project ...32 </small>

<small>3.2.1 Calculate power for choosing motor ...32 </small>

<small>CHAPTER 4. SOFTWARE DESIGN ...41 </small>

<small>4.1 Robot control program ...41 </small>

<small>4.1.1 Robot control program in ROS ...41 </small>

<small>4.1.2 The PID control program ...43 </small>

<small>4.2 Integrate system in ROS ...44 </small>

<small>4.2.1 Mapping ...44 </small>

<small>4.2.1.1 Hector SLAM mapping algorithm ...45 </small>

<small>4.2.1.2 Save map (map server) ...48 </small>

</div><span class="text_page_counter">Trang 10</span><div class="page_container" data-page="10">

Figure 1-1: Some self-propelled robot products ... 2

Figure 2-1: Three-wheel omni robot movement example ... 4

Figure 2-2: Some type of omni wheel ... 5

Figure 2-3: Robot using normal wheel ... 5

Figure 2-4: Robot using omni wheel ... 6

Figure 2-5: Four-wheel omni robot movement ... 7

Figure 2-6: Setting the axis of the robot ... 9

Figure 2-7: Robot's movement ... 10

Figure 2-8: Robot model with ROS... 12

Figure 2-9: Stack structure in ROS ... 13

Figure 2-10: Navigation stack model in ROS [5] ... 155

Figure 2-11: Chessboard 9x8 ... 18

Figure 2-12: g(x) ... 19

Figure 2-13: h(x) = <small>22</small><i><small>a</small></i> <small></small><i><small>b</small></i> ... 19

Figure 2-14: f(x) = g(x) + h(x) ... 20

Figure 2-15: Shortest path for robot tu run from 〇 to △... 21

Figure 2-16: Allowed velocity Va in DWA ... 22

Figure 2-17: Velocity Vd in DWA ... 22

Figure 2-18: Heading of robot in DWA ... 23

Figure 2-19: Integrate ROS for robot ... 24

Figure 2-20: PID controller for system ... 24

Figure 3-1: General diagram robot ... 29

Figure 3-2: Detail block diagram robot modules ... 30

Figure 3-3: Wiring diagram of robot base ... 30

Figure 3-4: Wiring diagram for Raspberry, Lidar and Arduino ... 31

Figure 3-5: Force analysis diagram ... 32

Figure 3-6: Encoder motor JGB-520 178rpm ... 34

</div><span class="text_page_counter">Trang 11</span><div class="page_container" data-page="11">

Figure 3-10: Internal circuit diagram of module L298N ... 37

Figure 3-11: Arduino mega 2560 board ... 38

Figure 3-12: RPLidar A1 ... 39

Figure 3-13: Lipo 3S 2200 mAh 40C 11.1V ... 40

Figure 3-14: Omni wheel 58mm ... 40

Figure 4-1: Flowchart controlling robot in ROS ... 41

Figure 4-2: Transfer data from joystick to setpoint for robot ... 42

Figure 4-3: Joystick GUI ... 42

Figure 4-4: PID diagram ... 43

Figure 4-5: Build a static map from laser ... 45

Figure 4-6: Start up lidar on Rviz ... 46

Figure 4-7: Robot take data from Lidar and draw map on Rviz ... 46

Figure 4-8: Use scanning matching to extend map ... 47

Figure 4-9: Full map ... 47

<i>Figure 5-1: Omni robot base running with angle = 63.435</i><small>o</small> ... 50

Figure 5-2: Robot can move with any angle ... 51

Figure 5-3: Clone the git into the Raspberry ... 52

Figure 5-4: Run roslaunch... 52

Figure 5-5: Map on Rviz ... 52

Figure 5-6: Completed map ... 53

Figure 5-7: Completed robot ... 54

</div><span class="text_page_counter">Trang 12</span><div class="page_container" data-page="12">

ARM Autonomous mobile robot

Transmitter

</div><span class="text_page_counter">Trang 13</span><div class="page_container" data-page="13">

<b>CHAPTER 1. OVERVIEW </b>

<b>1.1 Introduction </b>

In the age of advancing technology and continuous scientific breakthroughs, the prospect of personal robots becoming as ubiquitous as PCs or mobile phones is on the horizon. Robots have evolved into a crucial and integral aspect of daily life, with autonomous robots emerging as effective tools in various fields. The progress in mechatronics has led to the refinement of self-propelled robots, finding widespread applications in industries, commerce, healthcare, and science. They offer numerous advantages to society, gradually replacing human labor in hazardous and toxic environments, rapidly enhancing labor productivity, and actively contributing to the industrialization and modernization processes globally.Given the immense benefits robots bring to humanity, their usage is increasingly prevalent today, featuring diverse sizes, designs, and operational methods, all aimed at aiding humans. Autonomous robots employ various navigation techniques, such as recognizing floor barcodes, capturing environmental images, or utilizing laser-scanning sensors. However, regardless of their form, these robots grapple with three fundamental challenges. Firstly, they must determine their position within a reference coordinate system. Secondly, they need to autonomously devise a plan to navigate and avoid obstacles. Lastly, during the execution of these tasks, robots must comprehend their surroundings through sensors, constituting the cognitive process.Understanding and addressing these challenges demand significant time and effort for in-depth study and research, requiring researchers with high levels of expertise and extensive knowledge. In Vietnam, the utilization of self-propelled cars is not yet widespread due to technological accessibility challenges. However, to meet the evolving needs of life, there is a compelling need to further promote the development and application of autonomous robots. Hence, the research team has chosen the topic "A holonomic mobile robot for transportation of goods in a warehouse using RPLiDAR" to delve into and expand their knowledge, aiming to accumulate valuable experience for the prospective advancement of autonomous vehicles.

</div><span class="text_page_counter">Trang 14</span><div class="page_container" data-page="14">

Figure 1-1: Some self-propelled robot products

<b>1.2 Robot’s objective </b>

The objective of the thesis:

 Build a holonomic robot using the 4 omni-directional wheels model.  Research and implement ROS into the mobile robot for remote control.  Implement Hector SLAM algorithm to map the working environment.  Implement Navigation Stack package to navigate.

<b>1.3 Research method </b>

Considering the indoor operating environment of the robot, our group delved into researching and designing the hardware to support a robot capable of carrying a circular load on top, facilitating seamless movement within indoor spaces. Achieving precise and smooth movement necessitates that the robot's motors can handle both loaded and unloaded conditions. In the initial phase of our research, we focused on selecting a controller for the robot, exploring options like fuzzy controllers, sliding controllers, PID controllers, among others. Opting for the PID controller was a strategic choice, given its established effectiveness and wide application in industrial control systems.

Subsequently, we delved into researching the ROS (Robot Operating System) model and its relevance to our project. Our team studied and implemented ROS on the Ubuntu operating system, installed on the embedded Raspberry Pi computer.

</div><span class="text_page_counter">Trang 15</span><div class="page_container" data-page="15">

In addition, we conducted research on utilizing the lidar sensor, engaged in map scanning, and configured the robot's axis using ROS. Our investigation extended to exploring algorithms for determining the shortest path, optimizing obstacle avoidance for the robot, and validating our findings.Furthermore, research how to use the lidar sensor, performed map scanning, and set up the robot's axis using ROS. They searched for algorithms to find the shortest path, optimize obstacle avoidance for the robot, and verified their findings.

<b>1.4 Thesis’s content </b>

This thesis includes the following:

Chapter 1: Overview (Introduction to current research and proposals relating to the project, choose the suitable devices for application, introduction to the software)

Chapter 2: Theoretical basis (Introduce omni wheel robot model and ROS systems)

Chapter 3: Hardware Design (Requirements of the system, hardware design, connect the hardware and software).

Chapter 4: Software Design (Requirements of the system, software design).

Chapter 5: Experiments and Results (Survey PID controller, robot kinetic and navigation). Chapter 6: Conclusion and Improvement.

</div><span class="text_page_counter">Trang 16</span><div class="page_container" data-page="16">

<b>CHAPTER 2. THEORETICAL BASIS </b>

<b>2.1 Holonomic robot 2.1.1 Introduction </b>

This thesis supplies base knowledge about four omni wheel robot, the basic structure of an omni robot and the simple method to control.

Robot omni wheel which able to move to any direction, any angle without rotation need before move.

In general, robots want to gain that ability to move; it means that there are 3 degrees of freedom in the moving plane (temporarily called the Oxyz plane) including: moving independently along the x, y axes and rotating according to the x, y axes. z-axis. So, a minimum of 3 Omni wheels with independently controlled motors are required because each motor gives the ability to control one degree of freedom (in case of more than 3 wheels, the speed vectors of those wheels are not are linearly independent vectors, in other words, the wheels will have to be constrained to limit the number of degrees of freedom to 3).

<i>Figure 2-1: Three-wheel omni robot movement </i>

To let the robot can move in all directions, it is necessary to use a special wheel. Includes a large wheel and small wheels have an axis tangential to the big wheel and perpendicular

</div><span class="text_page_counter">Trang 17</span><div class="page_container" data-page="17">

Figure 2-2: Some type of omni wheel

<b>2.1.2 Compare omni wheel robot with normal wheel robot </b>

<i>Figure 2-3: Robot using normal wheel </i>

</div><span class="text_page_counter">Trang 18</span><div class="page_container" data-page="18">

<i>Figure 2-4: Robot using omni wheel </i>

<b>Omni wheels Normal wheel </b>

wheels allow for multidirectional movement without the need for complex steering mechanisms. They can move in any direction, including forward, backward, sideways, and diagonally, making them highly maneuverable.

<i>Improved Lateral Movement: Omni </i>

wheels can move laterally with ease, allowing for efficient sidestepping and precise positioning. This makes them beneficial in applications that

movements.

<i>Reduced Turning Radius: Omni </i>

wheels can rotate in place, enabling vehicles or robots equipped with them to perform quick and tight turns within a small radius. This is

simpler design, consisting of a central hub and a tire, which makes

simplicity also leads to lower costs compared to omni wheels.

<i>Stability: Normal wheels offer </i>

greater stability due to their wider contact area with the ground. This stability can be advantageous in applications where maintaining balance and preventing tipping or

</div><span class="text_page_counter">Trang 19</span><div class="page_container" data-page="19">

<i>Disadvantage Reduced”Traction: Due to their </i>

design, omni wheels often have reduced traction compared to normal wheels. The presence of rollers or small wheels at an angle can cause slippage and reduce the overall grip, especially on slippery or uneven

wheels generally enable movement in a single direction, requiring additional steering mechanisms for turning. This can limit their maneuverability, especially in tight spaces or when precise lateral movements are required.

<i>Limited Maneuverability: Normal </i>

wheels generally enable movement in a single direction, requiring additional steering mechanisms for turning. This can limit their maneuverability, especially in tight spaces or when precise lateral

<b>2.1.3 Compare omni 3 wheel with 4 wheels </b>

Figure 2-5: Four-wheel omni robot movement

<b>3 wheels 4 wheels </b>

omni robot typically has a single wheel at the front and two wheels at the rear. This configuration allows the robot to rotate on the

four wheels offers better stability to the robot, making it more suitable for carrying heavy loads or operating on

</div><span class="text_page_counter">Trang 20</span><div class="page_container" data-page="20">

spot, making it highly maneuverable and capable of navigating tight spaces with ease.

<i>Simplicity: With fewer wheels, the </i>

overall mechanical structure of a three-wheel omni robot tends to be simpler compared to a four-wheel omni robot. This can result in

maintenance costs.

<i>Lighter weight: Having one less </i>

wheel often means that the wheel omni robot is lighter than its four-wheel counterpart. This can be beneficial when it comes to energy efficiency, battery life, and

distribution across multiple wheels enhances balance and reduces the risk of tipping.

<i>Enhanced payload capacity: </i>

Four-wheel omni robots generally have a higher maximum load capacity compared to their three-wheel counterparts. This makes them suitable for applications that require transportation of bulky or heavy objects.

<i>Redundancy: Having four wheels </i>

provides redundancy in case of failure or damage to one or more wheels. The robot can continue to function and maintain stability even

robots can be less stable than wheel omni robots, especially when carrying heavy loads or operating on uneven surfaces. The single front wheel can be more prone to tipping or losing traction, affecting the overall stability of the robot.

<i>four-Limited load capacity: Due to the </i>

configuration of the three wheels, these robots may have a lower maximum load capacity compared to four-wheel omni robots. This can restrict their applications in scenarios requiring heavy payload

Compared to three-wheel omni robots, four-wheel omni robots may

maneuverability. While they can still move in any direction, the turning radius might be larger, requiring more space to rotate.

<i>Complexity: With four wheels, the </i>

mechanical structure of the robot

incorporating additional motors, sensors, and control mechanisms. This complexity can lead to higher manufacturing and maintenance costs.”

Comment: After compare the benefit of omni wheel, we decided to use 4 wheels omni robot to gain the maximum value in using omni wheel.

</div><span class="text_page_counter">Trang 21</span><div class="page_container" data-page="21">

<b>2.1.4 Dynamic Kinematic of the mobile robot 2.1.4.1 Forward kinematic </b>

Figure 2-6: Setting the axis of the robot

From the given V<small>1</small>,V<small>2</small>,V<small>3</small>,V<small>4</small> of the four motors, the  , <sub>1</sub>  , <sub>2</sub>  , <sub>3</sub>  is equal 45<sub>4</sub> <small>o</small>,135<small>o</small>,-135<small>o</small>, -45<small>o</small>.

cos( 135)sin( 135)

</div><span class="text_page_counter">Trang 22</span><div class="page_container" data-page="22">

<b>2.1.4.2 Inverse kinematic </b>

<i>Figure 2-7: Robot's movement </i>

From the report [2], The translation velocity of each wheel can be written as follow:

 R is the radius from the center of robot to the omni wheel

<small>OyV1</small>

</div><span class="text_page_counter">Trang 23</span><div class="page_container" data-page="23">

So the equation for 4 motors is:

With     is the velocity of four wheels. <sub>1</sub>, <sub>2</sub>, <sub>3</sub>, <sub>4</sub>

<b>2.2 ROS – Robot Operating System 2.2.1 Introduce to ROS [3] </b>

The Robot Operating System (ROS) is a versatile and robust software framework widely employed in the realm of robotics research and development. Originally developed by Willow Garage and currently overseen by Open Robotics, ROS has established itself as a standard in the field of robot development.

Featuring a distributed architecture, ROS enables seamless communication among robot components through message passing. This facilitates a conducive environment for the development, testing, and integration of various robot functionalities.

Furthermore, ROS provides an extensive ecosystem of software packages, encompassing libraries, tools, and utilities that significantly aid in the process of robot development. Some notable packages within ROS include:

- MoveIt: A motion planning framework that allows robots to plan and execute complex manipulation tasks efficiently and safely.

- OpenCV: A computer vision library that provides extensive tools and algorithms for image and video processing, essential for tasks like object recognition and tracking.

- Gazebo: A high-fidelity robot simulator that enables developers to create realistic virtual environments for testing and validating robot behaviors and algorithms. - ROS Navigation Stack: A set of navigation-related packages that offer capabilities

such as mapping, localization, and path planning to enable autonomous navigation for robots.

- ROS Control: A package that provides a standardized interface for controlling robot hardware, allowing developers to easily integrate and control various robotic systems.

One of the major benefits of ROS is its large and active user community and the sharing of open knowledge. The ROS community is highly engaged and willing to share software

</div><span class="text_page_counter">Trang 24</span><div class="page_container" data-page="24">

packages, tutorials, and experiences, enabling users to quickly access and apply the latest technologies.

Due to its flexibility, ease of use, and capacity for facilitating communication among robot components, ROS has emerged as a crucial tool in the arena of robotics research and development. This system enables developers to concentrate on crafting specific robot functionalities without the need to reinvent fundamental functions. Given its noteworthy influence and ongoing potential for development, ROS plays a pivotal role in propelling the progress of robotics.

Figure 2-8: Robot model with ROS

Third concept – Community: ROS has a vibrant and active community of developers, researchers, and robotics enthusiasts. The ROS community contributes to the development and improvement of ROS by creating packages, sharing code, providing support, and collaborating on projects.

<small>JoystickROS SerialMotor control</small>

<small>Move </small>

<small>base</small> <sup>SLAM</sup>

<small>MapserverRPLidar</small>

</div><span class="text_page_counter">Trang 25</span><div class="page_container" data-page="25">

<b>Packages: It is the primary unit for organizing software in ROS. A package can contain </b>

nodes, libraries, files, or any other files.

The purpose of a package is to create as small as possible program size for easy to reuse.

<b>Metapackage: It is a specialized package which used to represent the relationship between </b>

a group of packages.

<b>Stacks: When packages are combined with specific function, it is called Stack. In ROS, </b>

there are many stacks with different purposes. Similarly, to packages, the place where information of stack is stored is called Stack Manifests.

<i>Figure 2-9: Stack structure in ROS </i>

<b>Message types: It is a description of a message sent back and forth between processes, </b>

stored in the format my_package/msg/myMessagetype.msg. A message defines the data structure for the messages being sent.

<b>2.2.2.2 ROS Computation Graph Level </b>

The Computation Graph functions as an interconnected network of processes within ROS. Each node within the system can connect to this network, engage with other nodes, and share data seamlessly. Key elements of the Computation Graph encompass nodes, Master, Parameter Server, messages, services, topics, and bags.

<b>Nodes: A node is an individual process for computation and control. A node can be created </b>

when a package is successfully compiled, and multiple nodes can be created within the same package. When a node wants to communicate and interact with other nodes, it needs to be connected to the ROS network. In a system, each node serves a different function.

<b>Master: the ROS Master provides a registration and lookup service for the rest of the </b>

Computation Graph. Without the ROS Master, nodes would not be able to discover each other, exchange messages, or call services. The ROS Master acts as a central coordination point for the system, enabling nodes to find and communicate with one another effectively.

<b>Package </b>

<b>Package </b>

<b>Package </b>

<b>STACK</b>

</div><span class="text_page_counter">Trang 26</span><div class="page_container" data-page="26">

<b>Parameter Server: allows data to be stored by keywords in a centralized location. With </b>

these variables, nodes can be configured while they are running or to modify the behavior of nodes. The Parameter Server provides a way to store and retrieve configuration parameters, allowing nodes to access and update shared data during runtime.

<b>Messages: is a simple data structure that consists of defined fields such as integers, floating </b>

points, Booleans, and so on. Messages can also include nested structures and arrays (similar to structs in C). User can develop custom message types based on standard messages, allowing them to define our own message structures tailored to specific application requirements.

<b>Services: The publish/subscribe model in ROS is highly flexible for one-way </b>

communication with multiple entities. However, it may not be suitable for request/reply style communication, which is often used in distributed systems. Therefore, for request/reply communication, services are utilized. Services are defined by a pair of data structures: one for the request and one for the reply. A node provides a service through a named interface, and a client uses the service by sending a request message and waiting for a response. Services enable synchronous and bidirectional communication between nodes, facilitating a request/reply pattern in ROS.

<b>2.3 SLAM </b>

<b>2.3.1 Introduce to SLAM (Simultaneous localization and mapping) </b>

Simultaneous localization and mapping (SLAM) is a popular technique used in robotics to enable robots to navigate and build maps of their environment in real time. In ROS, there are various SLAM algorithms and packages available that utilize sensor data to perform localization and mapping tasks. These algorithms allow robots to move autonomously, perceive their surroundings, and create accurate maps for navigation and planning purposes.

<b>2.3.2 Hector SLAM </b>

Hector SLAM is a method using laser sensor or distance sensor. Laser sensors typically generate 2D or 3D points, known as a point cloud, which is used to represent the shape and distance of the environment around the robot. Due to the high accuracy of laser sensors, the point cloud provides crucial information for constructing accurate and ideal maps for the SLAM process.

Lidar is a sensor commonly used in indoor environments that can help robots build maps and navigate autonomously. The laser-based SLAM system calculates the distance traveled

</div><span class="text_page_counter">Trang 27</span><div class="page_container" data-page="27">

lidar has high accuracy, minimal errors, and can be directly used for localization and navigation purposes. [4]

<b>2.3.3 2D Navigation Stack </b>

2D Navigation stack is used to gather the information, data from odometry, sensor, setpoint and setpoints, and then generate velocity commands to control the robot’s movement. When using the Navigation stack, there are certain hardware requirements:

 Odometry: The robot should be equipped with odometry sensors, such as encoders or wheel sensors, to estimate its position and velocity based on wheel rotations.  Laser Range Finder or Lidar: A laser range finder or lidar sensor is typically used

to provide accurate and reliable distance measurements for obstacle detection and mapping. This sensor helps the robot perceive its surroundings and avoid collisions.  IMU (Inertial Measurement Unit): An IMU sensor, which consists of accelerometers and gyroscopes, is often used to provide information about the robot's orientation and angular velocity. This data is important for sensor fusion and accurate localization.

 Actuators: The robot should have actuators, such as motor controllers or servos, to control its motion based on the velocity commands generated by the Navigation stack. These actuators enable the robot to move and navigate through the environment.

Navigation stack only send velocity directly to robot controller to gain the robot’s setpoint values such as linear velocity in x-axis, y-axis and angular velocity.

Figure 2-10: Navigation stack model in ROS [5]

</div><span class="text_page_counter">Trang 28</span><div class="page_container" data-page="28">

<b>2.3.3.1 Costmap 2D </b>

the environment. It stores information about obstacles and inaccessible areas for the robot. The Costmap 2D utilizes sensor data from a pre-built map and updates the costmap with obstacle information.

The costmap represents different levels of cost or "inflation" around obstacles, indicating how difficult it is for the robot to navigate through those areas. The cost values help the robot's navigation algorithm to plan paths that avoid obstacles and prefer areas with lower costs.

By continuously updating the costmap with sensor data, the robot can perceive its surroundings and adapt its path planning accordingly, ensuring safe and efficient

<b>2.3.3.2 Costmap configuration process </b>

local navigation.

Global Navigation: Global navigation involves planning a path for the robot to reach a target or goal location within the map. It is typically used for longer distances or when the target location is far away. The global navigation algorithm considers the entire map and computes an optimal path that takes into account obstacles and the desired destination. This path is planned in advance and can be adjusted if the environment changes. Global navigation helps the robot efficiently navigate to distant targets.

Local Navigation: Local navigation focuses on generating a path in the immediate vicinity of the robot. It is used for short distances or to avoid obstacles encountered during robot movement. Local navigation algorithms take into account real-time sensor data, such as from a laser range finder or other obstacle detection sensors, to generate a path that avoids obstacles and leads the robot towards its goal. Local navigation enables the robot to react quickly to its immediate surroundings and make necessary adjustments to ensure safe and obstacle-free movement.

Global navigation utilizes the global costmap, while local navigation utilizes the local costmap. Each costmap has its own specific parameters and shared parameters.

The "obstacle_range" attribute is used to define the maximum distance at which the sensor can read and update obstacle information in the costmap. If the robot detects an obstacle within a distance smaller than "obstacle_range," it will place an obstacle in the costmap.

</div><span class="text_page_counter">Trang 29</span><div class="page_container" data-page="29">

from the laser information on the obstacle surface can be updated without identifying the entire obstacle. With this information, we can construct a map.

The "inflation_radius" attribute is used to maintain the minimum distance between the robot's center and the obstacle in the costmap.

The "laser_scan_sensor" attribute is used to declare information about the sensor type and is used to add/remove obstacles in the costmap.

Information for declaring variables in the "global_costmap_params.yaml" file:

- The "global_frame" and "robot_base_frame" attributes define the global frame and the frame attached to the mobile base, respectively.

- The "update_frequency" attribute is used to declare the update frequency for the costmap.

- The "static_map" attribute is used to declare whether or not to use a pre-built map.

- The "publish_frequency" attribute is used to determine the frequency of updating information.

- The "rolling_window" attribute is used to keep the costmap centered on the robot as it moves.

<b>2.4 Algorithm for global planner and local planner 2.4.1 A* algorithm for global planner </b>

A* is a search algorithm in graph theory [3], used to find a path from a current vertex to a goal vertex by utilizing a heuristic function to estimate the distance, also known as the Heuristic function.

From the current state, A* constructs all possible paths using the Heuristic function to evaluate the best possible path. The Heuristic function is evaluated differently depending on the specific problem. A* always finds the shortest path if such a path exists.

A* maintains a set of paths through the graph, from the starting vertex to the goal vertex. The priority order for a path is determined by the evaluation of the Heuristic function:

</div><span class="text_page_counter">Trang 30</span><div class="page_container" data-page="30">

Question: Given a chessboard of size n x n, find the shortest path from point 〇 to point △ under the following conditions:

- White cells represent valid paths.

- Black cells represent obstacles and cannot be traversed.

- At any given cell, movement is only allowed in the upward, downward, leftward, or rightward directions, without diagonal movement.

</div><span class="text_page_counter">Trang 32</span><div class="page_container" data-page="32">

Point P(1,0) has two neighboring points with the following values: P(2,0) = 5.2 and P(1,1) = 4.8. Adding P(0,1), which is already available, we have three points: P(0,1) = 3.2, P(2,0) = 5.2, and P(1,1) = 4.8.

The value of P(2,0) is closest to the value of 8.6. Therefore, P(2,0) is chosen as the next point to be evaluated. By following the same steps, we obtain the image table above. After reach the △, we have the shortest path below:

</div><span class="text_page_counter">Trang 33</span><div class="page_container" data-page="33">

Figure 2-15: Shortest path for robot tu run from 〇 to △.

<b>2.4.2 Dynamic Window Approach algorithm to avoid object for local planner </b>

The Dynamic Window Approach (DWA) algorithm is used to find an appropriate control signal to send to the robot in order to navigate it to the destination safely and quickly, based on a pre-planned global path. This algorithm consists of two main steps: reducing the search space for velocity and finding the optimal velocity within that search space. [3]

<b>2.4.2.1 The search spaces </b>

The permissible velocities are determined based on the following three steps in the search space reduction:

Circular Trajectory: The algorithm considers a circular trajectory defined uniquely by a

robot's potential path within the search space.

Feasible Velocities: Feasible velocities are selected to generate a safe trajectory for the robot to avoid obstacles. A pair of velocities (v, w) is considered feasible if the robot can stop before the nearest obstacle without collision along the corresponding trajectory. Feasible velocities are defined as follows:

<small>( , )2.( , ).</small> <i><sub>b</sub></i> <small>2.( , ).</small> <i><sub>b</sub></i>

<i><small>Va</small></i><small></small> <i><small>v</small></i> <small></small> <i><small>dist v</small></i>  <i><small>v</small></i> <small> </small> <i><small>dist v</small></i>   (2.12) Since,

collision.

</div><span class="text_page_counter">Trang 34</span><div class="page_container" data-page="34">

( , )

<i>dist v</i>  is the lowest distance that robot stop in front of obstacle without collision.

velocity for robot moving without collision.

<i>Figure 2-16: Allowed velocity Va in DWA </i>

Dynamic Window: The dynamic window represents the intersection between the robot's feasible velocities and the permissible velocities within the search space. It is obtained by limiting the linear and angular velocities to the feasible range based on the robot's dynamic constraints, such as maximum acceleration and maximum angular velocity.

<i><small>Vd</small></i><small></small> <i><small>v</small></i> <i><small>v</small></i><small></small> <i><small>va v t va v t</small></i><small>    </small>    <small> </small><i><small>t</small></i> <small> </small><i><small>t</small></i> (2.13)

<i>Figure 2-17: Velocity Vd in DWA </i>

After completing the three steps, we find the search space.

<b>2.4.2.2 Optimize </b>

( , ) . ( , ) . ( , ) . ( , )

To optimize the output velocity, the objective function should have a maximum value. To

</div><span class="text_page_counter">Trang 35</span><div class="page_container" data-page="35">

- Target heading: heading represents the progress towards the destination of the robot. The value will be maximized when the robot moves directly towards the destination. The value of ℎ𝑒𝑎𝑑𝑖𝑛𝑔(𝑣, 𝜔) is calculated using the formula 180 − 𝜃, where 𝜃 is the angle between the robot's direction and the destination point.

<i>Figure 2-18: Heading of robot in DWA </i>

nearest obstacle along its curved trajectory. This value will be very large if there are no obstacles on its path. The smaller this value, the higher the likelihood of the robot facing an obstacle, and it will move around that obstacle.

supports faster movement.

- The coefficients 𝛼, 𝛽, 𝛾 are chosen to be appropriate for the characteristics of the robot and the operating environment. When the objective function has the highest value, the optimal trajectory will be selected with the best velocity (𝑣, 𝜔), which is the result of the algorithm.

<b>2.5 Protocol </b>

<b>2.5.1 ROS communication </b>

ROS Serial is a communication library that allows the exchange of data between a computer running the Robot Operating System (ROS) and a microcontroller or embedded system. It enables the integration of ROS with low-level hardware platforms that do not have native support for ROS.

ROS Serial provides a lightweight and flexible protocol for serial communication, allowing ROS nodes to send and receive messages and commands over a serial port. It supports both

</div>

×