CTRE Phoenix C++ 5.33.1
TalonFXSensorCollection.h
Go to the documentation of this file.
1/* Copyright (C) Cross The Road Electronics 2024 */
2#pragma once
3
5
6/* forward proto's */
7namespace ctre {
8 namespace phoenix {
9 namespace motorcontrol {
10 namespace can {
11 class BaseTalon;
12 }
13 }
14 }
15}
16
17namespace ctre {
18 namespace phoenix {
19 namespace motorcontrol {
20
21 /**
22 * Collection of sensors available to the Talon FX.
23 *
24 * For best performance and update-rate,
25 * we recommend using the configSelectedFeedbackSensor() and getSelectedSensor*() routines.
26 * However there are occasions where accessing raw sensor values may be useful or convenient.
27 * Particularly if you are seeding one sensor based on another, or need to circumvent sensor-phase.
28 *
29 * Use the GetTalonFXSensorCollection() routine inside your motor controller to create a sensor collection.
30 *
31 * @deprecated This device's Phoenix 5 API is deprecated for removal in the
32 * 2025 season. Users should update to Phoenix 6 firmware and migrate to the
33 * Phoenix 6 API. A migration guide is available at
34 * https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html.
35 *
36 * If the Phoenix 5 API must be used for this device, the device must have 22.X
37 * firmware. This firmware is available in Tuner X after selecting Phoenix 5 in
38 * the firmware year dropdown.
39 */
41 public:
42 /**
43 * Constructor for TalonFXSensorCollection
44 * @param motorController Talon Motor Controller to connect Collection to
45 */
47
48 /**
49 * Get the IntegratedSensor position of the Talon FX, regardless of whether
50 * it is actually being used for feedback. The units are 2048 per rotation.
51 * Note : Future versions of software may support scaling features (rotations, radians, degrees, etc) depending on the configuration.
52 *
53 * This method relies on the Status 21 message, which has a default period of 240ms. For more
54 * information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html
55 *
56 * @return the IntegratedSensor position.
57 */
58
60 /**
61 * Get the IntegratedSensor absolute position of the Talon FX, regardless of whether
62 * it is actually being used for feedback. This will be within one rotation (2048 units).
63 * The signage and range will depend on the configuration.
64 * Note : Future versions of software may support scaling features (rotations, radians, degrees, etc) depending on the configuration.
65 *
66 * This method relies on the Status 21 message, which has a default period of 240ms. For more
67 * information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html
68 *
69 * @return the IntegratedSensor absolute position.
70 */
72
73 /**
74 * Get the IntegratedSensor velocity of the Talon FX, regardless of whether
75 * it is actually being used for feedback.
76 * One unit represents one position unit per 100ms (2048 position units per 100ms).
77 * The signage and range will depend on the configuration.
78 * Note : Future versions of software may support scaling features (rotations, radians, degrees, etc) depending on the configuration.
79 *
80 * This method relies on the Status 21 message, which has a default period of 240ms. For more
81 * information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html
82 *
83 * @return the IntegratedSensor velocity.
84 */
86
87 /**
88 * Set the IntegratedSensor reported position. Typically this is used to "zero" the
89 * sensor. This only works with IntegratedSensor. To set the selected sensor position
90 * regardless of what type it is, see SetSelectedSensorPosition in the motor controller class.
91 *
92 * @param newPosition The position value to apply to the sensor.
93 * @param timeoutMs
94 * Timeout value in ms. If nonzero, function will wait for
95 * config success and report an error if it times out.
96 * If zero, no blocking or checking is performed.
97 *
98 * @return error code.
99 */
100 ErrorCode SetIntegratedSensorPosition(double newPosition, int timeoutMs = 0);
101
102 /**
103 * Set the IntegratedSensor reported position based on the absolute position.
104 * This can also be done automatically on power boot depending on configuration.
105 *
106 * @param timeoutMs
107 * Timeout value in ms. If nonzero, function will wait for
108 * config success and report an error if it times out.
109 * If zero, no blocking or checking is performed.
110 *
111 * @return error code.
112 */
114
115 /**
116 * Is forward limit switch closed.
117 *
118 * This method relies on the Status 1 message, which has a default period of 10ms. For more
119 * information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html
120 *
121 * @return '1' iff forward limit switch is closed, 0 iff switch is open. This function works
122 * regardless if limit switch feature is enabled. Remote limit features do not impact this routine.
123 */
124
126
127 /**
128 * Is reverse limit switch closed.
129 *
130 * This method relies on the Status 1 message, which has a default period of 10ms. For more
131 * information, see: https://phoenix-documentation.readthedocs.io/en/latest/ch18_CommonAPI.html
132 *
133 * @return '1' iff reverse limit switch is closed, 0 iff switch is open. This function works
134 * regardless if limit switch feature is enabled. Remote limit features do not impact this routine.
135 */
136
138
139 private:
140 void* _handle;
141 };
142
143 } // namespace motorcontrol
144 } // namespace phoenix
145} // namespace ctre
Collection of sensors available to the Talon FX.
Definition: TalonFXSensorCollection.h:40
TalonFXSensorCollection(ctre::phoenix::motorcontrol::can::BaseTalon &motorController)
Constructor for TalonFXSensorCollection.
double GetIntegratedSensorVelocity()
Get the IntegratedSensor velocity of the Talon FX, regardless of whether it is actually being used fo...
double GetIntegratedSensorAbsolutePosition()
Get the IntegratedSensor absolute position of the Talon FX, regardless of whether it is actually bein...
ErrorCode SetIntegratedSensorPosition(double newPosition, int timeoutMs=0)
Set the IntegratedSensor reported position.
int IsFwdLimitSwitchClosed()
Is forward limit switch closed.
int IsRevLimitSwitchClosed()
Is reverse limit switch closed.
double GetIntegratedSensorPosition()
Get the IntegratedSensor position of the Talon FX, regardless of whether it is actually being used fo...
ErrorCode SetIntegratedSensorPositionToAbsolute(int timeoutMs=0)
Set the IntegratedSensor reported position based on the absolute position.
CTRE Talon SRX Motor Controller when used on CAN Bus.
Definition: BaseTalon.h:267
ErrorCode
Definition: ErrorCode.h:13
namespace ctre
Definition: paramEnum.h:5