siconos.control.controller#
Module documentation
- class siconos.control.controller.nullDeleter(*args, **kwargs)[source]#
Bases:
object
- Using a shared_ptr to hold a pointer to a statically allocated
object use create<type>SPtr(<type> &x) cf http://www.boost.org/doc/
- class siconos.control.controller.Actuator(*args, **kwargs)[source]#
Bases:
object
Actuators Base Class
Abstract class, interface to user-defined actuators.
An Actuator is dedicated to act on parameters of the Model (especially z param. in DynamicalSystem) according to some specific values recorded thanks to sensors. It gives an interface for User who can implement its own Actuator. clearly define which data he needs to save.
An Actuator handles a TimeDiscretisation, which defines the set of all instants where the Actuator must operate (i.e. each times where actuate() function will be called). An Event, inserted into the EventsManager of the Simulation, is linked to this TimeDiscretisation.
Moreover, an Actuator is identified thanks to an id and a type (a number associated to the derived class type indeed).
Construction
To build an Actuator it is necessary to use the factory. Inputs are a number which identify the derived class type and a TimeDiscretisation:
Get the registry ActuatorFactory::Registry& regActuator(ActuatorFactory::Registry::get()) ; Build an Actuator of type "myType" with t as a TimeDiscretisation. regActuator.instantiate(myType, t);
The best way is to use the controlManager:
cm a ControlManager cm->addActuator(myType,t); or if cm has already been initialized: cm->addAndRecordActuator(myType,t)
- setSizeu(size)[source]#
Set the control size
- Parameters:
size (int) – dimension of the control input u
- setg(g)[source]#
Set the name of the plugin for computing g
- Parameters:
g (string) – the name of the plugin to compute g
- addSensorPtr(newSensor)[source]#
add a Sensor in the actuator.
- Parameters:
newSensor (ControlSensor) – a Sensor that will be connected to the Actuator
- setTimeDiscretisation(td)[source]#
This is derived in child classes if they need to copy the TimeDiscretisation associated with this Actuator
- Parameters:
td (
TimeDiscretisation
) – the TimeDiscretisation for this Actuator
- class siconos.control.controller.PID(*args)[source]#
Bases:
Actuator
Constructor.
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
B (
SimpleMatrix
, optional) – the B matrix
- initialize(nsds, s)[source]#
initialize actuator data.
- Parameters:
nsds (
NonSmoothDynamicalSystem
) – a NonSmoothDynamicalSystems (
Simulation
) – the simulation
- actuate()[source]#
Compute the new control law at each event Here we are using the following formula: \(u_k = u_{k-1} + c_1 e_k + c_2 e_{k-1} + c_3 e_{k-2}\) , where
\[\begin{split}c_1 &= K_P - \frac{K_D}{\Delta t} + K_I \Delta t \\ c_2 &= -1 - \frac{2K_D}{\Delta t} \\ c_3 &= \frac{K_D}{\Delta t}\end{split}\]
- setRef(reference)[source]#
Set the value of _ref to reference
- Parameters:
reference (float) – the new value
- class siconos.control.controller.CommonSMC(*args)[source]#
Bases:
Actuator
Overload 1: General constructor
- Parameters:
type (int) – the type of the SMC Actuator
sensor (ControlSensor) – the ControlSensor feeding the Actuator
Overload 2: Constructor for dynamics affine in control
- Parameters:
type (int) – the type of the SMC Actuator
sensor (ControlSensor) – the ControlSensor feeding the Actuator
B (
SimpleMatrix
) – the matrix multiplying the control inputD (
SimpleMatrix
, optional) – the saturation matrix (optional)
Overload 3: Constructor for dynamics affine in control
- Parameters:
type (int) – the type of the SMC Actuator
sensor (ControlSensor) – the ControlSensor feeding the Actuator
B (
SimpleMatrix
) – the matrix multiplying the control inputD – the saturation matrix (optional)
- computeUeq()[source]#
Compute the equivalent part of the control \(u^{eq}\). The method used here is to discretize the continuous-time formula using a theta method
- initialize(nsds, s)[source]#
Initialization
- Parameters:
nsds (
NonSmoothDynamicalSystem
) – current nonsmooth dynamical systems (
Simulation
) – current simulation setup
- setg(plugin)[source]#
Set the name of the plugin for computing g
- Parameters:
g (string) – the name of the plugin to compute g
- setCsurface(Csurface)[source]#
Set Csurface
- Parameters:
Csurface (
SimpleMatrix
) – a SP::SimpleMatrix containing the new value for _Csurface
- setSaturationMatrix(newSat)[source]#
Set _D to pointer newPtr
- Parameters:
newSat (
SimpleMatrix
) – a SP::SimpleMatrix containing the new value for _D
- setSolver(numericsSolverId)[source]#
Set the solver
- Parameters:
numericsSolverId (int) – the solver for the relay
- relay()[source]#
Get the OneStepNSProblem problem associated with the controller. This is useful to gain access to the data given to the solver in Numerics
- Return type:
LinearOSNS
- Returns:
a reference to the LinearOSNS problem
- setTheta(newTheta)[source]#
Set _theta, used in some discretization method for \(u^{eq}\)
- Parameters:
newTheta (float) – the new value for _thetaSMC
- noUeq(b)[source]#
Disable (or enable) the use of the state-continuous control \(u^{eq}\)
- Parameters:
b (boolean) – disable the use of Ueq if true
- setComputeResidus(b)[source]#
Disable (or enable) the computation of the residus on the Newton loop. This has an incidence only if the Relation is nonlinear
- Parameters:
b (boolean) – disable the computation of the residus
- setTimeDiscretisation(td)[source]#
This is derived in child classes if they need to copy the TimeDiscretisation associated with this Sensor
- Parameters:
td (
TimeDiscretisation
) – the TimeDiscretisation for this Sensor
- setDS(ds)[source]#
Set the DynamicalSystem used to compute the control law. This is useful when we have a Nonlinear problem and we need to compute the control law with an approximate model, or when the dynamics are quite different.
- Parameters:
ds (
FirstOrderNonLinearDS
) – the DynamicalSystem to be used in the Controller
- class siconos.control.controller.LinearSMC(*args)[source]#
Bases:
CommonSMC
Linear sliding mode controller
This controller implements the following sliding mode control strategy:
\[\begin{split}\begin{equation} u = u_{\mathrm{eq}} + u_s\qquad\text{where}\begin{cases} u_{\mathrm{eq}} \text{is the equivalent control input}\\u_s = -sgn(\sigma)\end{cases},\end{equation}\end{split}\]where \(\sigma = Cx\) is the user-defined sliding variable.
Overload 1: default constructor
Overload 2: Constructor for the ActuatorFactory
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
type (int, optional) – do not set this yourself ! this is used in derived classes
Overload 3: Constructor for the ActuatorFactory
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
type – do not set this yourself ! this is used in derived classes
Overload 4: Constructor with all the data
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
B (
SimpleMatrix
) – the matrixD (
SimpleMatrix
, optional) – the D matrix in the FirstOrderLinearRtype (int, optional) – do not set this yourself ! this is used in derived classes
Overload 5: Constructor with all the data
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
B (
SimpleMatrix
) – the matrixD (
SimpleMatrix
, optional) – the D matrix in the FirstOrderLinearRtype – do not set this yourself ! this is used in derived classes
Overload 6: Constructor with all the data
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
B (
SimpleMatrix
) – the matrixD – the D matrix in the FirstOrderLinearR
type – do not set this yourself ! this is used in derived classes
- class siconos.control.controller.ExplicitLinearSMC(*args)[source]#
Bases:
CommonSMC
Overload 1: Constructor
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
Overload 2: Constructor.with all data
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
B (
SimpleMatrix
) – the B matrix
- class siconos.control.controller.LinearSMCOT2(sensor)[source]#
Bases:
CommonSMC
Constructor
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
- initialize(nsds, s)[source]#
initialize actuator data.
- Parameters:
nsds (
NonSmoothDynamicalSystem
) – current nonsmooth dynamical systems (
Simulation
) – current simulation setup
- class siconos.control.controller.LinearSMCimproved(*args)[source]#
Bases:
LinearSMC
Overload 1: Constructor
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
Overload 2: Constructor with all the data
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
B (
SimpleMatrix
) – the B matrix in the FirstOrderLinearRD (
SimpleMatrix
, optional) – the D matrix in the FirstOrderLinearR
Overload 3: Constructor with all the data
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
B (
SimpleMatrix
) – the B matrix in the FirstOrderLinearRD – the D matrix in the FirstOrderLinearR
- predictionPerturbation(xTk, CBstar)[source]#
Predict the effect of the perturnation during the next timestep
- Parameters:
xTk (
SiconosVector
) – available state at the current time instantCBstar (
SimpleMatrix
) – matrix \(CB^{*}\)
- initialize(nsds, s)[source]#
Initialize Controller
- Parameters:
nsds (
NonSmoothDynamicalSystem
) – current nonsmooth dynamical systems (
Simulation
) – current simulation setup
- actuate()[source]#
Compute the new control law at each event Here we are using the following formula: TODO
- class siconos.control.controller.Twisting(*args)[source]#
Bases:
CommonSMC
Modified Twisting Controller with an implicit discretization
This is the twisting controller that gives the best result
Overload 1: default constructor
Overload 2: Constructor for the ActuatorFactory
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
Overload 3: Constructor for a nonlinear system.
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
hControl (float) – sampling period
Overload 4: Constructor for the linear case
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
gain (float) – control magnitude
beta (float) – twisting parameter
hControl (float) – sampling period
- actuate()[source]#
Compute the new control law at each event Here we are using the following formula:
- class siconos.control.controller.RegularTwisting(*args)[source]#
Bases:
Twisting
Twisting Controller with a straightforward discretization
- Overload 1:
default constructor
- Overload 2:
Constructor for a nonlinear system or the ActuatorFactory
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
hControl – sampling period
- Overload 3:
Constructor for the linear case
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
gain (float) – control magnitude
beta (float) – twisting parameter
hControl – sampling period
- class siconos.control.controller.ExplicitTwisting(*args)[source]#
Bases:
CommonSMC
Twisting Controller with an explicit discretization
- Overload 1:
default constructor
- Overload 2:
Constructor for a nonlinear system or the ActuatorFactory
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
- Overload 3:
Constructor for the linear case
- Parameters:
sensor (ControlSensor) – the ControlSensor feeding the Actuator
gain (float) – control magnitude
beta (float) – twisting parameter