# Bacterial foraging-optimized PID control of a two-wheeled machine with a two-directional handling mechanism

- K. M. Goher
^{1}Email author and - S. O. Fadlallah
^{2}

**Received: **13 September 2016

**Accepted: **10 March 2017

**Published: **23 March 2017

## Abstract

This paper presents the performance of utilizing a bacterial foraging optimization algorithm on a PID control scheme for controlling a five DOF two-wheeled robotic machine with two-directional handling mechanism. The system under investigation provides solutions for industrial robotic applications that require a limited-space working environment. The system nonlinear mathematical model, derived using Lagrangian modeling approach, is simulated in MATLAB/Simulink^{®} environment. Bacterial foraging-optimized PID control with decoupled nature is designed and implemented. Various working scenarios with multiple initial conditions are used to test the robustness and the system performance. Simulation results revealed the effectiveness of the bacterial foraging-optimized PID control method in improving the system performance compared to the PID control scheme.

### Keywords

Two-wheeled machine Inverted pendulum Two-directional handling Lagrangian modeling PID BFO## Background

The interest in two-wheeled machines (TWMs) is incomparably increasing, and various linear and nonlinear methods of identification are employed for developing an accurate model of the inverted pendulum and establishing a proper control strategy for the system. Lee et al. [1] concentrated on designing a one-wheel inverted pendulum system that employs air power for balancing. The pitch angle was controlled by a DC motor, while the roll angle was regulated by air pressure sent out from ducted fans controlled by linear control methods. Chinnadurai and Ranganathan [2] focused on applying the principle of IP by proposing a two-wheel self-supporting robot controlled by an internet-on-a chip (IOC) controller. The main feature associated with this system is the capability to control the robot worldwide using the IOC, not to mention the IR, attitude, and tilt sensors installed on the robot. A novel configuration of wheeled robotic machines (WRM) which is based on the principle of two-wheeled inverted pendulum (IP) with an extended intermediate body (IB) was developed by Goher and Tokhi [3]. For providing multiple lifting levels for a carried payload, the developed machine is equipped with a linear actuator. The previously mentioned WRM was later improved by Almeshal et al. [4]. Increasing the machine’s flexibility and workspace led to a novel five DOFs two-wheeled IP with an extended rod.

### Implementation of optimization techniques on IP systems

Determining the optimal control strategy for IP systems has been and still a major concern for significant amount of studies. Diverse modeling techniques and control approaches have been applied for investigating and controlling this highly nonlinear system [5, 8]. Due to their outstanding successful applications in various areas of interest, nature-inspired and bio-inspired optimization algorithms are significantly gaining attention in nowadays research aspects. Within the past decade, there has been a tremendous amount of research studies focusing on developing optimization algorithms. Some of these algorithms include particle swarm optimization (PSO) algorithm [9], spiral dynamics algorithm (SDA) [10], genetic algorithm (GA) [11], and bacterial foraging optimization (BFO) [12].

## Bacterial foraging optimization (BFO) algorithm

BFO algorithm parameters [12]

Symbol | Description |
---|---|

| Search space dimension |

| Total number of bacteria in the population |

\(N_{\text{s}}\) | Maximum number of swim |

\(N_{\text{c}}\) | Total number of chemotaxis |

\(N_{\text{re}}\) | Maximum number of reproduction |

\(N_{\text{ed}}\) | Maximum number of elimination and dispersal events |

\(P_{\text{ed}}\) | Probability of the elimination and dispersal of bacterium |

| Step size of the bacterium tumble |

| Cost function value |

### BFO implementation

