Mobile robotics fuzzylogic and pso

18
AI APPLICATIONS (FUZZY LOGIC AND PSO) IN MOBILE ROBOTICS ASSIGNMENT 2012 – 2013 Submitted by:- Devasena Inupakutika MSc. Automation and Robotics @00346444 1 Artificial Intelligence in Mobile Robotics

Transcript of Mobile robotics fuzzylogic and pso

AI APPLICATIONS (FUZZY LOGIC AND PSO) IN MOBILE

ROBOTICS ASSIGNMENT 2012 – 2013

Submitted by:- Devasena Inupakutika

MSc. Automation and Robotics @00346444

1 Artificial Intelligence in Mobile Robotics

OUTLINE

S.No Topic Page No.

1 Abstract 3

2 Introduction 4

3 Objectives 5

4 Theory 5

5 Assignment Description 7

6 Assignment Development 11

7 Results 15

8 Discussion 17

9 Conclusion 17

10 References 18

2 Artificial Intelligence in Mobile Robotics

ABSTRACT

Optimal target reaching is an important concept in mobile robotics and computational intelligence. Motion planning is one of the important tasks in intelligent control of autonomous mobile robot. In this present course project, controllers have been developed using algorithms for intelligent navigation of mobile robot with path planning and obstacle avoidance in a unknown and known environments (for target reaching). The developed controllers pilot robots in an unknown environment using kinect sensor / laser scanner. The robot can detect real time obstacles present in the environment. However, there are few uncertainties in dealing with obstacle detection, avoidance and target reaching due to trade-offs in sensors specifications.

The robot moves within the unknown environment by sensing and avoiding the obstacles coming across its way towards the target. This work demonstrates the algorithms employed for development of controller for robot based on Artificial Intelligence concepts to perform above tasks efficiently are :

1. Fuzzy logic with basic obstacle avoidance and dynamic window approach for path planning and goal reaching in the first part.

2. The use of multiple robots to accomplish a task is always preferrable over the use of individual robots. A major problem with individual robots is the idle-time which can be reduced by the use of multiple robots thus making the task and process economical. This work involves path planning and co-ordination between robots in a static obstacle environment. Here, Particle Swarm optimization has been used for this purpose in second part.

3 Artificial Intelligence in Mobile Robotics

INTRODUCTION

Autonomous robots which can operate even in the absence of human operators re required in the field of robotics. For this purpose and accomplishing tasks, robots have to be intelligent, choose their actions and find their way out in order to achieve a particular purpose. Moreover, it's necessary to plan a collision free path. Therefore, the main purpose of this work is to apply Artificial intelligence strategies for path planning for autonomous mobile robots while searching for a collision free path to target.

Many works and several approaches have been implemented in this field but the purpose of this course project is to use Fuzzy logic through fuzzy lite library for improved decision making of the mobile robot when it faces an obstacle during its navigation towards destination (first part) and PSO for global path planning of all agents in the workspace.

The first approach of fuzzy logic has been done using following:

1. ROS (Robot Operating System – Fuerte/ groovy distro)2. C++ language3. SLAM, gmapping, turtlebot_navigation, roomba_500_series, openni_kinect packages4. Fuzzylite stand-alone library5. Turtlebot with Roomba 521 base with Kinect as a sensor attached to it.

The second approach of PSO is in progress and being simulated on a graphical user interface in C++ language.

4 Artificial Intelligence in Mobile Robotics

OBJECTIVES

The main objectives of this work is to accomplish optimal target tracking with collision avoidance and co-ordination between multiple-robots in a known environment with static obstacles. This has to be achieved by using artificial intelligence fuzzy logic principles in a known/ unknown environment and by doing path-planning for robots using swarm intelligence optimization technique called PSO (Particle swarm optimization).

THEORY

The navigation process is the most important key issue in the design of autonomous robots. It provides the necessary information to do path planning and gives information for monitoring the position of robot during the execution of planned path. It is important that the mobile robot have the ability to build and use models of its environment that enable it to understand the structure of the environment. The major task for path-planning for a robot is to search for collision-free path. Navigation consists of two essential components known as localization and planning. Hence, a reliable map is essential for navigation without which robots wouldn't be able to accomplish the goals of optimally reaching the target.

