REVLib - C++
rev::SparkMaxAbsoluteEncoder Class Reference

#include <SparkMaxAbsoluteEncoder.h>

Inherits rev::AbsoluteEncoder.

Inherited by rev::SparkAbsoluteEncoder.

Public Types

enum class  Type { kDutyCycle }
 

Public Member Functions

 SparkMaxAbsoluteEncoder (SparkMaxAbsoluteEncoder &&rhs)=default
 
SparkMaxAbsoluteEncoderoperator= (SparkMaxAbsoluteEncoder &&rhs)=default
 
 SparkMaxAbsoluteEncoder (const SparkMaxAbsoluteEncoder &rhs)=default
 
 ~SparkMaxAbsoluteEncoder () override=default
 
double GetPosition () const override
 
double GetVelocity () const override
 
REVLibError SetPositionConversionFactor (double factor) override
 
double GetPositionConversionFactor () const override
 
REVLibError SetVelocityConversionFactor (double factor) override
 
double GetVelocityConversionFactor () const override
 
REVLibError SetInverted (bool inverted) override
 
bool GetInverted () const override
 
REVLibError SetAverageDepth (uint32_t depth) override
 
uint32_t GetAverageDepth () const override
 
REVLibError SetZeroOffset (double offset) override
 
double GetZeroOffset () const override
 
- Public Member Functions inherited from rev::AbsoluteEncoder
virtual ~AbsoluteEncoder ()
 
- Public Member Functions inherited from rev::MotorFeedbackSensor
virtual ~MotorFeedbackSensor ()
 
- Public Member Functions inherited from rev::CANSensor
virtual ~CANSensor ()
 

Friends

class CANSparkBase
 
class SparkAbsoluteEncoder
 

Detailed Description

Member Enumeration Documentation

◆ Type

The type of encoder connected to a SPARK MAX

Deprecated:
Use SparkAbsoluteEncoder::Type instead
Enumerator
kDutyCycle 

Constructor & Destructor Documentation

◆ SparkMaxAbsoluteEncoder() [1/2]

rev::SparkMaxAbsoluteEncoder::SparkMaxAbsoluteEncoder ( SparkMaxAbsoluteEncoder &&  rhs)
default

◆ SparkMaxAbsoluteEncoder() [2/2]

rev::SparkMaxAbsoluteEncoder::SparkMaxAbsoluteEncoder ( const SparkMaxAbsoluteEncoder rhs)
default

◆ ~SparkMaxAbsoluteEncoder()

rev::SparkMaxAbsoluteEncoder::~SparkMaxAbsoluteEncoder ( )
overridedefault

Member Function Documentation

◆ operator=()

SparkMaxAbsoluteEncoder & rev::SparkMaxAbsoluteEncoder::operator= ( SparkMaxAbsoluteEncoder &&  rhs)
default

◆ GetPosition()

double SparkMaxAbsoluteEncoder::GetPosition ( ) const
overridevirtual

Get the position of the motor. This returns the native units of 'rotations' by default, and can be changed by a scale factor using setPositionConversionFactor().

Returns
Number of rotations of the motor

Implements rev::AbsoluteEncoder.

◆ GetVelocity()

double SparkMaxAbsoluteEncoder::GetVelocity ( ) const
overridevirtual

Get the velocity of the motor. This returns the native units of 'rotations per second' by default, and can be changed by a scale factor using setVelocityConversionFactor().

Returns
Number of rotations per second of the motor

Implements rev::AbsoluteEncoder.

◆ SetPositionConversionFactor()

REVLibError SparkMaxAbsoluteEncoder::SetPositionConversionFactor ( double  factor)
overridevirtual

Set the conversion factor for position of the encoder. Multiplied by the native output units to give you position

Parameters
factorThe conversion factor to multiply the native units by
Returns
REVLibError::kOk if successful

Implements rev::AbsoluteEncoder.

◆ GetPositionConversionFactor()

double SparkMaxAbsoluteEncoder::GetPositionConversionFactor ( ) const
overridevirtual

Get the conversion factor for position of the encoder. Multiplied by the native output units to give you position

Returns
The conversion factor for position

Implements rev::AbsoluteEncoder.

◆ SetVelocityConversionFactor()

REVLibError SparkMaxAbsoluteEncoder::SetVelocityConversionFactor ( double  factor)
overridevirtual

Set the conversion factor for velocity of the encoder. Multiplied by the native output units to give you velocity

Parameters
factorThe conversion factor to multiply the native units by
Returns
REVLibError::kOk if successful

Implements rev::AbsoluteEncoder.

◆ GetVelocityConversionFactor()

double SparkMaxAbsoluteEncoder::GetVelocityConversionFactor ( ) const
overridevirtual

Get the conversion factor for velocity of the encoder. Multiplied by the native output units to give you velocity

Returns
The conversion factor for velocity

Implements rev::AbsoluteEncoder.

◆ SetInverted()

REVLibError SparkMaxAbsoluteEncoder::SetInverted ( bool  inverted)
overridevirtual

Set the phase of the AbsoluteEncoder so that it is set to be in phase with the motor itself

Parameters
invertedThe phase of the encoder
Returns
REVLibError::kOk if successful

Implements rev::AbsoluteEncoder.

◆ GetInverted()

bool SparkMaxAbsoluteEncoder::GetInverted ( ) const
overridevirtual

Get the phase of the AbsoluteEncoder

Returns
The phase of the encoder

Implements rev::AbsoluteEncoder.

◆ SetAverageDepth()

REVLibError SparkMaxAbsoluteEncoder::SetAverageDepth ( uint32_t  depth)
overridevirtual

Set the average sampling depth for an absolute encoder. This is a bit size and should be either 1, 2, 4, 8, 16, 32, 64, or 128

Parameters
depthThe average sampling depth of 1, 2, 4, 8, 16, 32, 64, or 128
Returns
REVLibError::kOk if successful

Implements rev::AbsoluteEncoder.

◆ GetAverageDepth()

uint32_t SparkMaxAbsoluteEncoder::GetAverageDepth ( ) const
overridevirtual

Get the average sampling depth for an absolute encoder

Returns
The average sampling depth

Implements rev::AbsoluteEncoder.

◆ SetZeroOffset()

REVLibError SparkMaxAbsoluteEncoder::SetZeroOffset ( double  offset)
overridevirtual

Sets the zero offset of an absolute encoder (the position that is reported as zero).

The zero offset is specified as the reported position of the encoder in the desired zero position, if the zero offset was set to 0. It is influenced by the absolute encoder's position conversion factor, and whether it is inverted.

Always call SetPositionConversionFactor() and SetInverted() before calling this function.

Parameters
offsetThe zero offset with the position conversion factor applied
Returns
REVLibError::kOk if successful

Implements rev::AbsoluteEncoder.

◆ GetZeroOffset()

double SparkMaxAbsoluteEncoder::GetZeroOffset ( ) const
overridevirtual

Gets the zero offset for an absolute encoder (the position that is reported as zero).

The zero offset is specified as the reported position of the encoder in the desired zero position, if the zero offset was set to 0. It is influenced by the absolute encoder's position conversion factor, and whether it is inverted.

Returns
The zero offset of the absolute encoder with the position conversion factor applied

Implements rev::AbsoluteEncoder.

Friends And Related Function Documentation

◆ CANSparkBase

friend class CANSparkBase
friend

◆ SparkAbsoluteEncoder

friend class SparkAbsoluteEncoder
friend

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