BFO has been applied in numerous research areas. Supriyono and Tokhi [13] proposed an adaptable chemotactic step size BFO in modeling a single-link flexible manipulator system. Based on an experimental single-link flexible manipulator rig, the input–output data have been collected and employed in establishing three single-input single-output models to characterize the system. As for Kalaam et al. [14], their study considered the implementation of bacterial foraging algorithm for optimizing multiple PI controllers’ design variables in a cascaded structure. Four proportional-integral (PI) controllers were employed for controlling a grid-connected photovoltaic (PV) system. Simulation results revealed that the optimized design values improved the system performance. The performance of utilizing bacterial foraging algorithm (BFO) on an intelligent fuzzy logic controller for a unicycle class of differential drive robot on an irregular rough terrain was investigated by Almeshal et al. [15]. Based on simulation results, the BFO algorithm improved the control method and a satisfactory convergence has been achieved. Nasir et al. [16] focused on improving the performance of BFO by proposing novel adaptive bacteria foraging algorithms based on index of iteration, index of chemotaxis, and fitness value to overcome the oscillations in the convergence graph caused by the constant step size and to speed up the convergence in the case of using small step size. The developed algorithms have been examined with multiple unimodal and multimodal standard benchmark functions. Considering different dimensions and fitness landscapes, simulation results revealed the outperformance of the developed algorithms based on convergence speed and fitness accuracy. On the other hand, Agouri et al. [17] proposed a control strategy for a two-wheeled robot with an extendable IB using quadratic adaptive bacterial foraging algorithm (QABFA). Nasir et al. [18] focused on improving the spiral dynamic algorithm by considering both elimination and dispersal phases of bacterial foraging algorithm. The improved SDA’s performance has been tested and implemented in fuzzy logic dynamic modeling of a twin rotor system. According to simulation results, the improved SDA converged to a far better solution compared to other implemented optimization algorithms. Considerable amount of research studies merged the concept of bacterial foraging algorithm with other algorithms and developed hybrid optimization algorithms [19, 21].

### Overview and contribution

This paper presents a bacterial foraging technique for determining the optimal parameters of a PID controller to control the stability of a five degrees-of-freedom (DOF) two-wheeled machine (TWM) developed by Goher [22].

The novel 5-DOF TWM provides payload handling in two mutually perpendicular directions while attached to the IB. Compared to existing TWRMs, this design increases both workspace and flexibility of two-wheeled machines and allows them to be employed in service and industrial robotic applications including objects assembly and material handling. Bacterial foraging algorithm’s potential, as illustrated in the literature, was a source of encouragement to examine the proposed optimization technique on the novel 5 DOF two-wheeled machine’s controller in order to improve the system’s stability performance.

### Paper organization

The rest of the paper is organized as follows: “Bacterial foraging optimization (BFO) algorithm” section presents an overview of the BFO algorithm and a rationale about the implementation on various nonlinear dynamic systems, the system description machine is presented in “TWRM system description,” and “System modeling” sections present the previously developed mathematical model using Lagrangian approach. “Control system design” section describes the control system design and the implementation of bacterial foraging optimization technique including various courses of motion and testing of the robustness of the control approach. At last, the main conclusions of the paper are presented in “Conclusions” section.

## Methods

### TWRM system description

*P*

_{1}and the mass of the linear actuators with center of gravity at point

*P*

_{2}. The coordinates of

*P*

_{1}and

*P*

_{2}will change as long as the robot maneuvers away from its initial position along the

*X*axis. The two motors attached to each wheel are in charge of providing the necessary torque, \(\tau_{\text{R}}\) and \(\tau_{\text{L}}\), for controlling the TWRM. For enabling the control strategy to maintain the two-wheeled machine’s position at the upright position continuously, the system is equipped with both accelerometer and gyroscope sensors that provide multiple state variables information at any given time. The system design provides compactness with offering proper rooms for system electronics and accessories. Other targeted features include a lightweight structure without affecting the robot stiffness and a symmetrical mass distribution for the entire robot parts and components at initial position. With respect to the

*X*and

*Z*axes, four types of translations define the system’s DOFs: the attached payload linear displacement in vertical and horizontal directions \(h_{1}\) and \(h_{2}\), respectively, and the angular displacement of the angular rotation of the right and left wheels \(\delta_{\text{R}}\) and \(\delta_{\text{L}}\), respectively. The tilt angle \(\theta\) of the intermediate body around the vertical

*Z*axis is considered as the fifth remaining DOF. Consider a picking up and placing scenario, as an application of the proposed configuration, with the vehicle’s course of motion illustrated in Fig. 2.

Subtasks against engagement of individual actuators

