This project aims to solve the inverted pendulum problem using various controllers such as PID controller and Fuzzy controller.
The inverted pendulum problem involves keeping a pendulum balanced in an inverted position. The initial state of the problem and the general state can be observed in the figures provided.
The variables of this problem include:
- Pendulum angle with respect to the vertical axis (ฮ)
- Pendulum angular velocity (โฆ)
- Cart position (cp)
- Cart velocity along the x-axis (cv)
The output of the problem is the force (F) applied to the cart in the x-axis direction.
To implement the fuzzy control system, follow these steps:
-
Fuzzification:
- Fuzzify the input variables by mapping them to fuzzy sets.
- Transform the crisp inputs (angle and angular velocity) into linguistic terms using membership functions.
-
Inference:
- Use the predefined rules written in the
fcl.simple/controller
file. - Perform appropriate inference based on the fuzzified inputs to determine the fuzzy output.
- The rules involve terms like Pv (Proportional Velocity) and Pa (Proportional Angle) to guide the inference process.
- Use the predefined rules written in the
-
Defuzzification:
- Convert the fuzzy output into a crisp value representing the absolute force.
- Calculate the absolute force value based on the provided descriptions and guidelines.
- Consider this value as the output of the
decide
function.
To run this project, ensure that Python 2.7 is installed on your system. If not, you can download Python 2.7 from the org.python website.
Follow the steps below to set up the project environment:
-
Install
virtualenv
by running the following command: -
Navigate to the project directory and create a Python 2 virtual environment using the following command:
-
Activate the virtual environment based on your operating system:
- Linux:
source venv/bin/activate
- Windows:
.\venv\Scripts\activate
- Install the required libraries by executing the following command:
To run the simulator, execute the following command: python main.py
This is the picture of the result: