Design and Implementation of Fuzzy Logic for Obstacle Avoidance in Differential Drive Mobile Robot

—Autonomous mobile robots based on wheel drive are widely used in various applications. The differential drive mobile robot (DDMR) is one type with wheel drive. DDMR uses one actuator to move each wheel on the mobile robot. Autonomous capabilities are needed to avoid obstacles around the DDMR. This paper presents implementing a fuzzy logic algorithm for obstacle avoidance at a low cost (DDMR). The fuzzy logic algorithm input is obtained from three ultrasonic sensors installed in front of the DDMR with an angle difference between the sensors of 45 0 . Distance information from the ultrasonic sensors is used to regulate the speed of the right and left motors of the DDMR. Based on the test results, the Mamdani inference system using the fuzzy logic algorithm was successfully implemented as an obstacle avoidance algorithm. The speed values of the right and left DDMR wheels produce values according to the rules created in the Mamdani inference system. DDMR managed to pass through a tunnel-shaped environment and reach its goal without hitting any obstacles around it. The average speed produced by DDMR in reaching the goal is 4.91 cm/s.


I. INTRODUCTION
Mobile robots are one of the successful achievements in robotics and provide a path to a new era in automation technology.Advances in artificial intelligence, sensory, and movement technology mean mobile robots can move autonomously with increasingly high levels of accuracy.Mobile robots are widely implemented in various fields such as industry [1]- [3], health [4]- [6], military [7]- [9] and education [10]- [12].In the industrial sector, mobile robots can be used to improve automation systems and perform repetitive work precisely and at lower costs.The health sector also uses mobile robot technology in services that help patients.The use of mobile robot services is very beneficial during the COVID-19 outbreak because it not only prevents the spread of infection and reduces human error but also allows health staff to reduce direct contact.Mobile robots can be used to improve navigation techniques so that they can be used in all terrains.Mobile robots also play an important role in education as they provide a flexible platform to explore and teach various topics such as mechanics, electronics, and software.Mobile robots are widely used because they are the smallest and have relatively lower investment costs than flying and humanoid robots.Apart from that, the way of movement used by mobile robots is also understood by humans.This makes it easier to develop mobile robots that use wheels as propulsion in various applications.
One of the developments in mobile robots in the industry 4.0 era is autonomous mobile robots (AMR).Advances in sensors, data processing, and artificial intelligence have enabled AMRs to become more sophisticated, adaptive, and flexible in carrying out assigned tasks.One of the capabilities AMR needs to prevent damage from collision hazards is obstacle avoidance [13].Obstacle avoidance capabilities to detect, identify, and avoid obstacles efficiently [14].This is the basis for the success of autonomous vehicles and robots operating in dynamic environments [15].Robots that can avoid obstacles will be able to reduce the risk of collisions associated with financial investment in robot development.
One of the algorithms used in obstacle avoidance is fuzzy logic (FL) [16]- [20].Fuzzy algorithms utilize an approach like how humans make uncertain decisions [20].Fuzzy logic allows robots or autonomous systems to make decisions based on understanding the "truth" or "untruth" of a condition [18].This algorithm allows the system to listen and respond to sensory information in a given condition [16].The use of fuzzy logic in obstacle avoidance allows robots to make decisions based on information, such as distance and speed [17] and can respond to the information obtained with an appropriate level of caution [19].A control system that uses fuzzy logic as a controller can be built more simply and flexibly to handle the system without having to build a mathematical model.This is the advantage of fuzzy logic, so it is widely used in various applications.One application that can be solved using the fuzzy logic algorithm is obstacle avoidance on mobile robots.
One important part of fuzzy logic is the fuzzy inference system (FIS).One type of fuzzy inference system that is considered to have advantages in a more interpretable rule base is Mamdani [16], [21], [22].Mamdani FIS is one of the most used approaches in applying fuzzy logic in decisionmaking [16].Mamdani is also considered more popular than Sugeno and Tsukamoto.One of the main characteristics of the Mamdani fuzzy inference system is its ability to develop rules that can be easily interpreted by humans [21].This allows domain experts, such as engineers or experts in a particular field, to creatively construct rules based on their knowledge of the system organized in a fuzzy environment.Apart from that, the Mamdani fuzzy inference system is also flexible in handling devices in data input [22].In the Mamdani method, all input and output variables have a membership function that accommodates all members of the fuzzy set [23].
Mamdani's fuzzy inference system is a type of fuzzy inference system that is very suitable to be applied in the context of obstacle avoidance on mobile robots.The information required by the obstacle avoidance algorithm is generally obtained from sensors installed on the robot body.These sensors will act as the robot's eyes and ears so that it can provide insight and understanding of the surrounding environment.Several sensors used for obstacle detection in mobile robots include ultrasonic [24]- [26], lidar [27], [28], and others.The ultrasonic sensor will work by utilizing ultrasonic sound waves emitted and reflected by surrounding objects [24].This can be used to measure the distance between a robot and an object.Ultrasonic sensors are very useful in detecting obstacles at short to medium distances [25] and in complex environments [26].In the implementation of mobile robots, ultrasonic sensors are widely used because they have the advantage of low cost.Meanwhile, lidar uses laser technology which can create a three-dimensional map of the surrounding environment [27].This gives the robot a higher level of accuracy in detecting objects at long distances [28].The information collected by these sensors will be used by the obstacle avoidance algorithm to make decisions about how the robot should move.
The contribution of this research is to design a fuzzy logicbased obstacle avoidance algorithm using three ultrasonic sensors to control the speed of the mobile robot.This research also uses a low-cost mobile robot platform to implement a real-time obstacle avoidance algorithm.This article is organized as follows: Section 2 explains the robot design used in this research.Section 3 presents the Fuzzy Logic method used to avoid obstacles in the testing environment.Section 4 presents the results of the experiment.The conclusion of this study is presented in Section 5.