Subtask | Associated DOFs | Right motor \(\tau_{\text{R}}\) | Left motor \(\tau_{\text{L}}\) | Linear actuator I, \(F_{1}\) | Linear actuator II, \(F_{2}\) |
---|---|---|---|---|---|

Moving and picking | \(\delta_{\text{L}}\), \(\delta_{\text{R}} , \theta\) | ✓ | ✓ | ✕ | ✕ |

IB extension | \(\delta_{\text{L}}\), \(\delta_{\text{R}} , \theta , h_{1}\) | ✓ | ✓ | ✓ | ✕ |

Extension: end effector | \(\delta_{\text{L}}\), \(\delta_{\text{R}} , \theta , h_{2}\) | ✓ | ✓ | ✕ | ✓ |

Reverse: end effector | \(\delta_{\text{L}}\), \(\delta_{\text{R}} , \theta , h_{2}\) | ✓ | ✓ | ✕ | ✓ |

IB contraction | \(\delta_{\text{L}}\), \(\delta_{\text{R}} , \theta , h_{1}\) | ✓ | ✓ | ✓ | ✕ |

Placing the object | \(\delta_{\text{L}}\), \(\delta_{\text{R}} , \theta , h_{2}\) | ✓ | ✓ | ✕ | ✕ |

## System modeling

Among the diverse methods of deriving the equations of motion, and due to the fact that it is a powerful approach, Lagrangian modeling approach is employed to model the TWRM. Based on the system schematic diagrams illustrated earlier, the vehicle’s mathematical model is derived by relating the system’s kinematics to the torques/forces applied (details of the model derivation can be found in the work of Goher [22]). The system’s mathematical model is presented as five nonlinear-coupled differential equations as follows:

## Control system design

^{®}environment by utilizing the simulation parameters shown in Table 3. In a previous study conducted by Goher [22], it was revealed that the system response is unstable nonlinear system. Based on that, a closed-loop system is substantial for stabilizing the TWRM and improving the system’s performance. In this work, five decoupled feedback control loops have been used throughout the work. The developed control strategy, based on loops decoupling, ensures separation of the system dynamics due to the high frequency range (tilt angle) from the dynamics of low frequency range (motion of the intermediate body). The two feedback control loops occupy separate ranges of dynamics, low frequency and high frequency with tilt angle over higher frequency range and motion of intermediate body over lower frequency range, and hence, the decoupling approach is reasonable to use and apply separate control loops.

System simulation parameters

Parameter | Description | Value | Unit |
---|---|---|---|

\(m_{1}\) | Mass of the chassis | 1 | kg |

\(m_{2}\) | Mass of the linear actuators | 0.6 | kg |

\(m_{\text{w}}\) | Mass of wheel | 0.14 | kg |

\(g\) | Gravitational acceleration | 9.81 | m/s |

\(l\) | Distance of chassis’s center of mass for wheel axle | 0.14 | m |

\(R\) | Wheel radius | 0.05 | m |

\(J_{1}\) | Rotation inertia of chassis | 0.068 | kg m |

\(J_{2}\) | Rotation inertia of moving mass | 0.0093 | kg m |

\(J_{\text{w}}\) | Rotation inertia of a wheel | 0.000175 | kg m |

\(\mu_{\text{c}}\) | Coefficient of friction between chassis and wheel | 0.1 | N s/m |

\(\mu_{\text{w}}\) | Coefficient of friction between wheel and ground | 0 | N s/m |

\(\mu_{1}\) | Coefficient of friction of vertical linear actuator | 0.3 | N s/m |

\(\mu_{2}\) | Coefficient of friction of horizontal linear actuator | 0.3 | N s/m |

The friction at the mating surfaces has been simplified for the chassis–wheel, wheel–ground interaction and in the linear actuator to follow Coulomb frictional model. The values of the coefficients have been selected depending on the type of surfaces. The selected constant values are assumed to be valid under all working conditions of the vehicle and the actuators. This did not take into account variations in speed, path configuration, terrain profile, etc. The constant values have been used to validate the system model. However, modeling interactions between surfaces need to be investigated for various surfaces, various terrain profiles, and various operation conditions of the vehicle.

