CTRE Phoenix C++ 5.33.1
ctre::phoenix::sensors::CANCoderConfiguration Struct Reference

Configurables available to CANCoder. More...

#include <ctre/phoenix/sensors/CANCoder.h>

Inheritance diagram for ctre::phoenix::sensors::CANCoderConfiguration:
ctre::phoenix::CustomParamConfiguration

Public Member Functions

 CANCoderConfiguration ()
 Constructor. More...
 
std::string toString ()
 
std::string toString (std::string prependString)
 
- Public Member Functions inherited from ctre::phoenix::CustomParamConfiguration
 CustomParamConfiguration ()
 
std::string toString ()
 
std::string toString (std::string prependString)
 

Public Attributes

SensorVelocityMeasPeriod velocityMeasurementPeriod = SensorVelocityMeasPeriod::Period_100Ms
 Velocity measurement period to use. More...
 
int velocityMeasurementWindow = 64
 Velocity measurement window to use. More...
 
ctre::phoenix::sensors::AbsoluteSensorRange absoluteSensorRange = AbsoluteSensorRange::Unsigned_0_to_360
 Desired Sign / Range for the absolute position register. More...
 
double magnetOffsetDegrees = 0
 Adjusts the zero point for the absolute position register. More...
 
bool sensorDirection = false
 Choose which direction is interpreted as positive displacement. More...
 
ctre::phoenix::sensors::SensorInitializationStrategy initializationStrategy = ctre::phoenix::sensors::SensorInitializationStrategy::BootToZero
 The sensor initialization strategy to use.This will impact the behavior the next time CANCoder boots up. More...
 
double sensorCoefficient = 360.0 / 4096.0
 Scalar to multiply the CANCoder's native 12-bit resolute sensor. More...
 
std::string unitString = "deg"
 String holding the unit to report in. More...
 
ctre::phoenix::sensors::SensorTimeBase sensorTimeBase = ctre::phoenix::sensors::SensorTimeBase::PerSecond
 Desired denominator to report velocity in. More...
 
- Public Attributes inherited from ctre::phoenix::CustomParamConfiguration
int customParam0
 Custom Param 0. More...
 
int customParam1
 Custom Param 1. More...
 
bool enableOptimizations
 Enable optimizations for ConfigAll (defaults true) More...
 

Detailed Description

Configurables available to CANCoder.

Deprecated:
This device's Phoenix 5 API is deprecated for removal in the 2025 season. Users should update to Phoenix 6 firmware and migrate to the Phoenix 6 API. A migration guide is available at https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html.

If the Phoenix 5 API must be used for this device, the device must have 22.X firmware. This firmware is available in Tuner X after selecting Phoenix 5 in the firmware year dropdown.

Constructor & Destructor Documentation

◆ CANCoderConfiguration()

ctre::phoenix::sensors::CANCoderConfiguration::CANCoderConfiguration ( )
inline

Constructor.

Member Function Documentation

◆ toString() [1/2]

std::string ctre::phoenix::sensors::CANCoderConfiguration::toString ( )
inline
Returns
String representation of configs

◆ toString() [2/2]

std::string ctre::phoenix::sensors::CANCoderConfiguration::toString ( std::string  prependString)
inline
Parameters
prependStringString to prepend to configs
Returns
String representation of configs

Member Data Documentation

◆ absoluteSensorRange

ctre::phoenix::sensors::AbsoluteSensorRange ctre::phoenix::sensors::CANCoderConfiguration::absoluteSensorRange = AbsoluteSensorRange::Unsigned_0_to_360

Desired Sign / Range for the absolute position register.

Choose unsigned for an absolute range of[0, +1) rotations, [0, 360) deg, etc. Choose signed for an absolute range of[-0.5, +0.5) rotations, [-180, +180) deg, etc.

◆ initializationStrategy

ctre::phoenix::sensors::SensorInitializationStrategy ctre::phoenix::sensors::CANCoderConfiguration::initializationStrategy = ctre::phoenix::sensors::SensorInitializationStrategy::BootToZero

The sensor initialization strategy to use.This will impact the behavior the next time CANCoder boots up.

Pick the strategy on how to initialize the CANCoder's "Position" register. Depending on the mechanism, it may be desirable to auto set the Position register to match the Absolute Position(swerve for example). Or it may be desired to zero the sensor on boot(drivetrain translation sensor or a relative servo).

TIP: Tuner's self-test feature will report what the boot sensor value will be in the event the CANCoder is reset.

◆ magnetOffsetDegrees

double ctre::phoenix::sensors::CANCoderConfiguration::magnetOffsetDegrees = 0

Adjusts the zero point for the absolute position register.

The absolute position of the sensor will always have a discontinuity (360 -> 0 deg) or (+180 -> -180) and a hard-limited mechanism may have such a discontinuity in its functional range. In which case use this config to move the discontinuity outside of the function range.

◆ sensorCoefficient

double ctre::phoenix::sensors::CANCoderConfiguration::sensorCoefficient = 360.0 / 4096.0

Scalar to multiply the CANCoder's native 12-bit resolute sensor.

Defaults to 0.087890625 to produce degrees.

◆ sensorDirection

bool ctre::phoenix::sensors::CANCoderConfiguration::sensorDirection = false

Choose which direction is interpreted as positive displacement.

This affects both "Position"and "Absolute Position". False(default) means positive rotation occurs when magnet is spun counter - clockwise when observer is facing the LED side of CANCoder.

◆ sensorTimeBase

ctre::phoenix::sensors::SensorTimeBase ctre::phoenix::sensors::CANCoderConfiguration::sensorTimeBase = ctre::phoenix::sensors::SensorTimeBase::PerSecond

Desired denominator to report velocity in.

This impacts GetVelocityand the reported velocity in self-test in Tuner. Default is "Per Second".

◆ unitString

std::string ctre::phoenix::sensors::CANCoderConfiguration::unitString = "deg"

String holding the unit to report in.

This impacts all routines(except for ConfigMagnetOffset) and the self-test in Tuner. The string value itself is arbitrary.The max number of letters will depend on firmware versioning, but generally CANCoder supports up to eight letters.However, common units such as "centimeters" are supported explicitly despite exceeding the eight-letter limit. Default is "deg"

◆ velocityMeasurementPeriod

SensorVelocityMeasPeriod ctre::phoenix::sensors::CANCoderConfiguration::velocityMeasurementPeriod = SensorVelocityMeasPeriod::Period_100Ms

Velocity measurement period to use.

◆ velocityMeasurementWindow

int ctre::phoenix::sensors::CANCoderConfiguration::velocityMeasurementWindow = 64

Velocity measurement window to use.


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