# 24 March Update IgnacioMejiaRodriguez - GaloisInc/HighAssuranceControllerOfSelfBalancingRobotCapstone GitHub Wiki

### Status Update

- Note1: My specific task in this project is the controller design/implementation.
- Note2: These are only the tasks completed by Ignacio Mejia-Rodriguez

### Controller Selection

- A great deal of effort went into selecting a controller that is robust, reliable, and easily implementable given our hardware. Many advanced control methods that require online optimization require fast hardware. The worry that the controller that we are using has the capability of implementing one of these controllers led us to select fuzzy logic control (FLC). Some Advantages of FLC are as follows:
- Model Free implementation.
- Robustness.
- Ease of implementation (MATLAB toolbox accessible)
- No online optimization methods needed.

### MATLAB Fuzzy inference system (FIS) for the balance controller.

- The robot has 2 controllers (A tilt controller & a yaw controller). The fundamental one is evidently the balance controller. The balance controller was inspired by the work in the article "IMPLEMENTATION OF MAMDAMI FUZZY CONTROL ON A MULTI-DOF TWO-WHEEL INVERTED PENDULUM ROBOT," by Yubai Liu and Xueshan Gao. In this article a fuzzy Proportional-plus-Derivative (PD) controller is developed. After slight adjustments to the membership functions and PD gains I developed a fuzzy balance controller with a relatively good response. The response is shown below:

The response has no overshoot and a good steady state response. The code to generate the fuzzy inference system has been uploaded to the repository for analysis. It should be noted that there were quite a few issues in the creation of this controller. They are as follows:

- MATLAB has an error that commonly occurs when using the Fuzzy Logic Controller in a feedback loop. The details of this issue are discussed in the following link:

The solution to this problem is to add a unit delay in the feedback loop.

- The degree of membership for the proportional and derivative inputs would go to zero at the maximum error signal. This can best be explained with the following image:

When the input was less than -0.8 or more than 0.8, the degree of membership would crash to zero instead of remaining constant at one. To solve this I added a saturation block in Simulink which keeps the inputs within their respective boundaries and prevents the degree of membership from crashing to zero.

- The fuzzy rules provided in "IMPLEMENTATION OF MAMDAMI FUZZY CONTROL ON A MULTI-DOF TWO-WHEEL INVERTED PENDULUM ROBOT," by Yubai Liu and Xueshan Gao had a different reference direction for "positive torque." This resulted in the system only being stable with negative controller gains. To solve this I changed the consequent of each rule. For example: The rule "If e is NB and derivative of e is NB then u is PB" would change to "If e is NB and derivative of e is NB then u is NB."

### Next Steps:

- Develop a fuzzy yaw controller.
- Check the feasibility regarding the motors and plan on implementation.
- Study the Simulink -> Lustre -> Rust code generation process for implementation. The following link provided by Artem looks promising: http://www-verimag.imag.fr/ss2lus.html