21#include "sensorring/platform/SensorringExport.hpp"
Communication endpoint identifier.
Unified device state enum covering lifecycle and runtime health.
DeviceState
Unified lifecycle and runtime state of a device.
Definition DeviceState.hpp:28
Implementation of a matrix of size 3 × 3.
RAII wrapper pairing a SubscriberToken with its cancel function.
Uniquely identifies a communication endpoint by its string ID.
Definition ComEndpoint.hpp:25
bool getEnable() const
Query if the sensor is currently enabled.
void resetSensorState()
Reset error state and internal flags to nominal values.
std::optional< std::promise< bool > > _data_available_promise
Promise for the current data-available-wait cycle; set by callback when "data available" is received.
Definition BaseSensor.hpp:158
DeviceState _error
Current health state of the sensor.
Definition BaseSensor.hpp:138
std::mutex _state_mutex
Definition BaseSensor.hpp:153
std::future< bool > beginMeasurementWait()
Start a measurement-wait cycle and return a future that will be set when the measurement is ready.
virtual void onResetSensorState()=0
Sensor-specific hook invoked from resetSensorState().
math::Matrix3 _rot_m
Rotation matrix derived from the Euler angles.
Definition BaseSensor.hpp:147
void setDataAvailableReady(bool success)
Set the result of the current data-available-wait cycle. Called from derived callbacks when "data ava...
virtual void comCallback(const com::ComEndpoint source, const std::vector< std::uint8_t > &data)=0
Handle an incoming communication message for this sensor.
com::ComInterface * _interface
Communication interface used to talk to the sensor.
Definition BaseSensor.hpp:140
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.
bool _enable_flag
Flag indicating whether the sensor is enabled.
Definition BaseSensor.hpp:150
std::mutex _promise_mutex
Definition BaseSensor.hpp:161
std::future< bool > beginDataAvailableWait()
Start a data-available-wait cycle and return a future that will be set when new data is available.
virtual void onClearDataFlag()=0
Sensor-specific hook invoked from clearDataFlag().
unsigned int _idx
Index of this sensor instance within its group.
Definition BaseSensor.hpp:136
math::Vector3 _translation
Translation of the sensor origin in the common coordinate frame.
Definition BaseSensor.hpp:143
BaseSensor(com::ComInterface *interface, com::ComEndpoint target, unsigned int idx, bool enable)
Construct a base sensor and register it with the communication interface.
void setMeasurementReady(bool success)
Set the result of the current measurement-wait cycle. Called from derived callbacks when ready.
unsigned int getIdx() const
Get the index of this sensor instance.
math::Vector3 _rotation
Rotation of the sensor expressed as Euler angles in degrees.
Definition BaseSensor.hpp:145
virtual ~BaseSensor()
Destructor.
std::optional< std::promise< bool > > _measurement_promise
Promise for the current measurement-wait cycle; set by callback, consumed by wait + get().
Definition BaseSensor.hpp:156
subscription::Subscription _com_subscription
RAII subscription to the communication interface.
Definition BaseSensor.hpp:164
void clearDataFlag()
Clear state for the next measurement cycle. Calls the sensor-specific hook onClearDataFlag().
Move-only RAII wrapper that pairs a SubscriberToken with an unsubscribe callable. Destroying a Subscr...
Definition Subscription.hpp:30
Matrix of size 3 × 3.
Definition Matrix3.hpp:26
Vector of length 3.
Definition Vector3.hpp:25