siconos.control.sensor.Sensor (Python class)

class siconos.control.sensor.Sensor(*args, **kwargs)[source]

Bases: object

A map that links a std::string to a pointer to SiconosVector.

An iterator through a map that links a std::string to a pointer to SiconosVector. A const iterator through a map that links a std::string to a pointer to SiconosVector. The object used to store data in the Sensor. To each Event corresponds a Data Sensor Base Class

Abstract class, interface to user-defined sensors.

A Sensor is dedicated to data capture. It gives an interface for User who can implement its own Sensor to clearly define which data he needs to save.

A Sensor handles a TimeDiscretisation, which defines the set of all instants where the sensor must operate

(i.e. each times where capture() function will be called). An Event, inserted

into the EventsManager of the Simulation, is linked to this TimeDiscretisation.

Moreover, a Sensor is identified thanks to an id and a type (a number associated to the derived class type indeed). Construction To build a Sensor it is necessary to use the factory. Inputs are a number which identify the derived class type and a TimeDiscretisation:

The best way is to use the controlManager:

The data are saved in a DataSet object named data, a map which associate to each Event another map. This second map links a std::string, used to identify the data, and a SiconosVector. As an example consider the case where you need to save the state vector x of a DynamicalSystem, then you can define a Data object, with “myDS_X” as an id and yourDS->x() as the SiconosVector. For myEvent being an Event where you need to save data, you get: (data[myEvent])[“myDS_X”] = model->nonSmoothDynamicalSystem()->dynamicalSystem()->x()

See users’ manual for details on how to define its own Sensor.

Generated class (swig), based on C++ header Program listing for file control/src/Sensor/Sensor.hpp.


Sensor(int type, DynamicalSystem ds)

Constructor with a TimeDiscretisation.

  • type – the type of the Sensor, which corresponds to the class type.
  • ds – the SP::DynamicalSystem we observe.
capture() → void[source]

capture()=0 -> None

capture data when the SensorEvent is processed => set data[SensorEvent]=…

display() → None[source]

display the data of the Sensor on the standard output

getDS() → DynamicalSystem[source]

get the DynamicalSystem linked to this Sensor

getId() → str[source]

get id of the Sensor

Returns:a std::string
getType() → int[source]

get the type of the Sensor

Returns:an int
initialize(NonSmoothDynamicalSystem nsds) → None[source]

get all the data saved for this sensor

Returns:a DataSet initialize sensor data.
Parameters:nsds – the Model
setId(str newId) → None[source]

set id of the Sensor

Parameters:newId – the id of the Sensor
setTimeDiscretisation(TimeDiscretisation td) → None[source]

This is derived in child classes if they need to copy the TimeDiscretisation associated with this Sensor.

Parameters:td – the TimeDiscretisation for this Sensor