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.
Returns a new Measurement instance containing only the samples in the range [start, end). Both timestamps and data are sliced accordingly.
Parameters:
startStarting sample index (inclusive).endEnding sample index (exclusive).
Returns:
New Measurement instance with sliced data and timestamps.
Exception:
std::out_of_rangeIf indices are invalid or inconsistent.
function data [½]¶
Return the measurement data array.
Returns:
Reference to the data array (channels in rows, samples in columns).
function data [2/2]¶
function num_channels¶
The number of independent channels or axes of measurement.
function num_measurements¶
The number of measurement samples.
function operator[]¶
Return an indexed element of the current instance.
Parameters:
indexIndex of the element to return.
Returns:
New instance containing only the indexed element.
function sample_rate¶
Return the measurement sample rate in Hz.
Returns:
The sample rate as a double.
function time [½]¶
Return the measurement timestamps.
Returns:
Reference to the timestamps array.
function time [2/2]¶
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:
measurementsList 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:
dataArray of measurements, with channels in rows and samples in columns.sample_rateMeasurement 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:
dataArray of measurements (channels in rows, samples in columns).timeArray of unique, strictly increasing times for each sample.sample_rateOptional 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