File control/src/utils/ControlManager.hpp

Go to the source code of this file

Tools to provide control in a Simulation: Sensors, Observer and Actuators.

Typedefs

typedef std::set<SP::Actuator> Actuators

A set of Actuators.

typedef Actuators::iterator ActuatorsIterator

An iterator through a set of Actuators.

typedef std::set<SP::Observer> Observers

A set of Observers.

typedef Observers::iterator ObserversIterator

An iterator through a set of Observers.

typedef std::set<SP::Sensor> Sensors

A set of Sensors.

typedef Sensors::iterator SensorsIterator

An iterator through a set of Sensors.

class ControlManager
#include <ControlManager.hpp>

ControlManager Class: tools to provide control in a Simulation (Sensors, Actuators, Observers)

This class is used to handle all the sensors and actuators declared by the user and to schedule them into the simulation.

A ControlManager has:

  • a list of Sensor
  • a list of Actuator
  • a link to an existing Simulation

The usual way to define control over a system is as follows:

  • declare a ControlManager and associate it with a Simulation
  • add some sensors and actuators into the ControlManager
  • initialize the ControlManager (which will result in the recording of all actuators and sensors into the list of events processed during the simulation)
  • optionally add some new sensor/actuator at any time but with a specific function: addAndRecord(…). A call to this function results in the creation of a Sensor/Actuator and in the insertion of the corresponding event into the simulation eventsManager.

Public Functions

ControlManager(SP::Simulation sim)

Constructor with a Simulation, to which control will be applied.

Parameters
  • sim: the Simulation

virtual ~ControlManager()

destructor

SP::Actuator addActuator(int name, SP::TimeDiscretisation td, SP::ControlSensor sensor)

To build and add a new Actuator in the Manager.

Return
the added Actuator
Parameters

void addActuatorPtr(SP::Actuator act, SP::TimeDiscretisation td)

Add an existing Actuator to the manager.

Parameters
  • act: a SP::Actuator to the Actuator we want to add
  • td: the TimeDiscretisation used for the associated Event

SP::Actuator addAndRecordActuator(int name, SP::TimeDiscretisation t, SP::ControlSensor sensor, const NonSmoothDynamicalSystem &nsds)

To build, add, initialize a new Actuator in the manager and record it in the simulation This function is only useful to add a new Actuator after the initialization of the manager else call addActuator()

Return
a SP::Actuator to the added Actuator
Parameters

void addAndRecordActuatorPtr(SP::Actuator act, SP::TimeDiscretisation td, const NonSmoothDynamicalSystem &nsds)

To add, initialize an existing Actuator in the manager and record it in the simulation This function is only useful to add a new Actuator after the initialization of the manager otherwise call addActuator()

Parameters
  • act: a SP::Actuator to the Actuator we want to add
  • td: the TimeDiscretisation used for the associated Event
  • nsds: current nonsmooth dynamical system

SP::Observer addAndRecordObserver(int name, SP::TimeDiscretisation td, SP::ControlSensor sensor, const SiconosVector &xHat0, const NonSmoothDynamicalSystem &nsds)

To build, add, initialize a new Observer in the manager and record it in the simulation This function is only useful to add a new Observer after the initialization of the manager else call addObserver()

Return
the added Observer
Parameters
  • name: the type of the Observer
  • td: the SP::TimeDiscretisation of the Observer
  • sensor: the ControlSensor feeding the Observer
  • xHat0: the initial guess for the state
  • nsds: current nonsmooth dynamical system

void addAndRecordObserverPtr(SP::Observer obs, SP::TimeDiscretisation td, const NonSmoothDynamicalSystem &nsds)

To add, initialize an existing Observer in the manager and record it in the simulation This function is only useful to add a new Observer after the initialization of the manager otherwise call addObserver()

Parameters
  • obs: a SP::Observer to the Observer we want to add
  • td: the TimeDiscretisation used for the associated Event
  • nsds: current nonsmooth dynamical system

