RaidZeroLib
Coroutine robot framework for VEX V5
Loading...
Searching...
No Matches
rz::Sensor< T > Class Template Referenceabstract

A reading from hardware, or computed from other sensors. More...

#include <Sensor.hpp>

Inheritance diagram for rz::Sensor< T >:
rz::SimulationSensor< T >

Public Member Functions

 Sensor ()=default
 Sensor (const Sensor &)=delete
Sensor & operator= (const Sensor &)=delete
 Sensor (Sensor &&)=delete
Sensor & operator= (Sensor &&)=delete
virtual ~Sensor ()=default
T get ()
 The current reading. The last good value while disconnected.
T delta ()
 Change since the previous snapshot (covers several ticks if nobody read in between).
virtual bool connected () const =0

Protected Member Functions

virtual T raw () const =0
 This tick's reading from the source; the last good value while disconnected. May restart after a reconnect.
virtual std::uint32_t epoch () const
 Increments every time the source reconnects. Readings across a reconnect are not comparable.

Detailed Description

template<class T>
class rz::Sensor< T >

A reading from hardware, or computed from other sensors.

One object per physical source, shared by reference by everything that uses it; nothing a consumer does changes what another sees. A consumer that needs its own zero uses a SensorView.

  • get() is continuous: when the source power-cycles and its reading restarts, get() carries on from its last value instead of jumping. Motion while disconnected is not counted, and neither is motion since the last read before the restart, so something that must not lose any reads the sensor every tick.
  • delta() is the change since the previous snapshot. Every reader in the same tick sees the same value; nothing is consumed. It is zero while disconnected and on the tick the sensor reconnects.

Subclasses implement raw(), connected() and, if the source can restart, epoch().

Constructor & Destructor Documentation

◆ Sensor() [1/3]

template<class T>
rz::Sensor< T >::Sensor ( )
default

◆ Sensor() [2/3]

template<class T>
rz::Sensor< T >::Sensor ( const Sensor< T > & )
delete

◆ Sensor() [3/3]

template<class T>
rz::Sensor< T >::Sensor ( Sensor< T > && )
delete

◆ ~Sensor()

template<class T>
virtual rz::Sensor< T >::~Sensor ( )
virtualdefault

Member Function Documentation

◆ connected()

template<class T>
virtual bool rz::Sensor< T >::connected ( ) const
nodiscardpure virtual

◆ delta()

template<class T>
T rz::Sensor< T >::delta ( )
inlinenodiscard

Change since the previous snapshot (covers several ticks if nobody read in between).

◆ epoch()

template<class T>
virtual std::uint32_t rz::Sensor< T >::epoch ( ) const
inlinenodiscardprotectedvirtual

Increments every time the source reconnects. Readings across a reconnect are not comparable.

Reimplemented in rz::InertialSensor, rz::RotationSensor, and rz::SimulationSensor< T >.

◆ get()

template<class T>
T rz::Sensor< T >::get ( )
inlinenodiscard

The current reading. The last good value while disconnected.

◆ operator=() [1/2]

template<class T>
Sensor & rz::Sensor< T >::operator= ( const Sensor< T > & )
delete

◆ operator=() [2/2]

template<class T>
Sensor & rz::Sensor< T >::operator= ( Sensor< T > && )
delete

◆ raw()

template<class T>
virtual T rz::Sensor< T >::raw ( ) const
nodiscardprotectedpure virtual

This tick's reading from the source; the last good value while disconnected. May restart after a reconnect.

Implemented in rz::InertialSensor, rz::RotationSensor, rz::SimulationSensor< T >, and rz::TrackingWheel.


The documentation for this class was generated from the following file: