File control/src/Sensor/Sensor.hpp

Go to the source code of this file

General interface to define a sensor.

class Sensor
#include <Sensor.hpp>

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).

Subclassed by ControlSensor

Public Functions

Sensor(unsigned int type, SP::DynamicalSystem ds)

Constructor with a TimeDiscretisation.

  • type: the type of the Sensor, which corresponds to the class type.

  • ds: the SP::DynamicalSystem we observe.

virtual ~Sensor()


virtual void capture() = 0

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

void display() const

display the data of the Sensor on the standard output

SP::DynamicalSystem getDS() const

get the DynamicalSystem linked to this Sensor



const std::string getId() const

get id of the Sensor


a std::string

int getType() const

get the type of the Sensor


an int

virtual void initialize(const NonSmoothDynamicalSystem &nsds)

get all the data saved for this sensor


a DataSet initialize sensor data.

  • nsds: the Model

void setId(const std::string &newId)

set id of the Sensor


virtual void setTimeDiscretisation(const TimeDiscretisation &td)

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

  • td: the TimeDiscretisation for this Sensor

Protected Functions


default constructor

Sensor(const Sensor&)

copy constructor Private => no copy nor pass-by value allowed.


serialization hooks

Protected Attributes

SP::DynamicalSystem _DS

pointer to the DynamicalSystem we are measuring

SP::SiconosVector _DSx

pointer to the state of the DynamicalSystem

std::string _id

id of the Sensor

unsigned int _type

type of the Sensor