### BFO-optimized PID control design

In this part, bacterial foraging optimization technique is applied on the system in order to optimize the PID controller gains employed in a previous research study [22] by maintaining the system in the upright position and to counteract the disturbances occurring in different motion scenarios.

#### Optimization algorithm objective functions and constraints

*e*(

*t*) is the error signal in time domain.

## Results and Discussions

### Implementation of BFO-PID algorithm

The behavior of the robotic machine was observed for the tilt angle of the entire vehicle, angular displacements of the two wheels, and linear displacements of the linear actuators using different motion scenarios.

#### Payload free motion (*h*
_{1} = *h*
_{2} = 0)

System performance using different performance indices

Performance index | Percent overshoot | Settling time (s) | Rise time (s) | Peak time (s) |
---|---|---|---|---|

ISE | 33.8 | 0.9650 | 0.2150 | 0.3950 |

IAE | 27.9 | 0.7800 | 0.2300 | 0.4400 |

MSE | 46.6 | 1.8720 | 0.1970 | 0.3540 |

ITAE | 29.3 | 0.8080 | 0.2480 | 0.4610 |

ITSE | 34.8 | 1.0140 | 0.2230 | 0.4110 |

#### Payload vertical movement only

#### Payload horizontal movement only

#### Simultaneous vertical and horizontal motion (*h*
_{1} and *h*
_{2} ≠ 0)

#### Trajectory of a 1-m straight-line motion

#### Control system robustness

### Comparison between implementation of PID and BFO-optimized PID

Gain values for different control schemes

Loop | Output parameter | Gain parameters | PID + switching | BFO + switching | ||
---|---|---|---|---|---|---|

Lower boundary | Calculated gain | Upper boundary | ||||

Loop 1 | \(\theta\) |
| 80 | −50 | −1.733 | 50 |

| 9 | −10 | −0.0693 | 10 | ||

| 0.02 | −0.1 | 0.0835 | 0.1 | ||

Loop 2 | \(\delta_{\text{R}}\) |
| 80 | −20 | 10.255 | 20 |

| 75 | −20 | 0.016 | 20 | ||

| 0.05 | −20 | 15.05 | 20 | ||

Loop 3 | \(\delta_{\text{L}}\) |
| 80 | −20 | 10.255 | 20 |

| 75 | −20 | 0.016 | 20 | ||

| 0.05 | −20 | 15.05 | 20 | ||

Loop 4 | \(h_{1}\) |
| 8 | −20 | 10.3279 | 20 |

| 10 | −10 | 7.3378 | 10 | ||

| 0.01 | −0.1 | 0.013 | 0.1 | ||

Loop 5 | \(h_{2}\) |
| 27 | −60 | 50.1502 | 60 |

| 32 | −50 | 30.7237 | 50 | ||

| 0.05 | −0.1 | 0.027 | 0.1 |

*h*

_{1}=

*h*

_{2}= 0) scenario, as an example of how the BFO-optimized PID controller performance is better way than the PID, Table 6 illustrates a system performance comparison between the previously mentioned controllers in terms of overshoots, settling time, peak time, and rise time.

Comparison between the system’s performance using PID and BFO

Control | Percent overshoot | Settling time (s) | Peak time (s) | Rise time (s) |
---|---|---|---|---|

PID | 48.1 | 2.2870 | 0.5710 | 0.2790 |

BFO | 27.9 | 0.7800 | 0.4400 | 0.2300 |

Starting with system overshoot, the BFO-optimized PID control scheme provides better overshoot value (27.9%), which is much less than the PID-recorded overshoot value by almost 42%. Moving to settling time, it is observable that by implementing the PID control strategy the system takes around 2.3 s to settle, which is greater than the BFO-optimized PID control method’s settling time (0.78 s). Therefore, the BFO-optimized PID control strategy optimizes the settling time. As in peak and rise time values, a slight reduction has been noticed when the BFO-optimized PID control method is implemented on the TWRM model and it can be concluded that the BFO-based method produces both peak and rise time values better than the PID controller.