The heuristic approaches like Fuzzy Logic (FL) and Particle Swarm Optimization (PSO) gave suitable results for mobile robot navigation (target reaching and obstacle avoidance).

The control of the robot to build a map of the environment and also localization and navigation tasks are done using ROS and its package stacks. It's a software framework for robot software development, providing operating system like functionality on a heterogeneous computer cluster. Proper hardware and software architectures were used as a part of this work in order to implement our objective and get the results. The solution of the problem of SLAM has been one of the successes in robotics field as it makes robot truly autonomous. If a mobile robot is placed at an unknown location in an unknown environment, SLAM builds a consistent map of the environment while simultaneously determining it's location. It has been implemented on indoor, outdoor, underwater, under ground and space mobile robots. Another important aspect along with localization and mapping is obstacle avoidance. Several algorithms have been implemented so far.

All the obstacle avoidance approaches find a path from actual robot position to target position, all these parameters are inputs of the algorithms, the output is the optimal path from source to target. Efficient navigation means finding a collision free path. Efficient obstacle avoidance should be optimal w.r.t the overall goal, actual speed and kinematics of the robot, on board sensors, the actual and future risk of collision. The main motive of planning and navigation is as presented in figure 1.

5 Artificial Intelligence in Mobile Robotics

Figure 1. Navigation

In order to improve the decision making capability of robot implemented using concept mentioned as per figure 1 above, so as to proceed in a direction with maximum depth avoiding collisions, Fuzzy logic heuristic approach was made use of. It deals with reasoning i.e. approximate rather than fixed and exact. The main reason behind using fuzzy logic is that it handles the concept of partial truth, where the truth may range between completely true and completely false.

To use it on ROS, Fuzzylite which is a cross-platform, free open-source Fuzzy Logic control Library written in C++ was used as a part of this course work. It provides a simple way of creating fuzzy logic engine using object oriented programming. We can easily add our own features to the library by using inheritance. It relies on STL that comes with C++. It contains all the functions froma fuzzy logic controller. Fuzzylite library was used as a stand alone library on ros and with it's packages.

In this project, basic obstacle avoidance approach which allows robot to follow the path with maximum depth and dynamic window approach for reactive collision avoidance have been used. This approach is directly derived from the motion dynamics of the robot. The next steering command in a short time interval is only considered so as to avoid complex motion planning problems. Search space is potentially reduced to admissible velocities and results in circualar trajectories. The trajectories depend on the laser scan data received from sensor fitted to robot. Among these velocities, the combination of translational and rotational velocity which maximizes objective function (that measures the progress towards goal location) is chosen. The objective function is as below:

G(V,~) = o(a.heading(v,w)i-P.dist(v,w)+y.vel(v,w)) where o is the target heading, P is the clearance and y is forward velocity. These values are such that the objective function is maximized.

Further, as discussed in previous sections, multiple robots usage is preferred over single robot accomplishing task, the approach of particle swarm optimization is being simulated on C++. This approach is inspired by the social behaviour of bird flocking or ant colonies. It's concept is that each particle randomly searches through problem space by updating itself with its own memory and social information gathered from other particles. In this work, PSO particles are considered as robots. It has been used in various applications for optimization.

6 Artificial Intelligence in Mobile Robotics

DESCRIPTION OF ASSIGNMENT

The methodology and technical approaches used to perform optimal target reaching (path planning and obstacle avoidance) using a turtlebot with roomba base 521 series and Xbox 360 Kinect as it's sensor and also autonomously navigate the environment are described.

TURTLEBOT :

On a ROS Fuerte (Turtlebot netbook) and Groovy (Workstation) installation (Ubuntu 12.04)

• Permission for USB must be changed using → sudo chmod 777 /dev/ttyUSB*

• roomba500_light_node from roomba_500_series package works fine with 521 series roomba:

Figure 2. Turtlebot with Kinect

