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
or if cm has already been initialized:
setId(newId)[source]

set id of the Actuator

Parameters

newId (string) – the new id.

getId()[source]

get id of the Actuator

Return type

string

Returns

a std::string

getType()[source]

get the type of the Actuator (ie class name)

Return type

int

Returns

an integer

u()[source]

Get the control value

Return type

SiconosVector

Returns

current control value u

setSizeu(size)[source]

Set the control size

Parameters

size (int) – dimension of the control input u

setB(B)[source]

Set the B matrix

Parameters

B (SimpleMatrix) – the new B matrix

setg(g)[source]

Set the name of the plugin for computing g

Parameters

g (string) – the name of the plugin to compute g

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

initialize(nsds, s)[source]

initialize actuator data.

Parameters
• nsds (NonSmoothDynamicalSystem) – the NonSmoothDynamicalSystem

• s (Simulation) – the simulation

actuate()[source]

capture data when the ActuatorEvent is processed

display()[source]

display the data of the Actuator on the standard output

getInternalNSDS()[source]

get the NSDS used in the Controller, if there is one

Return type

NonSmoothDynamicalSystem

Returns

“NULL” shared_ptr if there is no internal simulation, otherwise it returns the Model hoding the simulation

class siconos.control.controller.PID(*args)[source]

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 NonSmoothDynamicalSystem

• s (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}$
setK(K)[source]

Set K

Parameters

K (SiconosVector) – SP::SiconosVector $$[K_P, K_I, K_D]$$

setRef(reference)[source]

Set the value of _ref to reference

Parameters

reference (float) – the new value

setTimeDiscretisation(td)[source]

Get the timestep from the TimeDiscretisation associated with this PID controller

Parameters

td (TimeDiscretisation) – the TimeDiscretisation for this Actuator

display()[source]

display the data of the Actuator on the standard output

class siconos.control.controller.CommonSMC(*args)[source]

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 input

• D (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 input

• D – 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

actuate()[source]

Compute the new control law at each event

initialize(nsds, s)[source]

Initialization

Parameters
• nsds (NonSmoothDynamicalSystem) – current nonsmooth dynamical system

• s (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

setAlpha(alpha)[source]

Set _alpha

Parameters

alpha (float) – the new value for _alpha

lambda_()[source]

get _lambda

Return type

SiconosVector

Returns

a pointer to _lambda

setSolver(numericsSolverId)[source]

Set the solver

Parameters

numericsSolverId (int) – the solver for the relay

setPrecision(newPrecision)[source]

Set the precision

Parameters

newPrecision (float) – a double

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

ueq()[source]

get $$u^{eq}$$

Return type

SiconosVector

Returns

a reference to _ueq

us()[source]

get $$u^{s}$$

Return type

SiconosVector

Returns

a reference to _us

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

getInternalNSDS()[source]

get the NSDS used in the SMC

Return type

NonSmoothDynamicalSystem

Returns

the NSDS used in the SMC

getInternalOSI()[source]

get the Integrator used in the SMC

Return type

OneStepIntegrator

Returns

the Integrator used in the SMC

class siconos.control.controller.LinearSMC(*args)[source]

Linear sliding mode controller

This controller implements the following sliding mode control strategy:

$\begin{split}$$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{split}$

where $$\sigma = Cx$$ is the user-defined sliding variable.

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 matrix

• D (SimpleMatrix, optional) – the D matrix in the FirstOrderLinearR

• type (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 matrix

• D (SimpleMatrix, optional) – the D matrix in the FirstOrderLinearR

• type – 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 matrix

• D – the D matrix in the FirstOrderLinearR

• type – do not set this yourself ! this is used in derived classes

actuate()[source]

Compute the new control law at each event Here we are using the following formula: $$u = u_{\mathrm{eq}} + u_s$$

setDPtr(D)[source]

Set the D matrix

Parameters

D (SimpleMatrix) – the new D matrix

class siconos.control.controller.ExplicitLinearSMC(*args)[source]

Parameters

sensor (ControlSensor) – the ControlSensor feeding the Actuator

Parameters
• sensor (ControlSensor) – the ControlSensor feeding the Actuator

• B (SimpleMatrix) – the B matrix

initialize(nsds, s)[source]

Initializer

Parameters
• nsds (NonSmoothDynamicalSystem) – current nonsmooth dynamical system

• s (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.LinearSMCOT2(sensor)[source]

Constructor

Parameters

sensor (ControlSensor) – the ControlSensor feeding the Actuator

initialize(nsds, s)[source]

initialize actuator data.

Parameters
• nsds (NonSmoothDynamicalSystem) – current nonsmooth dynamical system

• s (Simulation) – current simulation setup

actuate()[source]

Compute the new control law at each event Here we are using the following formula: TODO

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

class siconos.control.controller.LinearSMCimproved(*args)[source]

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 FirstOrderLinearR

• D (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 FirstOrderLinearR

• D – 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 instant

• CBstar (SimpleMatrix) – matrix $$CB^{*}$$

initialize(nsds, s)[source]

Initialize Controller

Parameters
• nsds (NonSmoothDynamicalSystem) – current nonsmooth dynamical system

• s (Simulation) – current simulation setup

actuate()[source]

Compute the new control law at each event Here we are using the following formula: TODO

setPerturbationPrediction(*args)[source]

Enable perturbation prediction

up()[source]

Get the control input _up, acting against matched perturbations

Return type

SiconosVector

Returns

a reference to _up

setPredictionOrder(order)[source]

Set the order of the prediction - 0 -> the predicted value is the same as the one we measured - 1 -> $$\widetilde{Cp_{k+1}} = 2Cp_k - Cp_{k-1}$$ - 2 -> $$\widetilde{Cp_{k+1}} = 3Cp_k - 3Cp_{k-1} + Cp_{k-2}$$

Parameters

order (int) – the order of the prediction

class siconos.control.controller.Twisting(*args)[source]

Modified Twisting Controller with an implicit discretization

This is the twisting controller that gives the best result

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:

setNSdata(hControl)[source]

set nonsmooth data: NormalConeNSL and AVI osnsp

Parameters

hControl (float) – sampling period

initialize(nsds, s)[source]

Initialization

Parameters
• nsds (NonSmoothDynamicalSystem) – current nonsmooth dynamical system

• s (Simulation) – current simulation setup

class siconos.control.controller.RegularTwisting(*args)[source]

Twisting Controller with a straightforward discretization

default constructor

Constructor for a nonlinear system or the ActuatorFactory

Parameters
• sensor (ControlSensor) – the ControlSensor feeding the Actuator

• hControl – sampling period

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]

Twisting Controller with an explicit discretization

default constructor

Constructor for a nonlinear system or the ActuatorFactory

Parameters

sensor (ControlSensor) – the ControlSensor feeding the Actuator

Constructor for the linear case

Parameters
• sensor (ControlSensor) – the ControlSensor feeding the Actuator

• gain (float) – control magnitude

• beta (float) – twisting parameter

actuate()[source]

Compute the new control law at each event Here we are using the following formula:

initialize(nsds, s)[source]

Initialization

Parameters
• nsds (NonSmoothDynamicalSystem) – current nonsmooth dynamical system

• s (Simulation) – current simulation setup