II. MOBILE ROBOT
Advances in robot technology have become an important factor in the world of technology and industry.Robots are mechanical or electronic entities that can perform specific tasks automatically, with or without human intervention [29].In other words, robots are automatic machines that can replace human work, even though they do not have a human-like appearance or do not carry out tasks like humans do [30].The use of robots has expanded in various sectors of human daily activities.These sectors include manufacturing, transportation, regional exploration, medical fields, military needs, and laboratory experiments.Robots are generally divided into mobile robots and fixed robots [31].The difference between the two lies in the ability of movement and destruction in carrying out it [32].Robots of the fixed robot type work in a predetermined and fixed environment [33].Meanwhile, mobile robots operate in a constantly changing environment [34].Fixed robots are more frequently used in industry for repetitive tasks, and the location of use has been previously identified, such as robot manipulators that inspect materials moving on conveyors [34].Meanwhile, mobile robots must carry out more complex and dynamic tasks quickly because they operate in unpredictable environments [33].
Fixed robots operate in a fixed position or with minimal movement [35].Fixed robots are usually designed to perform specific tasks in a relatively static environment.One of the most significant advantages of fixed robots is the robot's ability to work tirelessly and consistently, thereby increasing productivity.Fixed robots can handle monotonous and repetitive tasks, allowing human workers to focus on more complex and creative aspects of work [36].Additionally, fixed robots are adaptable as they can be reprogrammed to perform different tasks, which makes them cost-efficient for businesses with growing production needs [37].
Even though they have many advantages, fixed robots also have their challenges.One significant problem is the high initial costs for acquisition and installation, which can be a barrier for small businesses [38].Additionally, programming a fixed robot to perform a new task can be time-consuming and requires skilled technicians [39].Fixed robots can be found in various applications in the industrial world, such as manufacturing, automotive, pharmaceuticals, and others.Meanwhile, mobile robots, which are also known as autonomous robots or mobile autonomous robots, are a type of robot that can move or move places [40].In contrast to fixed robots, which are stationary, mobile robots are equipped with mobility mechanisms that allow them to move and navigate the environment independently.This autonomy is made possible through sensors, cameras, and advanced algorithms that enable robots to sense their surroundings, make decisions, and move across complex terrain.Mobile robots often have wheels, legs, wings, and propellers designed for specific applications and environments.Mobile robots, such as autonomous vehicles, drones, and exploration, are often used in various applications that require mobility and adaptation to environmental changes Riky Dwi Puriyanto, Design and Implementation of Fuzzy Logic for Obstacle Avoidance in Differential Drive Mobile Robot Journal of Robotics and Control (JRC) ISSN: 2715-5072 134 [40].The flexibility and adaptability of mobile robots make them a dynamic and transformative technology with the potential to revolutionize various sectors.
Mobile robots can be divided according to where they move into three main categories: aerial (air), underwater (underwater), and terrestrial (land) [41]- [43].Each category has specific characteristics and is used in various applications based on the environment in which it moves.Aerial robots are a type of mobile robot designed to move and operate in the air or an open environment [41].A drone or unmanned aerial vehicle (UAV) is the most common example.Drones are used in various applications, such as aerial mapping, surveying, aerial photography, surveillance, and entertainment.The advantage of aerial robots is the robot's ability to reach locations that are difficult to reach or potentially dangerous for humans and can provide a unique perspective from the air [41].
Furthermore, underwater robots, such as Remotely Operated Vehicles (ROV) or Autonomous Underwater Vehicles (AUV), move and operate below the water surface, such as in the sea, lake, or river [42].Underwater robots are used for deep sea exploration, underwater environmental monitoring, marine research, seafloor mapping, and other tasks that require operations below the water surface [42].Also, underwater robots are often used in extreme deep-sea exploration and can reach depths that human divers cannot reach.Furthermore, terrestrial robots move on land surfaces, such as on land, roads or the earth's surface [43].This type of robot includes various varieties, such as autonomous cars, rover robots, and service robots, used in transportation, monitoring, agriculture, and facility maintenance applications.The advantages of terrestrial robots are the ability to operate in various terrestrial environments and existing infrastructure, as well as flexibility in dealing with various challenges that may be encountered on land [44].
Mobile robots have several advantages compared to fixed robots, mainly depending on the task type to perform and the work environment [45].Mobile robots such as autonomous cars and drones can move places compared to fixed robots with limited movements [45].This allows the mobile robot to reach different locations quickly and flexibly, according to task requirements.Mobile robots are more adaptive to environmental changes than fixed robots [46].Mobile robots can navigate and interact with changing environments in the field, outdoors, and dynamic external locations.
Meanwhile, fixed robots are usually designed to operate in a stable or well-defined environment.Mobile robots are very suitable for monitoring and exploration, especially in environments that humans cannot reach, such as using drones in forest mapping, underwater probe robots for deep sea exploration, and space rovers for exploring planets [47].Mobile robots can be used for rescue tasks in dangerous environments, such as search and rescue in natural disasters, fires, or other dangerous zones [48].Mobile robots can be operated away from risk locations, maintaining operator safety.Mobile robots are more flexible in various applications [49].Mobile robots can be customized and configured to perform various tasks, while fixed robots tend to be designed for specific tasks.Mobile robots have higher manoeuvrability in carrying out tasks that require movement around objects, obstacles, or complex situations and can adapt to changing conditions more efficiently compared to fixed robots than fixed robots [45].
One type of mobile robot is a differential drive mobile robot, which uses a driving method based on differences in the speed of wheels placed on opposite sides [50].The differential drive mechanism allows this robot to move independently by controlling the right and left wheels' speed [51].This creates flexible robot manoeuvres and allows the robot to easily perform various movements such as turning, turning, or going back and forth.Differential drive mobile robots are often equipped with wheels that can be rotated independently so that the robot can precisely regulate the orientation and direction of the robot's movement [52].Therefore, these robots are suitable for navigation in cramped or complicated environments, such as warehouses, laboratories, or even on exploration missions in unpredictable environments.
The advantages of differential drive mobile robots are simplicity in design and construction and good navigation capabilities in confined environments [53].This robot is often used or applied in automatic sweeping robots, goods delivery devices, or even robotics contests.However, differential drive mobile robots also have several limitations, especially in overcoming rough or uneven terrain [54].To overcome this problem, some differential drive mobile robots are equipped with distancemeasuring sensors or additional navigation systems to increase the robot's ability to explore more complex environments [54].
The low-cost differential drive mobile robot (DDMR) design used can be seen in Fig. 1.The low-cost DDMR design was created by considering the manufacturing costs and function of the DDMR.DDMR consists of three ultrasonic sensors facing forward with an angle difference between the sensors of 45 0 .The three ultrasonic sensors will be used to detect the distance of obstacles in front of DDMR.DDMR uses two DC motors as actuators.The wheel revolutions are measured with two external encoders equipped with encoder disks.
In this research, low-cost DDMR is given obstacle avoidance capabilities to avoid obstacles while moving toward the target.Cheap sensors are expected to function optimally in detecting obstacles.The relationship between the input, microcontroller, and DDMR actuator can be seen in Fig. 2. Three ultrasonic sensors are connected to a microcontroller to obtain the distance value between the robot and the obstacle.DC motor rotational speed data is obtained from two encoders installed on the right and left sides of the robot.The microcontroller carries out speed regulation to the DC motor via the motor driver.