At workstation, the user issues the navigation commands and sees the current position of the robot, the map generated with SLAM and the obstacles in the environment.

OPTIMAL TARGET REACHING APPROACH using DYNAMIC WINDOW algorithm:

The ability to navigate in the environment is the most important capability for a mobile robot. It consists of performing activities that concerns with specific areas in robot environment and avoiding dangerous situations such as obstacles. It's robot's ability to determine it's position in it's frame of reference and then plan it's own path towards target location, the combination of which is described in figure 1 in last section.

7 Artificial Intelligence in Mobile Robotics

The process for navigation and setting up ROS navigation stack that was followed during this work is as per flowchart shown below:

Figure 3. Robot Navigation Flowchart

The kinematics of the robot is considered by searching a well chosen velocity space in dynamic approach for obstacle avoidance:

1. Circular Trajectories → The dynamic window approach considers only circular trajectories uniquely determined by pairs of translational and rotational velocities.

2. Admissible velocities → A pair is considered admissible, if the robot is able to stop before it reaches the closest obstacle on the corresponding curvature.

3. Dynamic Window → The dynamic window restricts the admissible velocities to those that can be reached within a short time interval given the limited accelerations of the robot .

Using move, the objective function stated in last section is optimized.

FUZZY CONTROL HEURISTIC APPROACH IN NAVIGATION :

This report presents a fuzzy controller technique in navigation with obstacle avoidance for a mobile robot using Fuzzylite stand alone C++ library. Fuzzy logic is used to control the movement of the robot towards the goal while avoiding obstacles along the way by changing it's direction of motion. The position of the robot, obstacle and target are considered and Kinect mounted on turtlebot as shown in figure 2 is used to gather these information. The point cloud data captured by kinect is converted into depth data (laser scan data) using PCL to laser scan package to get desired positions and this data is then integrated with the fuzzy controller engine developed making above discussed algorithm more efficient compared to simple navigation technique with obstacle avoidance.

8 Artificial Intelligence in Mobile Robotics

The turtlebot used for this work is a personal household autonomous vaccum cleaner robot with 2 wheels (2 motors) controlled by roomba base. The navigation set-up involves a kinect which was attached at the top of turtlebot to obtain view of the environment it has been put into. It captures position of robot using odomotery data, obstacles and the goal as shown in figure below:

Figure 4. Navigation System

The above captured robot and goal poses are then passed as input to fuzzy controller, which determines the path of mobile robot to the target while avoiding any obstacles that it will face on the way. The fuzzy controller's output is the movement of robot by controlling it's translation and rotation of wheels.

The fuzzy system is the non-linear mapping of input vector to scalar output (using Mamdani system). This system thinks the way human brain thinks and looks at the world which is quite imprecise, uncertain and complicated.

PSO ALGORITHM APPROACH:

It's a population based stochastic optimization technique inspired by social behaviour of bird flocks and ant colonies. The algorithmic sequence of PSO starts with population of robots (particles) as shown by a flowchart below:

9 Artificial Intelligence in Mobile Robotics

Figure 5. PSO Algorithm Flowchart

10 Artificial Intelligence in Mobile Robotics

ASSIGNMENT DEVELOPMENT

1. NAVIGATION STACK SET-UP:

The first and foremost thing while developing algorithm for robot to optimally reach target is to set up Navigation stack specific to robot (turtlebot here). This consists of three component checks:

1. Range sensors → The data from kinect needs to be checked if it's proper or not. The data from kinect is a huge point cloud data. To simplify the task, this data has been converted to laser scan data so that we have depth data using PCL to laser scan package as shown below:

Figure 6. Kinect_laser.launch file (PCL to laser scan conversion)

2. Odometry → The odometry data needs to be checked as to how reasonable it is for translation and rotation.

3. Localization → After range sensors and odometry starts performing reasonably, gmapping (SLAM) should be run and robot should either be keyboard or joystick teleoperated to move around in the environment to generate map.

