CTRE Phoenix 6 C++ 25.0.0-beta-4
Loading...
Searching...
No Matches
ctre::phoenix6::configs::MagnetSensorConfigs Class Reference

Configs that affect the magnet sensor and how to interpret it. More...

#include <ctre/phoenix6/configs/Configs.hpp>

Inheritance diagram for ctre::phoenix6::configs::MagnetSensorConfigs:
ctre::phoenix6::configs::ParentConfiguration ctre::phoenix6::ISerializable

Public Member Functions

constexpr MagnetSensorConfigs ()=default
 
constexpr MagnetSensorConfigsWithSensorDirection (signals::SensorDirectionValue newSensorDirection)
 Modifies this configuration's SensorDirection parameter and returns itself for method-chaining and easier to use config API.
 
constexpr MagnetSensorConfigsWithMagnetOffset (units::angle::turn_t newMagnetOffset)
 Modifies this configuration's MagnetOffset parameter and returns itself for method-chaining and easier to use config API.
 
constexpr MagnetSensorConfigsWithAbsoluteSensorDiscontinuityPoint (units::angle::turn_t newAbsoluteSensorDiscontinuityPoint)
 Modifies this configuration's AbsoluteSensorDiscontinuityPoint parameter and returns itself for method-chaining and easier to use config API.
 
std::string ToString () const override
 
std::string Serialize () const override
 
ctre::phoenix::StatusCode Deserialize (const std::string &to_deserialize) override
 

Public Attributes

signals::SensorDirectionValue SensorDirection = signals::SensorDirectionValue::CounterClockwise_Positive
 Direction of the sensor to determine positive rotation, as seen facing the LED side of the CANcoder.
 
units::angle::turn_t MagnetOffset = 0_tr
 This offset is added to the reported position, allowing the application to trim the zero position.
 
units::angle::turn_t AbsoluteSensorDiscontinuityPoint = 0.5_tr
 The positive discontinuity point of the absolute sensor in rotations.
 

Detailed Description

Configs that affect the magnet sensor and how to interpret it.

Includes sensor direction, the sensor discontinuity point, and the magnet offset.

Constructor & Destructor Documentation

◆ MagnetSensorConfigs()

constexpr ctre::phoenix6::configs::MagnetSensorConfigs::MagnetSensorConfigs ( )
constexprdefault

Member Function Documentation

◆ Deserialize()

ctre::phoenix::StatusCode ctre::phoenix6::configs::MagnetSensorConfigs::Deserialize ( const std::string & to_deserialize)
inlineoverridevirtual

◆ Serialize()

std::string ctre::phoenix6::configs::MagnetSensorConfigs::Serialize ( ) const
inlineoverridevirtual

◆ ToString()

std::string ctre::phoenix6::configs::MagnetSensorConfigs::ToString ( ) const
inlineoverridevirtual

◆ WithAbsoluteSensorDiscontinuityPoint()

constexpr MagnetSensorConfigs & ctre::phoenix6::configs::MagnetSensorConfigs::WithAbsoluteSensorDiscontinuityPoint ( units::angle::turn_t newAbsoluteSensorDiscontinuityPoint)
inlineconstexpr

Modifies this configuration's AbsoluteSensorDiscontinuityPoint parameter and returns itself for method-chaining and easier to use config API.

The positive discontinuity point of the absolute sensor in rotations. This determines the point at which the absolute sensor wraps around, keeping the absolute position in the range [x-1, x).

  • Setting this to 1 makes the absolute position unsigned [0, 1)
  • Setting this to 0.5 makes the absolute position signed [-0.5, 0.5)
  • Setting this to 0 makes the absolute position always negative [-1, 0)

Many rotational mechanisms such as arms have a region of motion that is unreachable. This should be set to the center of that region of motion, in non-negative rotations. This affects the position of the device at bootup.