SP::Sensor addAndRecordSensor(int name, SP::TimeDiscretisation td, SP::DynamicalSystem ds, const NonSmoothDynamicalSystem &nsds)

To build, add, initialize a new Sensor in the Manager and record it in the simulation This function is only useful to add a new Sensor after the initialization of the manager else call addSensor()

Return
a SP::Sensor to the added Sensor
Parameters
  • name: the type (int) of the Sensor
  • td: the SP::TimeDiscretisation of the Sensor
  • ds: the DynamicalSystem used in the Sensor
  • nsds: the NonSmoothDynamicalSystem

void addAndRecordSensorPtr(SP::Sensor s, SP::TimeDiscretisation td, const NonSmoothDynamicalSystem &nsds)

To add, initialize an existing Sensor in the manager and record it in the simulation This function is only useful to add a new Sensor after the initialization of the manager else call addSensor()

Parameters
  • s: a SP::Sensor to the Sensor we want to add
  • td: the TimeDiscretisation used for the associated Event
  • nsds: current nonsmooth dynamical system

SP::Observer addObserver(int name, SP::TimeDiscretisation td, SP::ControlSensor sensor, const SiconosVector &xHat0)

To build and add a new Observer in the Manager.

Return
a SP::ACtuator to the added Observer
Parameters

void addObserverPtr(SP::Observer obs, SP::TimeDiscretisation td)

Add an existing Observer to the manager.

Parameters
  • obs: a SP::Observer to the Observer we want to add
  • td: the TimeDiscretisation used for the associated Event

SP::Sensor addSensor(int name, SP::TimeDiscretisation td, SP::DynamicalSystem ds)

To build and add a new Sensor in the Manager.

Return
a SP::Sensor to the added Sensor
Parameters
  • name: the type of the Sensor
  • td: the SP::TimeDiscretisation of the Sensor
  • ds: the DynamicalSystem used in the Sensor

void addSensorPtr(SP::Sensor s, SP::TimeDiscretisation td)

Add an existing Sensor to the Manager.

Parameters
  • s: a SP::Sensor to the Sensor we want to add
  • td: the TimeDiscretisation used for the associated Event

void display() const

display the data of the ControlManager on the standard output

const Actuators getActuators() const

get the list of Actuators associated to this manager.

Return
a Actuators object.

const Observers getObservers() const

get the list of Observers associated to this manager.

Return
a Observers object.

const Sensors getSensors() const

get the list of Sensors associated to this manager.

Return
a Sensors object.

void initialize(const NonSmoothDynamicalSystem &nsds)

initialize all Sensors, Observers and Actuators.

Parameters
  • nsds: current nonsmooth dynamical system

SP::Simulation simulation() const

get the Simulation linked to this ControlManager

Return
a SP::Simulation

Protected Functions

ControlManager()

default constructor

void linkActuatorSimulation(SP::Actuator act, SP::TimeDiscretisation td)

Create associated Event and give the opportunity to get the TimeDiscretisation.

Parameters
  • act: a Sensor
  • td: a TimeDiscretisation asociated with this Sensor

void linkObserverSimulation(SP::Observer obs, SP::TimeDiscretisation td)

Create associated Event and give the opportunity to get the TimeDiscretisation.

Parameters
  • obs: a Sensor
  • td: a TimeDiscretisation asociated with this Sensor

void linkSensorSimulation(SP::Sensor s, SP::TimeDiscretisation td)

Create associated Event and give the opportunity to get the TimeDiscretisation.

Parameters
  • s: a Sensor
  • td: a TimeDiscretisation asociated with this Sensor

Protected Attributes

Actuators _allActuators

A list of Actuators.

Observers _allObservers

A list of Observers.

Sensors _allSensors

A list of Sensors.

SP::Simulation _sim

The simulation linked to this ControlManager.

Private Functions

ACCEPT_SERIALIZATION(ControlManager)

serialization hooks