A Catalog of Generic

Controller and Estimation Routines


Below you will find generic code for a variety of controller and estimation routines that were developed for the RCS Library. Note that below the pink balls represent the code integrated with the NIST-RCS Control Node, NML_MODULE, and the blue balls represent the original code. The original code is developed in a way that it can be used in applications that do not use the RCS Library.

If you want to use the code integrated with the RCS Module, you should know how to use the RCS Library. For more information on the RCS Library please consult the web site  Real-Time Control Systems (RCS) Library.

To download the RCS Library please visit the  Intelligent Systems Division's ftp site.

All the files are tarred. To untar them use "tar -xvf filename".



Use the links below to go directly to the information on the particular tool.


Runge-Kutta Differential Equation Solver

This utility can be used for simulating an n'th order system of first order differential equations with m inputs. The user specifies the system and inputs, as well as the system equations.
rk4_module.tar --- Generic 4'th order Runge-Kutta differential equation solver integrated with a generic RCS control module.
rk4_sim.tar --- Generic 4'th order Runge-Kutta differential equation solver that can be used both in RCS and non-RCS applications.
Example: Included above is an example where the motion of an automobile is simulated.


Proportional Integral Derivative (PID) Controller

PID controllers have been used very extensively and successfully in the industry for several decades. This utility provides a PID controller that uses a first difference for calculating the derivative and a 4'th order Runge-Kutta algorithm for calculating the integral of the input to the controller. The user provides the gains of the controller, and these specify the lead/lag characteristics of the controller.
pid_module.tar --- Generic PID controller integrated with a generic RCS control module.
pid_ctrl.tar --- Generic PID controller that can be used both in RCS and non-RCS applications.
Example: Included above is an example where a PID controller is used for speed regulation in an automobile.


State Feedback Controllers: Linear Quadratic Regulator (LQR)

In the systems that we can measure all the states the state feedback controller is very effective if the system under control is controllable. The LQR is a popular type of state feedback controller. The utility below can be used to implement any state feedback controller, including LQR, for an n'th order system. The user specifies the order for the system and the gains of the controller.
lqr_module.tar --- The generic state feedback, or LQR, controller integrated with a generic RCS control module.
lqr_ctrl.tar --- Generic state feedback, or LQR, controller that can be used both in RCS and non-RCS applications.
Example: Included above is an example where a state feedback controller is used for speed regulation in an automobile.


Linear State Observer for SISO Systems

In some systems we do not have direct access to the states of the system. Instead, we can only measure the output of the plant. However, if the system under control is observable, we can design an observer to estimate the plant states. This utility provides a linear state observer for single-input-single-output n-state plants. The user specifies the order for the system and the gains of the observer. This utility can be used together with the state feedback controller utility to stabilize controllable and observable plants with only output measurements. The design of the controller and the observer can be carried out separately (the separation principle).

rcs_observer.tar --- The generic linear state observer integrated with a generic RCS control module.
observer.tar --- Generic linear state observer that can be used both in RCS and non-RCS applications.
Example: Included above is an example where an observer is designed for a second order linear system that is controlled by a state feedback controller.


Recursive Least Squares (RLS) and Batch Least Squares

This utility provides a tool that implements a Recursive Least Squares (RLS) algorithm. This tool can be used for estimating the parameters of plants with unknown linearly entering parameters. The user specifies the number of parameters to be estimated, the initial guess for the parameters and the initial covarinace matrix. Moreover, you can specify forgetting factor between 0 and 1, if needed. Given the current system output and the current regression vector the tool calculates the next estimates of the parameters. The matrix utility provided below is used for internal calculations, and can be used for batch least squares (BLS) if that is needed. Of course, the RLS algorithm can be applied to a batch of data.

rls_module.tar  --- The generic RLS tool integrated with a generic RCS control module.
rls_estm.tar  --- The generic tool that implements RLS algorithm and can be used both in RCS and non-RCS applications.
Example: Included above is an example where the RLS tool is used to estimate the parameters of a linear discrete time plant with unknown parameters.


Kalman Filter

This utility provides a Kalman Filter (KF) for general multi-input-multi-output (MIMO) linear discrete time systems. The user specifies the number of the states, inputs, and outputs in the plant, as well as the system matrices and the covariances of the system and measurement noise. Moreover, the user provides the initial state of the filter and the initial state covariance matrix. Given the system inputs and outputs the tool calculates the estimated state of the system.
The matrix utility given below is used for internal calculations. In the example the function erfinv (the inverse of erf) is used.

k_fltr_module.tar  --- The generic KF tool integrated with a generic RCS control module.
k_fltr.tar  --- The generic tool that implements KF algorithm and can be used both in RCS and non-RCS applications.
Example: Included above is an example where the KF tool is used to estimate the states of a linear discrete time plant with random system and measurement noise.