For example, consider an arm which can travel from -0.2 to 0.6 rotations with a little leeway, where 0 is horizontally forward. Since -0.2 rotations has the same absolute position as 0.8 rotations, we can say that the arm typically does not travel in the range (0.6, 0.8) rotations. As a result, the discontinuity point would be the center of that range, which is 0.7 rotations. This results in an absolute sensor range of [-0.3, 0.7) rotations.

On a Talon motor controller, this is only supported when using the PulseWidth sensor source.

  • Minimum Value: 0.0
  • Maximum Value: 1.0
  • Default Value: 0.5
  • Units: rotations
Parameters
newAbsoluteSensorDiscontinuityPointParameter to modify
Returns
Itself

◆ WithMagnetOffset()

constexpr MagnetSensorConfigs & ctre::phoenix6::configs::MagnetSensorConfigs::WithMagnetOffset ( units::angle::turn_t newMagnetOffset)
inlineconstexpr

Modifies this configuration's MagnetOffset parameter and returns itself for method-chaining and easier to use config API.

This offset is added to the reported position, allowing the application to trim the zero position. When set to the default value of zero, position reports zero when magnet north pole aligns with the LED.

  • Minimum Value: -1
  • Maximum Value: 1
  • Default Value: 0
  • Units: rotations
Parameters
newMagnetOffsetParameter to modify
Returns
Itself

◆ WithSensorDirection()

constexpr MagnetSensorConfigs & ctre::phoenix6::configs::MagnetSensorConfigs::WithSensorDirection ( signals::SensorDirectionValue newSensorDirection)
inlineconstexpr

Modifies this configuration's SensorDirection parameter and returns itself for method-chaining and easier to use config API.

Direction of the sensor to determine positive rotation, as seen facing the LED side of the CANcoder.

Parameters
newSensorDirectionParameter to modify
Returns
Itself

Member Data Documentation

◆ AbsoluteSensorDiscontinuityPoint

units::angle::turn_t ctre::phoenix6::configs::MagnetSensorConfigs::AbsoluteSensorDiscontinuityPoint = 0.5_tr

The positive discontinuity point of the absolute sensor in rotations.

This determines the point at which the absolute sensor wraps around, keeping the absolute position in the range [x-1, x).

  • Setting this to 1 makes the absolute position unsigned [0, 1)
  • Setting this to 0.5 makes the absolute position signed [-0.5, 0.5)
  • Setting this to 0 makes the absolute position always negative [-1, 0)

Many rotational mechanisms such as arms have a region of motion that is unreachable. This should be set to the center of that region of motion, in non-negative rotations. This affects the position of the device at bootup.

For example, consider an arm which can travel from -0.2 to 0.6 rotations with a little leeway, where 0 is horizontally forward. Since -0.2 rotations has the same absolute position as 0.8 rotations, we can say that the arm typically does not travel in the range (0.6, 0.8) rotations. As a result, the discontinuity point would be the center of that range, which is 0.7 rotations. This results in an absolute sensor range of [-0.3, 0.7) rotations.

On a Talon motor controller, this is only supported when using the PulseWidth sensor source.

  • Minimum Value: 0.0
  • Maximum Value: 1.0
  • Default Value: 0.5
  • Units: rotations

◆ MagnetOffset

units::angle::turn_t ctre::phoenix6::configs::MagnetSensorConfigs::MagnetOffset = 0_tr

This offset is added to the reported position, allowing the application to trim the zero position.

When set to the default value of zero, position reports zero when magnet north pole aligns with the LED.

  • Minimum Value: -1
  • Maximum Value: 1
  • Default Value: 0
  • Units: rotations

◆ SensorDirection

signals::SensorDirectionValue ctre::phoenix6::configs::MagnetSensorConfigs::SensorDirection = signals::SensorDirectionValue::CounterClockwise_Positive

Direction of the sensor to determine positive rotation, as seen facing the LED side of the CANcoder.


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