1. Introduction
To navigate through unknown environments, micro aerial vehicles (MAVs) need to detect and avoid obstacles. There are many types of sensors to detect obstacles such as RADAR (RAdio Detection And Ranging), LiDAR (LIght Detection And Ranging), and ultrasonic sensor. RADAR and LiDAR have a good performance in terms of the operation range and accuracy to detect obstacles around the MAV. However, they have disadvantages in terms of operating time due to heavy weight and energy consumption. Although lightweight and low power consumption products have been developed recently [
1], they are still expensive. Ultrasonic sensors are small and light but typically have poor range accuracy. Vision sensors, on the other hand, have various advantages such as lightweight, large detection area, fast response time, low cost, and rich information about the environment around the MAV.
There are various obstacle avoidance methods using the vision system. Tomoyuki et al. [
2] and Abdulla et al. [
3] conducted obstacle avoidance experiment with a monocular camera using the feature match algorithms such as SURF (Speeded-Up Robust Features) and SIFT (Scale-Invariant Feature Transform). The algorithms extract the descriptors from the obstacles and detect them using the expansion of descriptors. However, they performed the experiments with the off-board computer (i.e., desktop PC) since the feature matching algorithm demands a heavy computational power. On the other hand, optical flow-based obstacle avoidance methods can be readily applicable to the lightweight on-board computer of the MAV as they require much less computational power compared to the feature-based algorithms [
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14]. Souhila et al. implemented an obstacle avoidance strategy for the ground vehicle by changing a heading angle according to the amount of the optical flow difference between the left and right half planes of the image, called the balance strategy [
4]. Yoo et al. applied the balance strategy to the multi-rotor UAV and carried out simulations in a virtual 3-D space [
12]. Eresen et al. made the UAV detect obstacles and junctions using the optical flow and turn at a junction in the Google Earth environment [
11]. The limitation of the balance strategy is that the MAV cannot recognize obstacles where the optical flow difference between the two half planes of the image is small. To overcome this limitation, Agrawal et al. designed a steering command inversely proportional to the optical flow difference so that the UAV turns around in front of a wall-like obstacle [
7]. However, this approach could cause jitter in the case of low optical flow difference. Muratet et al. developed the algorithm to detect a frontal wall-like obstacle by using the amount of the expansion of the optical flow [
5,
13]. If the frontal obstacle is detected, then the UAV decreases its speed or makes a U-turn. Prashanth et al. developed a logic to avoid obstacles by changing the pitch angle based on the optical flow difference between top and bottom halves of the image [
14]; however, they did not carry out simulations or flight experiments.
In this paper, we propose a vision-based obstacle avoidance algorithm based on the horizontal balance strategy using the optical flow. Along with horizontal avoidance, it is designed to change the height to avoid the obstacle vertically by balancing the optical flow generated in the upper and lower half plane of the image. Besides, if a wall-like obstacle is in front of the MAV directly, the MAV turns the heading angle according to the expansion of the optical flow. Previously, the MAV was made to turn inversely proportional to the optical flow difference [
7] or take a U-turn in case of a large amount of the expansion of the optical flow [
5,
13]. Meanwhile, the proposed algorithm uses a proportional-derivative (PD) controller with the yaw rate compensator according to the amount of the expansion of the optical flow so that the MAV can avoid the frontal obstacle without the jitter or unnecessary U-turns. The proposed algorithm also includes the guidance to the goal position or waypoint if there are no obstacles around. The proposed algorithm combines above obstacle avoidance strategies and waypoint guidance with appropriate weights according to the environment condition so that the MAV avoids obstacles in 3-D environments while moving towards the goal position. The performance of the proposed algorithm was verified by the numerical simulations using the RotorS simulator running in the Robot Operating System (ROS) and the Gazebo environment and indoor flight experiments using the quadrotor MAV.
The contribution of this paper is threefold: (i) the MAV avoids the obstacle by changing the height as well as heading angle in 3-D environments; (ii) the MAV can avoid the frontal obstacle which generates a similar optical flow in left and right half planes such as a wall by using the expansion of the optical flow; and (iii) the MAV combines the different guidance strategies with adequate weights considering the environment around the MAV.
This rest of this paper is organized as follows. In
Section 2, the computation of the optical flow is presented. In
Section 3, obstacle avoidance strategies according to the position of the obstacle and the waypoint guidance strategy are proposed. The proposed obstacle avoidance algorithm was verified with numerical simulations and indoor flight experiments, which are presented in
Section 4 and
Section 5, respectively.
2. Optical Flow
The optical flow refers to the movement of each pixel expressed in the image plane when an object moving in the three-dimensional space is projected onto the two-dimensional image plane. There are various methods to estimate the optical flow such as [
15,
16,
17]. Recently, learning-based optical flow estimation methods are also proposed [
3,
18,
19]. In this work, the optical flow computation method proposed by Horn and Schunck [
16] is adopted. The concept for computing optical flows is briefly introduced in the following for the sake of the completeness of the paper and readers’ convenience.
In the Horn–Schunck method, two assumptions are used to estimate the optical flow. First, as in
Figure 1, the intensity of a particular point is constant over time.
where
I is the intensity of the pixel at the point
. By using the chain rule, Equation (
1) can be expressed as:
where
,
and
are partial derivatives of the intensity at each pixel with respect to
,
axes and time
t, respectively. By defining the optical flow vector (velocity vector of the pixels) as
, Equation (
2) is expressed in a different form:
where
,
u and
v are
and
directions of the optical flow, respectively. The cost function to minimize the change of the intensity over the time is defined by:
The second assumption is a smoothness constraint, which represents that the neighboring points on an object have a similar optical flow. Having a similar optical flow at the neighboring points implies that the magnitude of the gradient of all optical flows should be minimized. It can be expressed by:
The total cost function to be minimized is designed using Equations (
4) and (
5) by
where
is a weighting factor for the smoothness constraint. Then,
u and
v minimizing Equation (
6), which are the optical flow at each pixel, can be obtained:
From Equations (
7) and (8), an iterative solution can be obtained as:
where
and
are the optical flow of the
and
axes at the
th time frame, respectively.
3. Obstacle Avoidance Strategy
This section introduces the obstacle avoidance strategies using the optical flow estimated from a forward looking monocular camera. The horizontal balance strategy vertical balance strategy to avoid the obstacle vertically, and the frontal obstacle avoidance strategy which exploits the expansion of the optical flow are introduced. In addition to obstacle avoidance strategies, the waypoint guidance strategy is described to reach to the goal point for the MAV. Lastly, the above strategies are integrated with the weighted sum of guidance commands from different strategies according to obstacle environment conditions.
3.1. Horizontal Balance Strategy
This subsection deals with the horizontal balance strategy. We modified conventional balance strategies [
5,
20,
21] using the concept of the proportional-derivative (PD) controller. First, we show how the magnitude of the optical flow changes as the MAV approaches to an obstacle, and then the methodology of the horizontal balance strategy is introduced.
As shown in
Figure 2, suppose there is the point
P on the obstacle of interest corresponding to the point
on the image plane. The vector
is defined as the vector from the nearest point
H on the principal axis of the camera to the point
P. The vector
is the vector corresponding to
on the image plane. The MAV approaches the obstacle with the forward speed
at the point
O. Note that the focal length
f and
are given. Considering the geometrical relationship, the following relation holds:
It is worth noting that
and
x are functions of time
t and
f and
does not change as the MAV moves. Differentiating Equation (
11) with respect to time gives:
By rewriting Equation (
12), the optical flow
for a particular point of the obstacle is obtained as:
where the speed of the MAV
. In Equation (
13), the denominator is a function of time, whereas the numerator is constant with the assumption that the MAV keeps a constant speed. Note that the magnitude of the optical flow
increases as the MAV approaches the obstacle.
Let the image be equivalently split into two horizontal (left and right) and vertical (upper and lower) half planes. Considering the fact that the larger the magnitude of the optical flow is, the closer the obstacle is, the desired heading direction of the MAV can be determined by finding the half plane which has the smaller sum of optical flows. More specifically, the optical flow is calculated within the horizontal calculation window shown as the red area in
Figure 3 to ignore the unnecessary part of the environment where collision does not need to be considered. The horizontal optical flow calculation window is the center region among five evenly-divided regions of the image plane horizontally. The size and position of the horizontal optical flow calculation window were empirically determined. The heading rate command (
) is generated by the PD controller with the error (
) defined as the difference of the sum of the optical flows at left (
) and right (
) half planes, as shown in
Figure 3:
where
and
are positive gains for the horizontal balance strategy. Gain values were set to
and
in the numerical simulations presented in
Section 4, and
and
in the indoor flight experiments presented in
Section 5.
3.2. Vertical Balance Strategy
To avoid the obstacle in the three-dimensional environment, the MAV has to change the altitude as well as heading angle. In this subsection, the obstacle avoidance strategy by changing the altitude of the MAV is proposed. The optical flow for the vertical balance strategy is calculated within the vertical calculation window shown as the red area in
Figure 4 where the unnecessary part to avoid the obstacle is ignored. The vertical optical flow calculation window is obtained similarly to the horizontal calculation window by dividing the image plane vertically. The size and position of the vertical optical flow calculation window were empirically determined.
The desired climb rate command (
) can be generated by the PD controller with the error (
), which is the difference of the sum of optical flows at lower (
) and upper (
) half planes shown in
Figure 4. However, when the MAV moves with a high climb rate, the additional optical flow could be generated due to the effect of vertical movements, and, as a result, the error
could diverge unexpectedly. To avoid the unwanted effect from
, the error
for the PD controller is modified to:
where
1000 is the weighting for the magnitude of the climb rate. In Equation (
15), if
, then,
is equal to
and the larger the climb rate is, the closer the
is to zero so that the MAV does not change the altitude much. The PD controller for vertical balance strategy can then be defined as:
where
and
are positive gains of the vertical balance strategy. Gain values were set to
and
in the numerical simulations presented in
Section 4, and
and
in the indoor flight experiments presented in
Section 5.
3.3. Frontal Obstacle Avoidance Strategy
Horizontal and vertical balance obstacle avoidance strategies might not work when the obstacle is directly in front of the MAV. In this situation, the optical flows on both the half planes are similar, so the MAV would go forward without changing the heading angle and collide with the obstacle. To address this problem, the concept of expansion of the optical flow at the focus of expansion (FOE) is introduced in [
5]. When the MAV goes towards the wall-like obstacle directly, the diverging optical flow is generated, as shown in
Figure 5, where the optical flows expand from the FOE close to the origin of the image.
Using the geometry given in
Figure 2, by assuming that FOE and principal point of the image plane coincide and the optical flow expands from the FOE, the following relation can be obtained:
where time-to-contact
can be expressed by the ratio between
and
x. When
is large or
x is small, the time-to-contact becomes small. Using this relation, the time-to-contact
can be computed. We define the inverse of
as
, expansion of the optical flow (EOF). Since
has the same direction with
, the EOF can be computed in a vector form as:
Note that the high EOF implies that there is a high risk of the collision with the frontal obstacle. The magnitude of the desired heading rate to avoid the frontal obstacle is determined by the PD controller using the EOF as:
where
(
) is the difference between the sum of EOF in the left and right half planes.
is the sum of the EOF in the horizontal optical flow calculation window and
N is the number of pixels in the horizontal optical flow calculation window.
and
are positive gains of the frontal obstacle avoidance controller. Gain values were set to
and
in numerical simulations presented in
Section 4, and
and
in the indoor flight experiments presented in
Section 5. The sign of
determines the turning direction, which makes the MAV rotate to the opposite direction in which the obstacle is most likely to be close.
3.4. Waypoint Guidance
In addition to the obstacle avoidance, the MAV may need to reach the waypoint to accomplish the given mission. The heading rate and climb rate for waypoint guidance can be determined as:
where the error (
) for the heading rate controller is the angle between the line from the current position to the waypoint and the current heading angle of the MAV
:
The error for the climb rate is the difference between the height of the waypoint and the MAV:
3.5. Hybrid Obstacle Avoidance Strategy
The hybrid obstacle avoidance strategy is designed to avoid various obstacles in 3-D environment while moving towards the goal according to existence of obstacles determined by the EOF
. The obstacle environment can be classified into three cases: (i) there is no obstacle around the MAV; (ii) there are obstacles but not directly in front of the MAV; and (iii) there are obstacles directly in front of the MAV. According to the classified situation, the obstacle avoidance strategies and waypoint guidance are combined with appropriate weighting factors. The weighting factors are designed with the sigmoid function according to the sum of the EOF:
where
and
represent threshold values and
and
are positive gains.
Figure 6 shows the sigmoid weighting for determining the strategy with
,
,
, and
. Sigmoid weights largely contain three sections as the EOF changes. First, in the case that there is no obstacle around the MAV, the weighting for the balance strategy and waypoint guidance are activated and the MAV aims to the waypoint while avoiding the obstacle around the MAV. In the case that there is an obstacle around the MAV, the MAV first need to focus on avoiding the obstacle rather than moving to the waypoint. The MAV will avoid the obstacle not using waypoint guidance but just using the balance strategy. The final situation is that there is an obstacle in front of the MAV where the frontal obstacle avoidance strategy should be used. That is to say, either balance strategy or frontal obstacle avoidance strategy is always activated, and obstacle avoidance strategies are switched depending on the presence or absence of an obstacle directly in front of the MAV. Additionally, waypoint guidance is deactivated if there is a risk of collision and the MAV is required to focus on obstacle avoidance (i.e.,
). The gains for the sigmoid function were empirically determined.
The hybrid obstacle avoidance algorithm including waypoint guidance can then be designed as:
Note that, unlike desired heading rate, the desired climb rate can be designed by just adding the vertical balance strategy and waypoint guidance without sigmoid weights. The sigmoid weights should not be multiplied to the vertical balance strategy considering the fact that the sigmoid weights are to change the heading angle of the MAV if there is a wall-like obstacle in front of the MAV.
6. Conclusions and Future Work
This paper proposes the vision-based obstacle avoidance strategy using the optical flow which can be used in various 3-D textured environments. In particular, it exploits the EOF to cope with the front obstacle efficiently along with avoiding obstacles horizontally and vertically. To verify the performance of the proposed approach, numerical simulations and indoor flight experiments were carried out. The proposed obstacle avoidance strategy using optical flows requires a light computational power; hence, it could be readily applicable to miniaturized MAVs requiring the lightweight CPU such as insect-inspired flapping aerial vehicles. It is worth noting that the use of obstacle avoidance based on optical flows is limited to only relatively well-textured environments since optical flows are rarely generated on textureless objects such as white walls, wires and poles.
As the forward speed of the MAV is assumed to be kept relatively slow in our approach, the effect of pitch control on the optical flow computation was negligible. However, for high speed maneuvers, the effect of pitch control on the optical flow would be significant; this will be dealt with in the future work. Besides, although this study proposed the yaw rate effect compensator in the situation where the MAV encounters the frontal obstacle, more rigorous analysis and experiments need to be performed. For general environments, other vision-based algorithms using feature or color detection could be combined with the proposed optical flow-based approach, which remains as future work.