Module: tempMeasurement
Executive Summary
Models the addition of noise, bias, and faults to temperature measurements.
Message Connection Descriptions
The following table lists all module input and output messages. The module msg connection is set by the user from python. The msg type contains a link to the message structure definition, while the description provides information on what this message is used for.
Msg Variable Name |
Msg Type |
Description |
---|---|---|
tempInMsg |
True temperature measurement |
|
tempOutMsg |
Sensed temperature measurement with corruptions |
Detailed Module Description
This module simulates the corruption of a true thermal measurement by noise, bias, and three faults:
TEMP_FAULT_STUCK_VALUE
is faulty behavior where the measurement sticks to a specific valueTEMP_FAULT_STUCK_CURRENT
fixes the measurement to the valueTEMP_FAULT_SPIKING
is faulty behavior where the measurement spikes to a specified multiplier times the actual value, with a given probabilityTEMP_FAULT_NOMINAL
has no faulty behavior but may still have noise and bias
User Guide
Fault Parameters
This module has several parameters that are set to default values:
Parameter |
Description |
Default Value |
---|---|---|
faultState |
Sets the fault status. |
|
senBias |
Sets the bias value. |
0.0 |
senNoiseStd |
Sets the standard deviation for sensor noise. |
0.0 |
walkBounds |
Sets the random walk bounds for sensor noise. |
1E-15 |
stuckValue |
Temperature at which the reading is stuck for fault mode |
0.0 |
spikeProbability |
Probability of a spike when in fault mode |
0.1 |
spikeAmount |
Sensed temperature multiplier when spiking for fault mode |
2.0 |
Module Setup
The module is created in python using, for example:
1tempMeasurementModel = tempMeasurement.TempMeasurement()
2tempMeasurementModel.ModelTag = 'tempMeasModel'
A sample setup is done using:
1tempMeasurementModel.senBias = 1.0 # [C] bias amount
2tempMeasurementModel.senNoiseStd = 5.0 # [C] noise standard devation
3tempMeasurementModel.walkBounds = 2.0 #
4tempMeasurementModel.stuckValue = 10.0 # [C] if the sensor gets stuck, stuck at 10 degrees C
5tempMeasurementModel.spikeProbability = 0.3 # [-] 30% chance of spiking at each time step
6tempMeasurementModel.spikeAmount = 10.0 # [-] 10x the actual sensed value if the spike happens
The incomping temperature message must be connected to the module:
1tempMeasurementModel.tempInMsg.subscribeTo(sensorThermalModel.temperatureOutMsg)
The fault state is changed by the user to spiking, for example, by setting:
1tempMeasurementModel.faultState = tempMeasurement.TEMP_FAULT_SPIKING
Enums
-
class TempMeasurement : public SysModel
- #include <tempMeasurement.h>
Models a sensor to add noise, bias, and faults to temperature measurements.
Public Functions
-
TempMeasurement()
This is the constructor for the module class. It sets default variable values and initializes the various parts of the model. Don’t allow random walk by default.
-
~TempMeasurement()
-
void Reset(uint64_t CurrentSimNanos)
This method is used to reset the module and checks that required input messages are connected.
- Returns:
void
-
void UpdateState(uint64_t CurrentSimNanos)
This is the main method that gets called every time the module is updated.
- Returns:
void
Public Members
-
ReadFunctor<TemperatureMsgPayload> tempInMsg
True temperature measurement.
-
Message<TemperatureMsgPayload> tempOutMsg
Sensed temperature measurement.
-
BSKLogger bskLogger
— BSK Logging
-
TempFaultState_t faultState
[-] Fault status variable
-
double senBias = {}
[-] Sensor bias value
-
double senNoiseStd = {}
[-] Sensor noise value
-
double walkBounds
[-] Gauss Markov walk bounds
-
double stuckValue = {}
[C] Value for temp sensor to get stuck at
-
double spikeProbability
[-] Probability of spiking at each time step (between 0 and 1)
-
double spikeAmount
[-] Spike multiplier
Private Functions
-
void applySensorErrors()
This method adds noise, bias, and fault behaviors to the read-in temperature message.
- Returns:
void
Private Members
-
double trueTemperature = {}
[C] Truth value for the temperature measurement
-
double sensedTemperature = {}
[C] Temperature measurement as corrupted by noise and faults
-
double pastValue = {}
[-] Measurement from last update (used only for faults)
-
std::minstd_rand spikeProbabilityGenerator
-
GaussMarkov noiseModel
[-] Number generator for calculating probability of spike if faulty
-
TempMeasurement()