Tangent Bug Algorithm
Tangent Bug Algorithm
Abdullah ABDULAZIZ
Al Arafat
Micheale Hadera
The University of Girona
Supervisor:
Marc Carreras
Abstract
Computing motion planning algorithm is the very first step for the construction of autonomous
robots in the area of mobile robotics. The Bug 1 and Bug 2 algorithms are two basic path planning
algorithms for a robot. Since these algorithms rely only on tactile sensing, a better Bug algorithm
is expected to be there to outperform both of them. Tangent Bug is the better bug algorithm that
deals with finite distance sensing and heuristic distance measurement between two points which are
not the robot itself. In this report, we illustrate our tangent bug algorithm implementation details
over real e-puck robot.
1 Introduction
The robot path planning problem can be classified into two main categories: one with complete infor-
mation and, another one is with incomplete information. For the first approach, robot has complete
information about the environment. It knows the start and goal configurations. Also, it knows where
the obstacles and passages are. And for the second approach, robot has only limited knowledge such as
the information about the start and goal positions and the reading from distance sensor or tactile sensor.
With this limited information robot tries to find a continuous path from start to goal. The tangent bug
algorithm is one of the limited information path planning algorithms.
Tangent Bug algorithm, similar to the other bug algorithms, assumes that the robot is at a point over
a 2D planar surface, and the obstacles in the environment are stationary. It is initialized by getting the
goal position as input and it provides with the range sensor data at each step, and up-to-date position
of the robot. Unlike Bug 1 and 2 algorithms, tangent Bug relies on range sensor to compute endpoints
of finite continuous segments on obstacle boundaries.
Range data is consisted of the directed distance values of the rays emanating from the robot’s current
position and being scattered in a radial fashion as it is shown in the figure 1. This range sensor is modeled
with the raw distance of ρ(x, θ) which is the distance to the closest obstacle along the ray from x at an
angle θ.
ρ(x, θ) = minλ∈[0,∞] d(x, x + λ[cosθ, sinθ]T ),
where
x + λ[cosθ, sinθ]T ∈ ]i W Oi
2
The robot can detect the obstacles by detecting the discontinuities in the raw distance function that is
sensor model.If sensor rays do not intersect an obstacle raw distance function gives the maximum value.
But if it intersects an obstacle it gives distance to that intersection point.
2 Algorithm
Definitions of the terms and equations that are used in the algorithm are as follow:-
x: - The current position of the robot.
ggoal : - The goal position
Oi : - The ith discontinuity point as shown in figure 2.
d: - Is the estimated distance from the current position to the goal through the local tangent point with
the heuristic function
d(x, qgoal ) = d(x, n) + d(n, qgoal )
The tangent bug algorithm consists of two main behaviors in distinct from the other bug algorithms:
1. Motion to Goal
2. Following obstacle
This behavior is activated either when there is no obstacle sensed on the direction from robot to the goal
or the robot can find a decreasable heuristic distance from a followed obstacle to the goal (Figure 3.)This
sub-planner consists of 2 motion behaviors that are adapted by the robot.
• The first one is the trivial motion where the robot detects the direction to the goal and moves
directly towards it while concluding that there exist no obstacles intersecting the line from robot to
the goal. This motion keeps executed while sensor readings yield maximum range distance result
for the angle corresponding to the direction to the goal. The end of this trivial direct motion comes
when the robot senses an obstacle on the direction to the goal.
3
• After this point, the sub-planner switches to the second part of the motion to goal behavior. In
this behavior the robot detects points of discontinuity on the sensed obstacle. It is important to
note here is that any discontinuity points that separates a continuity interval of an obstacle which
is located away from the direction to the goal is not a point of interest.
A boundary following behavior invoked when heuristic distance increases. When the boundary following
behavior is initiated, the robot starts to move to the direction of the last discontinuity selected from
heading towards the goal behavior. With the direction selected, the robot moves on the tangent line.
This tangent line is perpendicular to the line that connects the robot and the point closest to the robot
on the followed obstacle. This behavior continues to execute while the statement df ollowed >= dreach
holds as shown in figure 4.
where
• df ollowed is the shortest distance between the sensed boundary and goal
• dreach is the shortest distance between blocking obstacle and goal (or distance to goal if no blocking
obstacle visible).
Whenever dreach falls below df ollowed , the robot switches back to the motion to goal behavior. Figure 3
demonstrates the boundary following behavior for two obstacles.
Figure 4: Demonstration of Boundary following behavior (in green) and the corresponding df ollowed and
dreach and heading towards the goal behavior (in red) [1]
4
3 Implementation
The tangent bug algorithm was implemented using Matlab and tested on the real e-Puck robot.
To implement the tangent bug algorithm two functions were built; motion2goal and ObstacleFollowing
beside the main function.
The following figure (Figure 5) shows the flow chart of the main function:
In this function, A flag clear area was created to switch between the two behaviors. Initially, this flag is
active and therefore the motion2goal will be applied. If the flag became disactive, the robot will switch
to the ObstacleFollowing behavior. Finally, the robot will stop when the goal is reached.
5
3.2 The motion2goal function
This function contains two modes; go straight and go tangent. Depending on the IR sensors; IR0, IR7
the robot will enter one of these two modes. That is if the value of IR0 or IR7 is greater than a threshold
(5.5) (there is no obstacle in the sight of the robot), the robot will go straight otherwise it will go tangent.
When the robot enters the tangent mode (that means there is an obstacle in the sight of the robot),
the position of each of the discontinuity points is calculated and then the heuristic distance for each of
them is computed. The robot will follow the discontinuity point with the minimum heuristic distance as
long as it keeps decreasing.
When the heuristic distance starts increasing the clear area flag will be disactived and the robot will
switch to the ObstacleFollowing behavior. Practically, sometimes the heuristic distance increases because
of noisy data therefore a counter was implemented to trace the heuristic distance and if it keeps increasing
for ten times, at this point the clear area flag will be disactived.
6
3.3 The ObstacleFollowing function
The following figure (Figure 7) shows the flow chart of the main function:
In this function, the robot keeps following the boundary of the obstacle. This is done by keeping the
robot at a constant distance from the wall of the obstacle by track the values of the sensors IR1, IR2 if
the obstacle from the right and the sensors IR5, IR6 if the obstacle from the left.
At each step the position of the followed point is computed and then d followed is saved. When we
reach the point that satisfies d reach < d f ollowed, the flag clear area will become active and the robot
will switch again to the motion2goal behavior.
7
4 Results
The following figure (Figure 8) shows the environment used to test the algorithm. Also the videos of the
experiments are attached in the submission file.
The following figure (Figure 9) illustrates the problem of sensor range in tangent bug algorithm:
Sensor range has a crucial role on the algorithm performance. It is advantageous to have a high range
sensor specification to reach the goal quickly. In the e-Puck robot, the sensor range is almost 7 cm which
is very low and therefore the robot enters the tangent mode of the motion2goal behavior for a very short
period of time and then quickly switch to the ObstacleFollowing behavior.
5 Simulation
Simulation is an important aspect of modern science and research. It is a technique that tends to mimic
the real environment and creates a virtual environment for practice and learning that can be applied to
many different disciplines and trainees. It replaces and amplifies real experiences with guided ones. In
autonomous robotics, simulation plays vital role since using simulator researchers can build experimental
environments by gradually adding more complexity, reality and/or specificity to make it more realistic
8
and test the maneuver of a robot over the fabricated environment. It would minimize the effect of un-
necessary changes that could occur in the physical world, eventually cost and time.
There are various simulation platforms that offer increasingly more features that make simulation easier
and also very close to reality. A significant contribution comes from 3D simulation which can be used
to build the robot and the environment in detail. V-REP is one of them. V-REP is a 3D simulator
compatible with Windows, Mac and Linux, which allows modeling of an entire system or only certain
components like sensors, mechanisms, gearing and so on. The control program of a component can be
attached to the object or the scene with objects to model in a way similar to reality. The platform can
be used to control the hardware part, develop algorithms, create factory automation simulations, or for
educational demonstrations. [3]
Features: Since MATLAB lacks an easy to use 3D physical simulation engine, which is often necessary
for testing algorithms before deploying them to a real robot, it has to be interfaced with an 3D simulator
to test the robot. We chose V-REP as a simulator to test our algorithm. The main features of V-REP
simulation platform which led us to chose V-REP are:
• Supports 3D simulation.
Framework of V-REP for remote API: The remote API is a part of the V-REP API framework.
V-REP allows a remote API to control a simulation (or the simulator itself) from an external application
or a remote hardware (e.g. real robot, remote computer, etc.). [4]
The V-REP remote API has several functions for a MATLAB program to interact with the V-REP via
socket communication to reduce lag and network load to a great extend. The remote API also allows
one or several external applications interact with V-REP in a synchronous or asynchronous way (asyn-
chronous by default), and even remote control of the simulator is supported (e.g. remotely loading a
scene, starting, pausing or stopping a simulation for instance).
9
Figure 10: Remote API framework for V-REP [4]
Steps to set the remote API: The next task comprises setting up the remote API of the V-REP to
work with MATLAB. The steps to set the remote API for V-REP to work with MATLAB are stated below.
• Copy three files from the directory of the V-REP app to the project directory. The files are:
– remApi.m
– remoteApiProto.m
– remoteApi.so (for Linux) or remoteApi.dll (for Windows)
• In MATLAb code the following two lines of code should be added to bind the code with V-REP
through remote API.
vrep=remApi(’remoteApi’);
vrep.delete();
• The main LUA script for the robot should be disabled before starting simulation.
• To make sure that the server side is running in V-REP, in a child script, the following command
should be added.
10
5.2 Implementation over Simulation platform:
For this project work, we worked on e-puck robot with initial target to implement Tangent Bug over it.
The important remote API functions in MATLAB for the e-puck robot are:
• simxGetObjectPosition which returns the 3 values representing the position of the robot in the
world co-ordinate. We need only the x-axis and y-axis as the position of the e-puck robot.
• simxGetObjectOrientation: This function returns the 3 values representing the Euler angles (α, β
& γ). From here, we need the β only, as it denotes the Euler angle between x-axis and y-axis.
• simxReadProximitySensor to read the IR sensor reading. It returns several reading as following:
– detectionState: the detection state (false=no detection)
– detectedPoint: the detected point coordinates (relative to the sensor reference frame)
– detectedObjectHandle: the handle of the detected object
– detectedSurfaceNormalVector: the normal vector (normalized) of the detected surface. Rela-
tive to the sensor reference frame
From these reading, we require only the detectionState to check whether the IR sensors detect
anything or not and if they detect something then the detectedPointto compute the distance using
the norm.
• simxSetJointTargetVelocity to set the intrinsic target velocity of a non-spherical joint to achieve a
target velocity.
We implemented motion-towards goal and Obstacle avoidance algorithms over the simulated e-puck robot.
The results of our implementation are shown below.
11
Figure 12: Obstacle avoidance algorithm implemented over e-puck using V-REP.
Figure 13: Motion-towards goal algorithm implemented over e-puck using V-REP.
5.3 Limitations
Although we approached towards implementing Tangent bug algorithm over e-puck robot, we could not
reach our target due to some limitations of V-REP simulator and also for our time limitation. The main
limitations of V-REP simulator for e-puck robot are:
12
• Can not compute the encoder value i.e. the number of steps.
• IR sensors ranges are not similar to the real one.
• The measurement unit is not defined.
6 Conclusion
In this project work, the tangent bug algorithm has been implemented on a real time e-puck robot. We
also tried to extend our implementation over a 3D simulation environment using a virtual e-puck robot,
which we could not finish. Our implementation of Tangent bug algorithm works nicely for the e-puck
robot in real environment despite of limitations of IR sensors range.
This project was interesting, although challenging, since IR sensors of e-puck robot do not support for
long ranges than 7 cm. And also there were some real life constraints as noises and illumination, which
we had to consider to implement the Tangent bug algorithm. For the project work, we used rectangular
configuration spaces as environment.
The successful implementation of this algorithm over the real e-puck robot taught us how to deal with
real environment while we implement path planning algorithm using sensors range.
References
[1] Autonomous Robots, “Lecture 3-a: Bug algorithms”, 2015, lecture Note, UdG, Spain.
[2] Hasan İhsan Turhan, Implementation of Tangent bug algorithm in a non-holomic wheeled mobile
robot PIONEER 3-DX , Mechatronics, Robotics and Control Laboratory, Electrical and Electronics
Engineering Department, Middle East Technical University.
13