From the scenarios where the horizontal linear actuator activates, payload horizontal movement only case (Fig. 13) and simultaneous horizontal and vertical motion case (Fig. 14), the issue of the TWRM’s continuous movement that results from the activation of the horizontal actuator has been compensated by the implementation of bacterial foraging algorithm. For the response associated with the PID control scheme, the activation of the horizontal actuator affects the system’s stability and allows the TWRM to move 10 cm away from its original location (\(\delta_{\text{R}}\) = −0.1 m, \(\delta_{ \, }\) = −0.1 m). However, the BFO-optimized PID controller produces a satisfactory performance and robustness against the horizontal linear actuator’s movement. In general, the BFO-optimized PID control method produces much better system performance and optimized behavior than PID control scheme, where the optimum controller values are resultant from the IAE criterion.

#### Investigating control system robustness

*h*

_{2}). As a matter of fact, the bacterial foraging-optimized PID control method surpassed the PID control scheme in terms of performance, robustness, and instability minimization.

The upper and lower boundaries, shown in Table 5, are associated with the BFO-optimized control scheme with switching mechanism. Those parameters are required by the BFO algorithm in order to calculate the optimal gain values.

## Conclusions

A bacterial foraging optimization algorithm for determining the optimal parameters of PID controller employed for controlling the stability of a novel five DOF two-wheeled robotic machine has been presented in this paper. Lagrangian approach has been utilized for deriving the TWRM’s nonlinear mathematical model that has been simulated in MATLAB/Simulink^{®} environment. Furthermore, the stability of the two-wheeled machine was examined against different motion scenarios which include payload free movement, payload vertical movement only, payload horizontal movement only, simultaneous horizontal and vertical motion, and 1-m straight-line vehicle motion. In addition, the system’s stability was examined against disturbance forces to examine the controller robustness. It is clear that the bacterial foraging optimization applied in PID controller improves the system performance compared to the PID method. This was visualized by the reduction in the rise time, settling time, and percent overshoot. Further studies will consider implementing and comparing between various optimization techniques [i.e., particle swarm optimization algorithm, spiral dynamics algorithm, genetic algorithm] for optimizing the 5 DOF TWM’s PID controller gains in order to obtain the optimum control scheme that provides the best system stabilization performance.

## Declarations

### Authors’ contributions

KMG initiated the concept of two-wheeled machine with the two-directional handling mechanism. He derived the mathematical model in the linear and nonlinear forms. KMG simulated the system model and designed and implemented the control approach. SOF helped in writing the final format of the paper and analyzing and interpreting the results. Both authors read and approved the final manuscript.

### Acknowledgements

The authors of this paper would like to thank Sultan Qaboos University in Oman for hosting the initial stage of this research.

### Competing interests

The authors declare that they have no competing interests.

### Funding

This research has been funded by Sultan Qaboos University (Oman) and Lincoln University (NZ).

**Open Access**This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.

## Authors’ Affiliations

## References