III. METHODS
Fuzzy logic is a method in computer science and mathematics that allows the processing of information that is not clear or exact [55].This concept was first proposed by Lotfi Zadeh in 1965 and has been applied in various fields, such as automatic control decision-making and artificial intelligence [56].Fuzzy logic is based on the idea that many variables and concepts in the real world cannot be expressed strictly or in binary [57].Instead, these elements have degrees of membership in a fuzzy set, which allows measuring truth on a continuum between true and false.Fuzzy logic uses membership functions to describe the extent to which an element is included in a fuzzy set [58].Membership functions can be triangular, trapezoidal, or others that suit the problem context.This function determines the level of truth of a statement.In fuzzy logic, mathematical and logical operations such as conjunction (AND), disjunction (OR), and negation (NOT) are redefined for use in the context of fuzzy sets [59].Apart from that, there is the term fuzzy inference, which is a decision-making process based on fuzzy rules which are explained in the form of "fuzzy rules" or "IF-THEN rules" [60].Each direction describes the relationship between input variables and output variables in the form of a fuzzy set.The fuzzy inference system then combines these rules to produce a final decision [61].
Fuzzy logic deals with uncertainty and subjectivity in modelling and analysis, which are often difficult or impossible to represent in traditional ways.The main concept in fuzzy logic is the use of fuzzy sets, which replace conventional sets, which are strict [62].Fuzzy logic is often used in the field of robotics [63].Applying fuzzy logic concepts in robotics allows robots to overcome uncertainty and complexity in decision-making [64].Fuzzy logic also replaces conventional approaches based on Boolean logic, which only recognizes true or false values [65].The fuzzy logic approach allows the representation of various levels of truth, from true to false.This causes robots to behave more humanely and adaptively in various situations [66].The fuzzy inference system is an important part of fuzzy logic in developing mobile robots [67].Robots are often faced with complex and uncertain situations, such as environmental changes, sensor input variations, and decision-making uncertainty [68].A fuzzy inference system (FIS) is a key component in developing robots that overcome uncertainty and complexity in decision-making and can change environments [69].Using a fuzzy inference system in a mobile robot allows a more adaptive and responsive decision-making process based on sensor data, which is often vague or unclear [70].Mobile robots, often used in various applications such as exploration, logistics, and customer service, need this adaptability.
One important application is using a fuzzy inference system in mobile robot navigation [71].Fuzzy inference systems are used to process sensor data such as distance, direction, and image data from cameras to guide robot movement and avoid obstacles [72].Robots that use a fuzzy inference system can make decisions based on how far the robot approaches an object or obstacle so that the robot can move more safely and avoid collisions [73].This allows robots to deal with diverse situations, such as passing through narrow passageways, interacting with users, or moving in unpredictable environments.It can also be used in mobile robots that must make decisions about speed and direction to reach a destination without exact knowledge of road conditions [74].
Fuzzy inference systems are also used in user-based decisionmaking [75].Robots equipped with fuzzy inference systems can understand human instructions or preferences better than robots that only recognize "right" or "wrong" commands [76].This allows for more natural and efficient interactions between Riky Dwi Puriyanto, Design and Implementation of Fuzzy Logic for Obstacle Avoidance in Differential Drive Mobile Robot Journal of Robotics and Control (JRC) ISSN: 2715-5072 136 humans and robots.Mobile robots also use fuzzy logic to overcome complex situations on the road.In complex track situations, fuzzy logic allows vehicles to make decisions based on finer levels of truth, thereby avoiding accidents and optimizing performance in various conditions [77].
Using a fuzzy inference system in a mobile robot is also very important in an automated delivery system because it allows it to make adaptive and responsive decisions in managing the delivery of goods [78].Fuzzy inference systems help robots make decisions about optimal routes, avoid obstacles, and adjust speed based on changing situations, enabling more efficient delivery of goods [79].In addition, mobile robots used in environmental exploration, such as underwater probe robots or rovers on other planets, rely heavily on fuzzy inference systems to deal with uncertainty in decision-making].Fuzzy inference systems enable robots to move safely in dangerous or unpredictable environments, respond to changing conditions, and achieve exploration goals [80].
In this research, a fuzzy inference system design based on the Mamdani method will be designed, which consists of three inputs and two outputs.The input consists of three ultrasonic sensors, which are defined as the left sensor, middle sensor, and suitable sensor.The output used in this research is two DC motors on the robot body's right and left.The process carried out in the fuzzy inference system can be seen in Fig. 3. Based on Fig. 3, crisp input will be converted to fuzzy form through fuzzification.In fuzzification, the membership of the function of the distance variable is arranged based on three parts: near, medium, and far.The distance variable is obtained from ultrasonic sensor readings on the right, middle, and left.The membership function equation for each sensor can be seen in Equations ( 1)-(3).Fig. 4 (a)-(e) shows the membership function of the distance and speed variable.Each input consists of three set functions: near, medium, and far.The membership functions for the left, center and right sensors are the same.DC motor speed control is carried out to avoid obstacles in front of the DDMR.The membership function of the speed variable in each DC motor can be seen in Equations ( 4)- (5).Fig. 4(b) shows the membership function of the speed variable.
where j is left and right motor.
Based on Fig. 4, the fuzzy rules that will be used for the robot's obstacle avoidance system are listed in Table I.Rules are the link between input and output variables.All rules 1 to 27 in the table are obtained heuristically, where these rules are used as a reference for the robot's output movement on the DC motors.The next step is aggregation, combining the IF-THEN rule output into a single fuzzy set.In this research, it was determined using the MIN function to produce a single fuzzy set.The results of the aggregation process are still fuzzy information.For this reason, it is necessary to carry out calculations that produce a single number as the controller output value (defuzzification).The defuzzification process is carried out to get crisp values from fuzzy values.The defuzzification process in the research uses the Center of Gravity (COG) method, with appropriate calculations in (6).
IV. RESULT AND DISCUSSION The initial test results are mathematical calculations to obtain each rule's left and right motor speed values.The left, center, and right sensor values represent each condition in the rule.Table II shows the speed values for the left and right motor speeds under various conditions.When the left, middle, and right sensor conditions are 6 cm, 6 cm, and 7 cm, respectively, calculating the left and right motor speed values is carried out in several stages, according to Fig. 3.The steps involved in getting the right and left motor speed are explained below.For left motor speed: For right motor speed: Representation of aggregation according to ( 7) and ( 8) can be seen in Fig. 5.The left and right motor speed values can be seen from the defuzzification process.The speed values of the left motor (z * lef t ) and right motor (z * right ) are -16 rpm and -50 rpm, respectively.This shows that when the sensor detects an obstacle close to the DDMR, the speed of the right and left wheels will be negative.Therefore, in that condition, DDMR moves backwards.
Mathematical analysis is carried out on all rules using case examples.The results of mathematical calculations can be seen in Table II.Based on the results of mathematical calculations in Table II, the left and right motor speed values show compliance with the rules created in Table I.
These results are then implemented in DDMR to avoid obstacles in real-time.Implementing fuzzy logic in obstacle avoidance of DDMR is carried out in the test environment according to Fig. 6.DDMR moves from the start position to the goal position autonomously.
The three environments used in testing represent obstacles in the form of passageways lined with walls.Tests were carried out to see DDMR's ability to avoid obstacles, especially in producing turning left and right maneuvers.This research was carried out by forming an angle in the testing environment with a considerable angle value.In the next test, testing in an environment with a narrow corner trap is necessary.A controller is also needed to regulate the robot's speed to reach the desired speed.

