Abstract base class for sensors.
More...
#include <BaseSensor.hpp>
|
| | BaseSensor (com::ComInterface *interface, com::ComEndpoint target, unsigned int idx, bool enable) |
| | Construct a base sensor and register it with the communication interface.
|
|
virtual | ~BaseSensor () |
| | Destructor.
|
| unsigned int | getIdx () const |
| | Get the index of this sensor instance.
|
| bool | getEnable () const |
| | Query if the sensor is currently enabled.
|
| void | setEnable (bool enable) |
| | Enable or disable the sensor.
|
| void | setPose (math::Vector3 translation, math::Vector3 rotation) |
| | Set the pose of the sensor in the common coordinate frame.
|
| void | resetSensorState () |
| | Reset error state and internal flags to nominal values.
|
|
void | clearDataFlag () |
| | Clear state for the next measurement cycle. Calls the sensor-specific hook onClearDataFlag().
|
| std::future< bool > | beginMeasurementWait () |
| | Start a measurement-wait cycle and return a future that will be set when the measurement is ready.
|
| std::future< bool > | beginDataAvailableWait () |
| | Start a data-available-wait cycle and return a future that will be set when new data is available.
|
|
|
unsigned int | _idx |
| | Index of this sensor instance within its group.
|
|
DeviceState | _error |
| | Current health state of the sensor.
|
|
com::ComInterface * | _interface |
| | Communication interface used to talk to the sensor.
|
|
math::Vector3 | _translation |
| | Translation of the sensor origin in the common coordinate frame.
|
|
math::Vector3 | _rotation |
| | Rotation of the sensor expressed as Euler angles in degrees.
|
|
math::Matrix3 | _rot_m |
| | Rotation matrix derived from the Euler angles.
|
|
bool | _enable_flag |
| | Flag indicating whether the sensor is enabled.
|
| std::mutex | _state_mutex |
|
std::optional< std::promise< bool > > | _measurement_promise |
| | Promise for the current measurement-wait cycle; set by callback, consumed by wait + get().
|
|
std::optional< std::promise< bool > > | _data_available_promise |
| | Promise for the current data-available-wait cycle; set by callback when "data available" is received.
|
| std::mutex | _promise_mutex |
|
subscription::Subscription | _com_subscription |
| | RAII subscription to the communication interface.
|
Abstract base class for sensors.
Provides state tracking, pose handling and notification hooks for derived sensors.
◆ BaseSensor()
| eduart::device::BaseSensor::BaseSensor |
( |
com::ComInterface * | interface, |
|
|
com::ComEndpoint | target, |
|
|
unsigned int | idx, |
|
|
bool | enable ) |
Construct a base sensor and register it with the communication interface.
- Parameters
-
| [in] | interface | Communication interface used to exchange messages with the sensor. |
| [in] | target | Endpoint on the interface this sensor listens to. |
| [in] | idx | Index of the sensor instance. |
| [in] | enable | Initial enabled state of the sensor. |
◆ beginDataAvailableWait()
| std::future< bool > eduart::device::BaseSensor::beginDataAvailableWait |
( |
| ) |
|
Start a data-available-wait cycle and return a future that will be set when new data is available.
- Returns
- Future that will hold true when new data has been signalled as available.
◆ beginMeasurementWait()
| std::future< bool > eduart::device::BaseSensor::beginMeasurementWait |
( |
| ) |
|
Start a measurement-wait cycle and return a future that will be set when the measurement is ready.
- Returns
- Future that will hold true when the measurement has been fetched successfully.
◆ comCallback()
| virtual void eduart::device::BaseSensor::comCallback |
( |
const com::ComEndpoint | source, |
|
|
const std::vector< std::uint8_t > & | data ) |
|
protectedpure virtual |
Handle an incoming communication message for this sensor.
- Parameters
-
| [in] | source | Endpoint that sent the message. |
| [in] | data | Message payload. |
◆ getEnable()
| bool eduart::device::BaseSensor::getEnable |
( |
| ) |
const |
Query if the sensor is currently enabled.
- Returns
- true if the sensor is enabled.
◆ getIdx()
| unsigned int eduart::device::BaseSensor::getIdx |
( |
| ) |
const |
Get the index of this sensor instance.
- Returns
- Sensor index.
◆ onClearDataFlag()
| virtual void eduart::device::BaseSensor::onClearDataFlag |
( |
| ) |
|
|
protectedpure virtual |
Sensor-specific hook invoked from clearDataFlag().
Implementations should clear any additional flags related to buffered data.
◆ onResetSensorState()
| virtual void eduart::device::BaseSensor::onResetSensorState |
( |
| ) |
|
|
protectedpure virtual |
Sensor-specific hook invoked from resetSensorState().
Implementations should reset any additional state related to errors or measurements.
◆ resetSensorState()
| void eduart::device::BaseSensor::resetSensorState |
( |
| ) |
|
Reset error state and internal flags to nominal values.
Calls the sensor-specific hook onResetSensorState().
◆ setDataAvailableReady()
| void eduart::device::BaseSensor::setDataAvailableReady |
( |
bool | success | ) |
|
|
protected |
Set the result of the current data-available-wait cycle. Called from derived callbacks when "data available" is received.
- Parameters
-
| [in] | success | true if data available was signalled successfully. |
◆ setEnable()
| void eduart::device::BaseSensor::setEnable |
( |
bool | enable | ) |
|
Enable or disable the sensor.
- Parameters
-
| [in] | enable | New enabled state. Set to true to enable the sensor, false to disable it. |
◆ setMeasurementReady()
| void eduart::device::BaseSensor::setMeasurementReady |
( |
bool | success | ) |
|
|
protected |
Set the result of the current measurement-wait cycle. Called from derived callbacks when ready.
- Parameters
-
| [in] | success | true if measurement was fetched successfully. |
◆ setPose()
Set the pose of the sensor in the common coordinate frame.
- Parameters
-
| [in] | translation | Translation of the sensor origin. |
| [in] | rotation | Rotation as Euler angles in degrees. |
◆ _promise_mutex
| std::mutex eduart::device::BaseSensor::_promise_mutex |
|
protected |
Protects promise lifecycles (create in batch thread, set in callback thread).
- Note
- Locking order: acquire _state_mutex before _promise_mutex.
◆ _state_mutex
| std::mutex eduart::device::BaseSensor::_state_mutex |
|
mutableprotected |
Mutex protecting sensor state mutations.
- Note
- Locking order: acquire _state_mutex before _promise_mutex.
The documentation for this class was generated from the following file: