Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::encoder::WrappedEncoder Class Reference

#include <wrapped_encoder.hpp>

Inheritance diagram for tap::encoder::WrappedEncoder:
Collaboration diagram for tap::encoder::WrappedEncoder:

Public Member Functions

 WrappedEncoder (bool isInverted, uint32_t encoderResolution, float gearRatio=1, uint32_t encoderHomePosition=0)
 
void initialize () override
 
tap::algorithms::WrappedFloat getPosition () const override
 
mockable tap::algorithms::WrappedFloat getEncoder () const
 
float getVelocity () const override
 
void alignWith (EncoderInterface *other) override
 
void resetEncoderValue () override
 
- Public Member Functions inherited from tap::encoder::EncoderInterface
virtual bool isOnline () const =0
 

Protected Member Functions

void updateEncoderValue (uint32_t encoderActual)
 

Protected Attributes

tap::algorithms::WrappedFloat encoder
 
tap::algorithms::WrappedFloat position
 
bool inverted
 
const uint32_t encoderResolution
 
const float gearRatio
 

Detailed Description

Represents an encoder that reports its values as a wrapped number of ticks.

Constructor & Destructor Documentation

◆ WrappedEncoder()

tap::encoder::WrappedEncoder::WrappedEncoder ( bool  isInverted,
uint32_t  encoderResolution,
float  gearRatio = 1,
uint32_t  encoderHomePosition = 0 
)
Parameters
isInvertedif false the positive rotation direction of the shaft is counter-clockwise when looking at the shaft from. If true then the positive rotation direction will be clockwise.
encoderResolutionthe number of encoder ticks before the value wraps.
gearRatiothe ratio of input revolutions over output revolutions of this encoder.
encoderHomePositionthe zero position for the encoder in encoder ticks.

Member Function Documentation

◆ alignWith()

void tap::encoder::WrappedEncoder::alignWith ( EncoderInterface other)
overridevirtual

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.

◆ getEncoder()

mockable tap::algorithms::WrappedFloat tap::encoder::WrappedEncoder::getEncoder ( ) const
inline

Gets the raw encoder position.

◆ getPosition()

tap::algorithms::WrappedFloat tap::encoder::WrappedEncoder::getPosition ( ) const
overridevirtual

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

Implements tap::encoder::EncoderInterface.

◆ getVelocity()

float tap::encoder::WrappedEncoder::getVelocity ( ) const
overridevirtual

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

Implements tap::encoder::EncoderInterface.

◆ initialize()

void tap::encoder::WrappedEncoder::initialize ( )
inlineoverridevirtual

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

Implements tap::encoder::EncoderInterface.

◆ resetEncoderValue()

void tap::encoder::WrappedEncoder::resetEncoderValue ( )
overridevirtual

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

Implements tap::encoder::EncoderInterface.

◆ updateEncoderValue()

void tap::encoder::WrappedEncoder::updateEncoderValue ( uint32_t  encoderActual)
protected

Updates the stored encoder value given a newly received encoder value special logic necessary for keeping track of unwrapped encoder value.

Member Data Documentation

◆ encoder

tap::algorithms::WrappedFloat tap::encoder::WrappedEncoder::encoder
protected

The current encoder position.

◆ encoderResolution

const uint32_t tap::encoder::WrappedEncoder::encoderResolution
protected

◆ gearRatio

const float tap::encoder::WrappedEncoder::gearRatio
protected

◆ inverted

bool tap::encoder::WrappedEncoder::inverted
protected

◆ position

tap::algorithms::WrappedFloat tap::encoder::WrappedEncoder::position
protected

The encoder position converted into output rotations


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