iDynTree::SchmittTrigger class

Schmitt Trigger class for binary state detection This device is used to obtain a binary state (ON/OFF) at some time instant depending on a value inputted to the device.

It is initialized with 4 parameters,

ParameterTypeDescription
stableOFFTimedoubleTime to elapse to switch to OFF state, once low threshold is triggered
stableONTimedoubleTime to elapse to switch to ON state, once high threshold is triggered
lowValueThresholddoubleThreshold Value to turn state OFF
highValueThresholddoubleThreshold Value to turn state ON

The device is first configured with the user-defined parameter settings, but is not activated until the first call of updateDevice method. The updateDevice method must be called at every iteration with the current time and the value to be compared, for continuously updating the binary state of the device.

For instance, if the current state is OFF and there is a call to updateDevice with current time and an input value greater than the highValueThreshold, then a timer is activated and is updated at every call to updateMethod. If there are consecutive calls to the updateMethod with input values greater than the highValueThreshold, until the timer lapses stableONTime, then the state is switched to ON, otherwise it is remains OFF.

NOTE: Time is specified relative to the process that is instantiating this device. Default state is set to ON during instantiation. This can be changed accordingly using the setInitialState method.

NOTE: There are no default parameters to the Schmitt Trigger. These parameters are set through the constructor during instantiation.

Constructors, destructors, conversion operators

SchmittTrigger(double stableOFFTime, double stableONTime, double lowValueThreshold, double highValueThreshold)
Constructor.

Public functions

void resetDevice()
Sets the schmitt trigger settings to default values.
void updateDevice(double currentTime, double rawValue)
Update the device state with the latest time and input measurement.

State

bool m_currentState
double m_previousTime
double m_timer

Device Parameters

double m_stableOFFTime
double m_stableONTime
double m_highValueThreshold
double m_lowValueThreshold

Input

double m_rawValue
int m_verbose

Setters

void configure(double stableOFFTime, double stableONTime, double lowValueThreshold, double highValueThreshold)
Configures the Schmitt Trigger parameters (can be called after instantiation, to change the parameters)
void setStableOFFTime(double stableOFFTime)
set required time to elapse to switch to OFF state
void setStableONTime(double stableONTime)
set required time to elapse to switch to ON state
void setLowValueThreshold(double lowValueThreshold)
set low threshold value to trigger OFF state detection
void setHighValueThreshold(double highValueThreshold)
set high threshold value to trigger ON state detection
void setInitialState(bool state)
set initial state

Getters

auto getState() -> bool
get current state
auto getElapsedTime() -> double
get time elapsed since the first update of the device

Verbose

void setVerbose()
void unsetVerbose()

Function documentation

iDynTree::SchmittTrigger::SchmittTrigger(double stableOFFTime, double stableONTime, double lowValueThreshold, double highValueThreshold)

Constructor.

Parameters
stableOFFTime time to elapse to switch to OFF state
stableONTime time to elapse to switch to ON state
lowValueThreshold threshold value to turn state OFF
highValueThreshold threshold value to turn state ON

void iDynTree::SchmittTrigger::updateDevice(double currentTime, double rawValue)

Update the device state with the latest time and input measurement.

Parameters
currentTime current time
rawValue input measurement

void iDynTree::SchmittTrigger::configure(double stableOFFTime, double stableONTime, double lowValueThreshold, double highValueThreshold)

Configures the Schmitt Trigger parameters (can be called after instantiation, to change the parameters)

Parameters
stableOFFTime time to elapse to switch to OFF state
stableONTime time to elapse to switch to ON state
lowValueThreshold threshold value to turn state OFF
highValueThreshold threshold value to turn state ON

void iDynTree::SchmittTrigger::setStableOFFTime(double stableOFFTime)

set required time to elapse to switch to OFF state

Parameters
stableOFFTime

void iDynTree::SchmittTrigger::setStableONTime(double stableONTime)

set required time to elapse to switch to ON state

Parameters
stableONTime

void iDynTree::SchmittTrigger::setLowValueThreshold(double lowValueThreshold)

set low threshold value to trigger OFF state detection

Parameters
lowValueThreshold

void iDynTree::SchmittTrigger::setHighValueThreshold(double highValueThreshold)

set high threshold value to trigger ON state detection

Parameters
highValueThreshold

void iDynTree::SchmittTrigger::setInitialState(bool state)

set initial state

Parameters
state binary state true/false

bool iDynTree::SchmittTrigger::getState()

get current state

Returns binary state true/false

double iDynTree::SchmittTrigger::getElapsedTime()

get time elapsed since the first update of the device

Returns time