- Lee J, Shin H, Lee S, Jung S. Mechatronics balancing control of a single-wheel inverted pendulum system using air blowers: evolution of mechatronics capstone design. Mechatronics. 2013;23(8):926–32.View ArticleGoogle Scholar
- Chinnadurai G, Ranganathan H. IOT controlled two wheel self supporting robot without external sensor. Middle-East J Sci Res (Sens Signal Process Secur). 2015;23:286–90.Google Scholar
- Goher KM, Tokhi O. Balance control of a TWRM with a dynamic payload. In: Proceedings of the 11th international conference on climbing and walking robots and the support technologies for mobile machines, Coimbra, Portugal; 2008.Google Scholar
- Almeshal A, Goher KM, Tokhi M. Dynamic modelling and stabilization of a new configuration of two-wheeled machines. Robot Auton Syst. 2013;61(5):443–72.View ArticleGoogle Scholar
- Chan R, Stol K, Halkyard C. Review of modelling and control of two-wheeled robots. Annu Rev Control. 2013;37(1):89–103.View ArticleGoogle Scholar
- Olivares M, Albertos P. Linear control of the flywheel inverted pendulum. ISA Trans. 2014;53(5):1396–403.View ArticleGoogle Scholar
- Sun J, Li Z. Development and Implementation of a wheeled inverted pendulum vehicle using adaptive neural control with extreme learning machines. Cogn Comput. 2015;7(6):740–52.View ArticleGoogle Scholar
- Vinodh Kumar E, Jerome J. Robust LQR controller design for stabilizing and trajectory tracking of inverted pendulum. Proc Eng. 2013;64:169–78.View ArticleGoogle Scholar
- Kennedy J, Eberhart R. Particle swarm optimization. In: Proceedings of the IEEE international conference on neural networks, vol 4, Perth, WA; 1995, p. 1942–48.Google Scholar
- Tamura K, Yasuda K. Primary study of spiral dynamics inspired optimization. IEEJ Trans Electr Electron Eng. 2011;6(S1):98–100.View ArticleGoogle Scholar
- Goldberg D. Genetic algorithms in search, optimization, and machine learning. Reading: Addison-Wesley; 1989.MATHGoogle Scholar
- Passino K. Biomimicry of bacterial foraging for distributed optimization and control. Proc IEEE Control Syst Mag 2002;22:52–67.View ArticleGoogle Scholar
- Supriyono H, Tokhi M. Parametric modelling approach using bacterial foraging algorithms for modelling of flexible manipulator systems. Eng Appl Artif Intell. 2012;25(5):898–916.View ArticleGoogle Scholar
- Kalaam R, Hasanien HM, Al-Durra A, Al-Wahedi K, Muyeen SM. Optimal design of cascaded control scheme for PV system using BFO algorithm. In: International conference on renewable energy research and applications (ICRERA), Palermo; 2015, p. 907–12.Google Scholar
- Almeshal A, Goher K M, Alenezi M, A Almazeed, J Almatawah, Moaz M. BFA optimized intelligent controller for path following unicycle robot over irregular terrains. Int J Curr Eng Technol. 2015;5(2):1199–204.Google Scholar
- Nasir A, Tokhi M, Ghani N. Novel adaptive bacterial foraging algorithms for global optimisation with application to modelling of a TRS. Expert Syst Appl. 2015;42(3):1513–30.View ArticleGoogle Scholar
- Agouri S, Tokhi M, Almeshal A, Goher KM. BFA optimisation of control parameters of a new structure two-wheeled robot on inclined surface. Paper presented at the nature-inspired mobile robotics: proceedings of the 16th international conference on climbing and walking robots and the support technologies for mobile machines, CLAWAR 2013; 2013, p. 189–96.Google Scholar
- Nasir A, Tokhi M, Omar M, Ghani N. An improved spiral dynamic algorithm and its application to fuzzy modelling of a twin rotor system. In: 2014 world symposium on computer applications & research (WSCAR); 2014, p. 1–6.Google Scholar
- Nasir A, Tokhi M, Ghani N. Novel hybrid bacterial foraging and spiral dynamics algorithms. In: 13th UK workshop on computational intelligence (UKCI), Guildford; 2013, p. 199–205.Google Scholar
- Nasir A, Tokhi M. A novel hybrid bacteria-chemotaxis spiral-dynamic algorithm with application to modelling of flexible systems. Eng Appl Artif Intell. 2014;33:31–46.View ArticleGoogle Scholar
- Almeshal A, Goher K, Nasir A, Tokhi M, Agouri S. Fuzzy logic optimized control of a novel structure two-wheeled robotic vehicle using HSDBC, SDA and BFA: a comparative study. In: 18th international conference on methods and models in automation and robotics (MMAR); 2013, p. 656–61.Google Scholar
- Goher KM. A two-wheeled machine with a handling mechanism in two-different directions. Robot Biomim. 2016;3(17):1–22. doi:https://doi.org/10.1186/s40638-016-0049-8.Google Scholar
- O’Mahony T, Downing CJ, Fatla K. Genetic algorithms for PID parameter optimisation: minimising error criteria. 2000. http://zas.ie.pwr.wroc.pl/kf_glas00.pdf. Accessed 19 Mar 2017.