Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::encoder::MultiEncoder< COUNT > Class Template Reference

#include <multi_encoder.hpp>

Inheritance diagram for tap::encoder::MultiEncoder< COUNT >:
Collaboration diagram for tap::encoder::MultiEncoder< COUNT >:

Public Member Functions

 MultiEncoder (std::array< EncoderInterface *, COUNT > encoders)
 
void initialize () override
 
bool isOnline () const override
 
tap::algorithms::WrappedFloat getPosition () const override
 
float getVelocity () const override
 
void resetEncoderValue () override
 
void alignWith (EncoderInterface *other) override
 

Detailed Description

template<uint32_t COUNT>
class tap::encoder::MultiEncoder< COUNT >

A way to combine multiple encoders into one functional unit. The first encoder in the array must not be null, as it is the primary encoder. All other values can be null. This encoder uses the primary encoder as an initial source of truth. This allows the other encoders to align themselves to it, and then have the primary encoder disconnect with the system still working. This encoder is not valid until the primary encoder comes online, and stays online until either all synced encoders disconnect, or the primary encoder is offline and no other encoders have been synced. The positions returned by this encoder are averaged between all synced and online encoders.

Constructor & Destructor Documentation

◆ MultiEncoder()

template<uint32_t COUNT>
tap::encoder::MultiEncoder< COUNT >::MultiEncoder ( std::array< EncoderInterface *, COUNT >  encoders)
inline

Member Function Documentation

◆ alignWith()

template<uint32_t COUNT>
void tap::encoder::MultiEncoder< COUNT >::alignWith ( EncoderInterface other)
inlineoverridevirtual

Aligns this encoder to another encoder so that their positions are equal. If the two encoders are mechanically linked, they would then continue to report the same position.

Implements tap::encoder::EncoderInterface.

◆ getPosition()

template<uint32_t COUNT>
tap::algorithms::WrappedFloat tap::encoder::MultiEncoder< COUNT >::getPosition ( ) const
inlineoverridevirtual

Gets the current position of the encoder, in a wrapped float on the range [0, M_TWOPI)

Implements tap::encoder::EncoderInterface.

◆ getVelocity()

template<uint32_t COUNT>
float tap::encoder::MultiEncoder< COUNT >::getVelocity ( ) const
inlineoverridevirtual

Gets the current velocity reported by the encoder. Returned in a value of radians / second

Implements tap::encoder::EncoderInterface.

◆ initialize()

template<uint32_t COUNT>
void tap::encoder::MultiEncoder< COUNT >::initialize ( )
inlineoverridevirtual

Initialize the encoder. For instance: attaching a can receiver.

Implements tap::encoder::EncoderInterface.

◆ isOnline()

template<uint32_t COUNT>
bool tap::encoder::MultiEncoder< COUNT >::isOnline ( ) const
inlineoverridevirtual

Returns true when the encoder is online and reporting valid values.

Implements tap::encoder::EncoderInterface.

◆ resetEncoderValue()

template<uint32_t COUNT>
void tap::encoder::MultiEncoder< COUNT >::resetEncoderValue ( )
inlineoverridevirtual

Zeros the encoder to its current position. All encoder positions will be based from this position.

Implements tap::encoder::EncoderInterface.


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