Standard Fuzzy System

This utility provides a standard fuzzy system with n inputs and m outputs. The user specifies the number of the inputs and outputs. Two different types of defuzzification methods, Center-of-Gravity (COG) and Center-Average (CAV), can be chosen. The user can specify that the conjunction used in the premises of the rules be either minimum or product. Moreover, the utility can handle both triangular and Gaussian membership functions. The utility was developed in a generic way so that the user can specify and change the type, center, and spread of each individual membership function.

fuzzy_module.tar --- The generic n input m output standard fuzzy system integrated with a generic RCS control module.
fuzzy_sys.tar --- The generic n input m output standard fuzzy system that can be used both in RCS and non-RCS applications.
Example: Included above is an example where a standard fuzzy controller is used for speed regulation in an automobile.


Takagi-Sugeno Fuzzy System (Function Approximator, Static Controller, Direct and Indirect Adaptive Controller)

This utility provides a Takagi-Sugeno (TS) fuzzy system with n inputs and one outputs. Moreover, it has a build-in adaptation capability for the output parameters (i.e., TS coefficients). Therefore, it can be used as an adaptive controller in both direct and indirect schemes. The user specifies the number of the inputs to the input membership functions and the Takagi-Sugeno inputs to the outputs of the rules. The defuzzification is chosen to be a singleton defuzzification. The user can specify that the conjunction used in the premises of the rules be either minimum or product. Moreover, the utility can handle both triangular and Gaussian membership functions. The utility was developed in a generic way so that the user can specify and change the type, center, and spread of each individual input membership function.

fuzzy_ts_module.tar --- The generic n input one output Takagi-Sugeno fuzzy system integrated with a generic RCS control module.
fuzzy_ts_sys.tar --- The generic n input one output Takagi-Sugeno fuzzy system that can be used both in RCS and non-RCS applications.
Example: Included above are three exemples; one is a simple example that given inputs to the TS fuzzy system returns the output, the second example is one in which the utility is used as a (static) Takagi-Sugeno fuzzy controller for speed regulation in an automobile, and the third example is the second exemple repeated with the difference that the Takagi-Sugeno fuzzy system is used as a direct adaptive controller.


Radial Basis Function Network (Function Approximator, Static Neural Controller, Direct and Indirect Adaptive Controller)

This utility provides a radial basis function (RBF) neural network (NN) with Gaussian nodes. The network can have n inputs,  m outputs, and p neurons. Moreover, it has a build-in adaptation capability for the output parameters. Therefore, it can be used as an adaptive controller in both direct and indirect schemes. The user specifies the number of the inputs, outputs, and neurons.  The user needs to provide the centers and the spreads of the Gaussian nodes, whereas the output parameters can be specified by the user or randomly chosen from a user defined range. The matrix utility provided below is used for some of the internal calculations. Examples of how to use the RBF as a controller for steering of a cargo ship as well as how to use it as both direct and indirect adaptive controller for surge tank level regulation problem are provided.

rbf_module.tar  --- The generic RBF tool integrated with a generic RCS control module.
rbf.tar  --- The generic tool that implements RBF and can be used both in RCS and non-RCS applications.
Example: Included above are examples where the RBF tool is used as a controller for the problem of steering of a cargo ship, and as a direct and indirect  adaptive controller for regulating the liquid level of a surge tank.
 


Multilayer Perceptron Network (Function Approximator, Static Neural Controller, Direct and Indirect Adaptive Controller)

This utility provides a multilayer perceptron (MLP) neural network (NN) with n inputs,  m outputs, and p neurons. The network has build-in adaptation capability for the output parameters. Therefore, it can be used as an adaptive controller in both direct and indirect schemes. The user specifies the number of the inputs, outputs, and neurons. It is possible to specify different types of activation functions including the log-sigmoid function, hyperbolic-sigmoid function, hardlimiting function, etc. The input and output weights and biases can be specified by the user or randomly chosen from a user-defined range. The matrix utility provided below is used for internal calculations. Examples of how to use the MLP as a controller for steering of a cargo ship as well as how to use it as both direct and indirect adaptive controller for surge tank level regulation problem are provided.

mlp_module.tar  --- The generic MLP tool integrated with a generic RCS control module.
mlp.tar  --- The generic tool that implements MLP and can be used both in RCS and non-RCS applications.
Example: Included above are examples where the MLP tool is used as a controller for the problem of steering of a cargo ship, and as a direct and indirect  adaptive controller for regulating the liquid level of a surge tank.


Multilayer Perceptron Network with Levenberg-Marquardt Training Capability