ROS navigation stack is set up once above three steps are done and the robot is publishing information about relationship between it's coordinate frames using tf, this stack then uses information from sensors to avoid obstacles in the world provided sensors are either publishing sensor_msgs/LaserScan or sensor_msgs/PointCloud messages over ROS. It assumes that odometry information is being published using tf and nav_msgs/Odometry messages. All the transform packages have been created for /map to /odom, /odom to /base_link and /base_link to /camera_link. Then the navigation stack sends velocity commands using geometry_msgs/Twist to robot's base

11 Artificial Intelligence in Mobile Robotics

(roomba here).

Figure 7. ROS Navigation Stack Setup

2. FUZZY INFERENCE SYSTEM – MAMDANI FUZZY INFERENCE ENGINE:

The next part is developing code based on dynamic window approach algorithm in ROS C++ by creating package and including fuzzylite library in the package itself. Mamdani Fuzzy inference system is used for creating this fuzzy controller based path planning, obstacle avoidance code for reaching target location by robot. The pseudo code of the fuzzy inference system is as shown below:

// Fuzzylite library header file.

#include <fl/fuzzylite.h> #include <fl/Engine.h> #include <fl/variable/OutputVariable.h> #include <fl/variable/InputVariable.h> #include <fl/rule/mamdani/MamdaniRule.h> #include <fl/rule/RuleBlock.h> #include <fl/term/Trapezoid.h> #include <fl/term/Rectangle.h>

//Fuzzy Variables.

fl::Engine* engine = new fl::Engine("Control"); fl::InputVariable* depth_avg = new fl::InputVariable; fl::OutputVariable* fangular = new fl::OutputVariable; fl::OutputVariable* flinear = new fl::OutputVariable;

12 Artificial Intelligence in Mobile Robotics

// Obstacle avoidance logic with fuzzy inference engine logic.

for (int i = 0; i < numPts; i++) { double distance = msg->ranges[i] - 0.08; double angle = msg->angle_min + i * msg->angle_increment; // bounds check if (distance < msg->range_min || distance > msg->range_max) {

continue; } foundAny = true; // x-coordinate of point double forward = distance * cos(angle); if (abs(angle) > cutoffAngle) {

double lCutoff = abs(robotRadius / sin(angle)); if (distance < lCutoff) {

cout << "blocked at angle: " << angle << endl; blocked = true; blockAngle = angle;

} } else if (forward < cutoffDist) {

cout << "forward too small: " << angle << endl; blocked = true; blockAngle = angle;

}

//Beginning of Fuzzy Inference System. else if(distance >= 1.0) { float ang_out = 0.0; float lin_out = 0.0; fl::scalar in; if(forward > distance) in = distance; else in = forward; depth_avg->setInput(in); engine->process(); float out1 = fangular->defuzzify(); float out2 = flinear->defuzzify(); if(in < 0.8) out2=0.0; else if(in > 1.5) out1=0.0; lin_out=(-1*out2); ang_out = out1; linear = lin_out; angular = ang_out; ROS_INFO(" The robot linear and angular velocities are: %f %f ",linear,angular); }

13 Artificial Intelligence in Mobile Robotics

//Fuzzy Variables and Rules Definition. depth_avg->setName("DepthAverage"); depth_avg->setRange(0.000,8.000); depth_avg->addTerm(new fl::Trapezoid("NEAR",0.000,0.500,0.800,1.500)); depth_avg->addTerm(new fl::Trapezoid("FAR",0.800,1.500,7.000,8.000)); engine->addInputVariable(depth_avg);

fangular->setName("AngularVelocity"); fangular->setRange(0.000,1.000); fangular->setDefaultValue(0); fangular->addTerm(new fl::Rectangle("LOW",0.000,0.200)); fangular->addTerm(new fl::Rectangle("HIGH",0.600,1.000)); engine->addOutputVariable(fangular);

flinear->setName("LinearVelocity"); flinear->setRange(0.000,0.300); flinear->setDefaultValue(0); flinear->addTerm(new fl::Rectangle("SLOW",0.000,0.100)); flinear->addTerm(new fl::Rectangle("FAST",0.100,0.300)); engine->addOutputVariable(flinear);

