Skip to content

Class inertialsim::sensors::Measurement

ClassList > inertialsim > sensors > Measurement

Sensor measurement data.More...

  • #include <measurement.h>

Public Functions

Type Name
Measurement Slice (int start, int end) const
Return a slice of the measurement samples.
const Array & data () const
Return the measurement data array.
Array & data ()
int num_channels () const
The number of independent channels or axes of measurement.
int num_measurements () const
The number of measurement samples.
Measurement operator[] (int index) const
Return an indexed element of the current instance.
double sample_rate () const
Return the measurement sample rate in Hz.
const Timestamps & time () const
Return the measurement timestamps.
Timestamps & time ()

Public Static Functions

Type Name
Measurement FromMeasurements (const std::vector< Measurement > & measurements)
Construct a Measurement from a collection of Measurements.
Measurement FromSampledData (const Array & data, double sample_rate)
Construct a Measurement from uniformly sampled data.
Measurement FromTimestampedData (const Array & data, const Timestamps & time, std::optional< double > sample_rate=std::nullopt)
Construct a Measurement from timestamped data.

Detailed Description

Time-sampled sensor measurement data. Measurement data can be timestamped with a time of validity for each measurement datum or can be uniformly sampled at a fixed rate. Measurements can consist of any number of channels (e.g., 3-axis sensors have 3 channels).

Use the static From* methods to construct an instance.

** **

Data is organized with samples in rows and channels in columns: * Shape (N,): Single channel, N samples * Shape (1, N): Single channel, N samples (equivalent to above) * Shape (M, N): M channels, N samples

Example: A 3-axis gyroscope sampled at 100 Hz for 1 second will have shape (3, 100) where the 3 rows represent the x, y, z angular rates.

** **

For timestamped data, sample rate consistency is important for many algorithms. The class validates that timestamps are consistent with the expected sample rate.

Public Functions Documentation

function Slice

Return a slice of the measurement samples.

Measurement inertialsim::sensors::Measurement::Slice (
    int start,
    int end
) const

Returns a new Measurement instance containing only the samples in the range [start, end). Both timestamps and data are sliced accordingly.

Parameters:

  • start Starting sample index (inclusive).
  • end Ending sample index (exclusive).

Returns:

New Measurement instance with sliced data and timestamps.

Exception:

  • std::out_of_range If indices are invalid or inconsistent.

function data [½]

Return the measurement data array.

inline const Array & inertialsim::sensors::Measurement::data () const

Returns:

Reference to the data array (channels in rows, samples in columns).


function data [2/2]

inline Array & inertialsim::sensors::Measurement::data () 

function num_channels

The number of independent channels or axes of measurement.

inline int inertialsim::sensors::Measurement::num_channels () const


function num_measurements

The number of measurement samples.

inline int inertialsim::sensors::Measurement::num_measurements () const


function operator[]

Return an indexed element of the current instance.

Measurement inertialsim::sensors::Measurement::operator[] (
    int index
) const

Parameters:

  • index Index of the element to return.

Returns:

New instance containing only the indexed element.


function sample_rate

Return the measurement sample rate in Hz.

inline double inertialsim::sensors::Measurement::sample_rate () const

Returns:

The sample rate as a double.


function time [½]

Return the measurement timestamps.

inline const Timestamps & inertialsim::sensors::Measurement::time () const

Returns:

Reference to the timestamps array.


function time [2/2]

inline Timestamps & inertialsim::sensors::Measurement::time () 

Public Static Functions Documentation

function FromMeasurements

Construct a Measurement from a collection of Measurements.

static Measurement inertialsim::sensors::Measurement::FromMeasurements (
    const std::vector< Measurement > & measurements
) 

Merges a list of Measurement instances into a single instance. Inputs must have a consistent number of channels.

Parameters:

  • measurements List of Measurement instances to concatenate.

Returns:

A single merged Measurement instance.


function FromSampledData

Construct a Measurement from uniformly sampled data.

static Measurement inertialsim::sensors::Measurement::FromSampledData (
    const Array & data,
    double sample_rate
) 

A time span is constructed internally using the sample_rate input.

Parameters:

  • data Array of measurements, with channels in rows and samples in columns.
  • sample_rate Measurement sample rate (Hz).

Returns:

A Measurement instance.


function FromTimestampedData

Construct a Measurement from timestamped data.

static Measurement inertialsim::sensors::Measurement::FromTimestampedData (
    const Array & data,
    const Timestamps & time,
    std::optional< double > sample_rate=std::nullopt
) 

Constructs measurement data with explicit timestamps for each sample. Input shape is flexible: * (N,), (1, N): Single channel data * (M, N): Multi-channel data

If sample_rate is provided, the time input is checked for consistency. If sample_rate is null, the median sample rate from the time input is calculated and used. If only one data point is input, sample_rate must be supplied.

Parameters:

  • data Array of measurements (channels in rows, samples in columns).
  • time Array of unique, strictly increasing times for each sample.
  • sample_rate Optional expected sample rate (Hz). If provided, used for validation. If not provided, median is calculated.

Returns:

A Measurement instance.



The documentation for this class was generated from the following file cpp/include/inertialsim/sensors/measurement.h