This utility provides a multilayer perceptron (MLP) neural network (NN) with Levenberg-Marquardt (LM) training capability. The network can have n inputs,  m outputs, and p neurons that are specified by the user. It is possible to specify two different types of activation functions, the log-sigmoid function and hyperbolic-sigmoid function. The input and output weights and biases can be specified by the user or randomly chosen from a user-defined range. The user provides the training data set and the specified accuracy to the algorithm. The algorithm terminates when the specified accuracy is reached or the norm of the gradient is below some threshhold. The matrix utility provided below is used for internal calculations. An example for using the MLP_LM for approximating a 2-input 2-output function is provided.

mlp_lm_module.tar  --- The generic MLP_LM tool integrated with a generic RCS control module.
mlp_lm.tar  --- The generic tool that implements MLP_LM and can be used both in RCS and non-RCS applications.
Example: Included above is an example where the MLP_LM tool is used as an approximator of a 2-input 2-output nonlinear function.


Genetic Algorithm

This utility provides a genetic algorithm (GA) that is a type of a stochastic and parallel "direct search" method for optimization. It provides search by manipulating a string of numbers (a chromosome) based on the laws of evolution in biology. The chromosome is composed of traits that represent the parameters of a mathematical function, called a fitness function, that is to be maximized. The user specifies the length of the chromosome (the number of the genes), the number of the traits, and the population size. An example for finding the maximum of a simple function is provided.

ga_module.tar  --- The generic GA tool integrated with a generic RCS control module.
ga.tar  --- The generic tool that implements GA and can be used both in RCS and non-RCS applications.
Example: Included above is an example where the GA tool is used to find the maximum of simple function.


Limited Lookahead Policy (LLP) Controller

This utility provides a LLP controller that is an example of a planning system. Given a current system state and a finite number of possible controls the LLP generates all the possible future states of the system within the look ahead horizon (the number of steps to look ahead) provided by the user. The user also
provides the dimension of the state space and the control space. The possible future states are calculated using a model of the system that must be provided
by the programmer, since it is application-specific. The other information that needs to be provided by the user is the cost function which is used to pick the
"best" controller (plan). Once the possible future trajectories of the system are generated, the utility returns the first control input of the plan with the smallest cost. An example of using the controller for the load balancing problem of a six machine flexible manufacturing system (FMS) is provided.

llp_module.tar  --- The generic LLP tool integrated with a generic RCS control module.
llp.tar  --- The generic tool that implements LLP controller and can be used both in RCS and non-RCS applications.
Example: Included above is an example where the LLP controller is used in the load balancing problem of a six machine Flexible Manufacturing System (FMS).


Generic Tool for Matrix Operations

This utility provides a tool for implementing an n-by-m matrix of doubles. It contains functions for performing matrix operations such as addition, subtraction and multiplication of matrices as well as tools for taking the transpose, the trace, the (frobenious) norm of a matrix, or inverting a matrix. Its purpose is to be used in some adaptive control and estimation schemes such as least squares estimation techniques. However, it may be useful to the programmer on its own.
 
matrix.tar --- The generic tool for implementing n-by-m matrix of doubles and operations on it.


Pseudo-Random Number Generator

This utility provides a tool for generating pseudo-random doubles between 0 and 1 or used specified range or pseudo-random integers between user specified range. Uses the rand() function internally. It also has a function for returning the outcome of a random event given it's probability.
 

random.tar --- A tool for generating random numbers.


The Inverse of the Error Function "erf"

This provides a function that implements the inverse of the error function "erf." (Note that the inverse of erf is different from its complement given by "erfc.") It's implementation is based on the Matlab Toolbox.

erfinv.tar --- The inverse of the error function "erf."
 


Software Disclaimer

DISCLAIMER:  The above software was developed under a grand from Intelligent Systems Division (ISD) of National Institute of Standards and Technology (NIST) and is free of charge and is not subject to copyright. All of the code comes without any warranty. The implemented algorithms may not be coded in the most efficient way. The integration of the RCS control module and the developed control and estimation tools are to serve as an example for such an integration and may not always be suitable for every application. Therefore, the application programmer may want to modify them based on the application at hand. Recipients of this software assume all responsibility associated with its operation, modification, maintenance, and subsequent redistribution.

To report any bugs or if you have any questions, comments or suggestions related to the above code, please send e-mail to Veysel Gazi at gaziv@ee.eng.ohio-state.edu

If you have any questions, comments or suggestions related to the RCS Library, please send e-mail to Will Shackleford at shackle@nist.gov

To be automatically sent information on updates to the RCS library, please subscribe to the "nist_rcs" mailing list on http://www.onelist.com.