fl::RuleBlock* ruleblock1=new fl::RuleBlock; ruleblock1->addRule(fl::MamdaniRule::parse("if DepthAverage is NEAR then AngularVelocity is HIGH", engine)); ruleblock1->addRule(fl::MamdaniRule::parse("if DepthAverage is FAR then AngularVelocity is LOW", engine)); engine->addRuleBlock(ruleblock1);

fl::RuleBlock* ruleblock2=new fl::RuleBlock; ruleblock2->addRule(fl::MamdaniRule::parse("if DepthAverage is NEAR then LinearVelocity is SLOW", engine)); ruleblock2->addRule(fl::MamdaniRule::parse("if DepthAverage is FAR then LinearVelocity is FAST", engine)); engine->addRuleBlock(ruleblock2);

engine->configure("Minimum", "Maximum", "AlgebraicProduct", "AlgebraicSum", "Centroid");

The complete source code of fuzzy controller and part of PSO simulation code is attached with this assignment report as a seperate zip file for ROS package.

14 Artificial Intelligence in Mobile Robotics

RESULTS

1. The result of setting up of ROS navigation stack for turtlebot connected to Kinect can be cross-checked with tf frames by ruuning following command and the screenshot is as below:

rosrun tf view_frames

Figure 8. Links between Robot Coordinate frames

15 Artificial Intelligence in Mobile Robotics

2. Screenshots of the implementation of fuzzy controller based path planning and obstacle avoidance algorithm for optimal goal reaching are as below:

Path taken by robot analysed on turtle sim is as below:

16 Artificial Intelligence in Mobile Robotics

The position of obstacles is highlighted and robot footprint along with trajectory of robot are more clearly visualized in the map created on RViz which is attached with Mapping assignment report.

DISCUSSION

We encountered few issues during the implementation of this project due to the use of kinect as a rgb sensor rather than laser scanner. The Kinect sensor has around 60 degrees field of view, whereas hokuyo / LIDAR sensors have wider range of 240 to 270 degrees of field of view. Hence, when it is required to gather lots of information from environment, i.e. while estimating change in robot position, it is advisable to use sensors with wider field of view.

Also, Kinect can cover between 0.45 to 6 meters range. But laser scanners have different minimum coverage distance. This becomes quite important when it is required to avoid when robot is getting too close to obstacles. With Kinect, the robot in this case just hits the wall. The reason behind this is the use of pointcloud_to_laserscan package whose precision is less than data collected from original laser scan. The obstacle avoidance is not perfect as the one with real laser scanner when the obstacles haven't been detected in the map at earlier stages which increases crashes with obstacles in the beginning.

However, this can be improved by integrating the working of laser with kinect. Also, the dynamic window approach used here depends on obstacle weight. In case the robot encounters huge obstacles and they are too near, the robot just crashes due to its weight and above reasons mentioned (precision of kinect data).

CONCLUSION

The main idea behind using dynamic window approach for trajectory planning and obstacle avoidance is that it derives next possible velocities for robot based on it's dynamics. However as discussed due to imprecise data from kinect rgb sensor and turtlebot odometry (for robot poses), the result was not up to the mark.

Hence, we developed a fuzzy controller based on Mamdani fuzzy inference engine to improve the speed variation of robot when it faces obstacles and further decision making and planning of trajectory accordingly. The PSO simulation is currently in progress.

17 Artificial Intelligence in Mobile Robotics

REFERENCES

[1] http://www.hessmer.org/blog/2011/04/10/2d-slam-with-ros-and-kinect/

[2] http://code.google.com/p/fuzzylite/

[3] http://www.ros.org/wiki/navigation/Tutorials/RobotSetup

[4] http://www.ros.org/

[5] The Dynamic Window Approach to Collision Avoidance by Sebastian Thrun

[6] https://sites.google.com/site/slamnavigation/

[7] http://en.wikipedia.org/wiki/Particle_swarm_optimization

[8] PSO matlab lectures

18 Artificial Intelligence in Mobile Robotics