Course Simulation Project -- Inverted Pendulum with Fuzzy Controller
In this project, a inverted pendulum system controled by a simple fuzzy controller is simulated in the Matlab environment. The main refereence is the book "Fuzzy Control" [1]. The main purpose is to evaluate effects of different parameters. There are three types of files: supported functions, simulation functions and simulation results.
Supported Functions
- Model of the inverted pendulum system
InvertedPendulum.m
: Calculate the current enviroment values based on values of previous time step; - Fourth order Runge Kutta method
ODE_RK.m
: Solve the ODE by using the fourth order Runge Kutta method. It is used in theInvertedPendulum.m
; - Fuzzy Controller
FuzzyController.m
: Based on the user's settings and measured values to calculate the force which will transferred to the inverted pendulum system. It is only contains two inputs and one outputs. One input is the angle error. Another input is the angle speed error. The output is the force. ConvertEps2Pdf.sh
: Convert simulation results from eps figures to pdf figures. Only for Mac OS System. How to use it: In terminal, runchmod +x ./ConvertEps2Pdf.sh;./ConvertEps2Pdf.sh
Simulation Functions
test_membershipfunction.m
: Plot the membership functions based on the user's settings. Example results aree_membershipfunction.pdf
,de_membershipfunction.pdf
andF_membershipfunction.pdf
inTest_Results
floder.;test_InvertedPendulum_without_controller.m
: Test the model of the inverted pendulum. No control is performed. Example results arewithout_control_1.pdf
andwithout_control_2.pdf
inTest_Results
floder.;test_InvertedPendulum_with_fuzzy_controller.m
: Simulate the fuzzy control process of the inverted pendulum. Example results areforce_**.pdf
andangleandposition_**.pdf
inTest_Results
floder.Diff_Parameters_Diff_Results_triangle_min.m
: This file is to show the simulation results for effects of different parameters. Simulation results are in theSimulation_Results_triangle_min
floder (Membership functions are triangular. And use minimum to represent the premise and implication and COG classification)Diff_Parameters_Diff_Results_Gaussian_product.m
: This file is to show the simulation results for effects of different parameters. Simulation results are in theSimulation_Results_Gaussian_product
floder (Membership functions are Gaussian. And use product to represent the premise and implication and COG classification)Diff_Parameters_Diff_Results_49rules.m
: For the previous simulations, only 25 rules are used. This simulation is to show the effect of rule base. The number of rules is increased to 49.
Simulation Results
- There are some example results for testing simulation functions in the folder
Test_Results
. These example all follows the section "2.4 Simple Desgin Example: The Inverted Pendulum" of [1]. - Simulation results of
Diff_Parameters_Diff_Results_triangle_min.m
are all in the folderSimulation_Results_triangle_min
. These simulations also follows the section "2.4 Simple Desgin Example: The Inverted Pendulum" of [1]. - Simulation results of
Diff_Parameters_Diff_Results_Gaussian_product.m
are all in the folderSimulation_Results_Gaussian_product
. These simulations are for "2.10 Design Problem 2.1" of [1]. - Simulation results of
Diff_Parameters_Diff_Results_49rules.m
are all in the folderSimulation_Results_49rules
. These simulations are for "2.10 Design Problem 2.1" of [1].
Just for Fun
GUI_InvertedPendulumSimulation.m
is only for fun. ( ̄┰ ̄)
Reference
[1] K. M. Passion and S. Yurkovich, Fuzzy Cntrol. Menlo Park, CA: Addison-Wesley, 1998.