Riky
Dwi Puriyanto, Design and Implementation of Fuzzy Logic for Obstacle Avoidance in Differential Drive Mobile Robot Journal of Robotics and Control (JRC) ISSN: 2715-5072 137

( 9 ) 2 )
= 0.43, µ medium (9) = 0.14 Rule of fuzzy inference system (MINIMUM) For left motor speed: • IF Left = near AND Center = near AND Right = near THEN Left Speed = negative (0.43) Riky Dwi Puriyanto, Design and Implementation of Fuzzy Logic for Obstacle Avoidance in Differential Drive Mobile Robot Journal of Robotics and Control (JRC) ISSN: 2715-5072 138 • IF Left = near AND Center = near AND Right = medium THEN Left Speed = positive (0.14)For right motor speed: • IF Left = near AND Center = near AND Right = near THEN Left Speed = negative (0.43) • IF Left = near AND Center = near AND Right = medium THEN Left Speed = negative (0.14) 3) Aggregation using the MAXIMUM rule

TABLE I .
RULES OF FUZZY INFENECE SYSTEM

TABLE III .
RESULT OF THE TEST Riky Dwi Puriyanto, Design and Implementation of Fuzzy Logic for Obstacle Avoidance in Differential Drive Mobile Robot Journal of Robotics and Control (JRC) ISSN: 2715-5072 139