CTRE Phoenix 6 C++ 26.50.0-alpha-1
Loading...
Searching...
No Matches
DifferentialSensorsConfigs.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) Cross The Road Electronics.  All rights reserved.
3 * License information can be found in CTRE_LICENSE.txt
4 * For support and suggestions contact support@ctr-electronics.com or file
5 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases
6 */
7#pragma once
8
11#include <wpi/units/dimensionless.hpp>
12
13namespace ctre {
14namespace phoenix6 {
15
16
17namespace configs {
18
19/**
20 * \brief Configs related to sensors used for differential control of
21 * a mechanism.
22 *
23 * \details Includes the differential sensor sources and IDs.
24 */
26public:
27 constexpr DifferentialSensorsConfigs() = default;
28
29 /**
30 * \brief Choose what sensor source is used for differential control
31 * of a mechanism. The default is Disabled. All other options
32 * require setting the DifferentialTalonFXSensorID, as the average of
33 * this Talon FX's sensor and the remote TalonFX's sensor is used for
34 * the differential controller's primary targets.
35 *
36 * Choose RemoteTalonFX_HalfDiff to use another TalonFX on the same
37 * CAN bus. Talon FX will update its differential position and
38 * velocity whenever the remote TalonFX publishes its information on
39 * CAN bus. The differential controller will use half of the
40 * difference between this TalonFX's sensor and the remote Talon FX's
41 * sensor for the differential component of the output.
42 *
43 * Choose RemotePigeon2Yaw, RemotePigeon2Pitch, and RemotePigeon2Roll
44 * to use another Pigeon2 on the same CAN bus (this also requires
45 * setting DifferentialRemoteSensorID). Talon FX will update its
46 * differential position to match the selected value whenever Pigeon2
47 * publishes its information on CAN bus. Note that the Talon FX
48 * differential position will be in rotations and not degrees.
49 *
50 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus
51 * (this also requires setting DifferentialRemoteSensorID). Talon FX
52 * will update its differential position and velocity to match the
53 * CANcoder whenever CANcoder publishes its information on CAN bus.
54 *
55 * - Default Value: signals#DifferentialSensorSourceValue#Disabled
56 */
58 /**
59 * \brief Device ID of which remote Talon FX to use. This is used
60 * whenever the Differential Sensor Source is not disabled.
61 *
62 * The differential Talon FX must enable its Position and Velocity
63 * status signals. The update rate of the status signals determines
64 * the update rate of differential control.
65 *
66 * - Minimum Value: 0
67 * - Maximum Value: 62
68 * - Default Value: 0
69 * - Units:
70 */
72 /**
73 * \brief Device ID of which remote sensor to use on the differential
74 * axis. This is used when the Differential Sensor Source is not
75 * Disabled or RemoteTalonFX_HalfDiff.
76 *
77 * - Minimum Value: 0
78 * - Maximum Value: 62
79 * - Default Value: 0
80 * - Units:
81 */
83 /**
84 * \brief The ratio of sensor rotations to the differential
85 * mechanism's difference output, where a ratio greater than 1 is a
86 * reduction.
87 *
88 * When using RemoteTalonFX_HalfDiff, the sensor is considered half of
89 * the difference between the two devices' mechanism
90 * positions/velocities. As a result, this should be set to the gear
91 * ratio on the difference axis when using RemoteTalonFX_HalfDiff, or
92 * any gear ratio between the sensor and the mechanism differential
93 * when using another sensor source.
94 *
95 * We recommend against using this config to perform onboard unit
96 * conversions. Instead, unit conversions should be performed in
97 * robot code using the units library.
98 *
99 * If this is set to zero, the device will reset back to one.
100 *
101 * - Minimum Value: -1000
102 * - Maximum Value: 1000
103 * - Default Value: 1.0
104 * - Units: scalar
105 */
106 wpi::units::scalar_t SensorToDifferentialRatio = 1.0;
107
108 /**
109 * \brief Modifies this configuration's DifferentialSensorSource parameter and returns itself for
110 * method-chaining and easier to use config API.
111 *
112 * Choose what sensor source is used for differential control of a
113 * mechanism. The default is Disabled. All other options require
114 * setting the DifferentialTalonFXSensorID, as the average of this
115 * Talon FX's sensor and the remote TalonFX's sensor is used for the
116 * differential controller's primary targets.
117 *
118 * Choose RemoteTalonFX_HalfDiff to use another TalonFX on the same
119 * CAN bus. Talon FX will update its differential position and
120 * velocity whenever the remote TalonFX publishes its information on
121 * CAN bus. The differential controller will use half of the
122 * difference between this TalonFX's sensor and the remote Talon FX's
123 * sensor for the differential component of the output.
124 *
125 * Choose RemotePigeon2Yaw, RemotePigeon2Pitch, and RemotePigeon2Roll
126 * to use another Pigeon2 on the same CAN bus (this also requires
127 * setting DifferentialRemoteSensorID). Talon FX will update its
128 * differential position to match the selected value whenever Pigeon2
129 * publishes its information on CAN bus. Note that the Talon FX
130 * differential position will be in rotations and not degrees.
131 *
132 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus
133 * (this also requires setting DifferentialRemoteSensorID). Talon FX
134 * will update its differential position and velocity to match the
135 * CANcoder whenever CANcoder publishes its information on CAN bus.
136 *
137 * - Default Value: signals#DifferentialSensorSourceValue#Disabled
138 *
139 * \param newDifferentialSensorSource Parameter to modify
140 * \returns Itself
141 */
143 {
144 DifferentialSensorSource = std::move(newDifferentialSensorSource);
145 return *this;
146 }
147
148 /**
149 * \brief Modifies this configuration's DifferentialTalonFXSensorID parameter and returns itself for
150 * method-chaining and easier to use config API.
151 *
152 * Device ID of which remote Talon FX to use. This is used whenever
153 * the Differential Sensor Source is not disabled.
154 *
155 * The differential Talon FX must enable its Position and Velocity
156 * status signals. The update rate of the status signals determines
157 * the update rate of differential control.
158 *
159 * - Minimum Value: 0
160 * - Maximum Value: 62
161 * - Default Value: 0
162 * - Units:
163 *
164 * \param newDifferentialTalonFXSensorID Parameter to modify
165 * \returns Itself
166 */
167 constexpr DifferentialSensorsConfigs &WithDifferentialTalonFXSensorID(int newDifferentialTalonFXSensorID)
168 {
169 DifferentialTalonFXSensorID = std::move(newDifferentialTalonFXSensorID);
170 return *this;
171 }
172
173 /**
174 * \brief Modifies this configuration's DifferentialRemoteSensorID parameter and returns itself for
175 * method-chaining and easier to use config API.
176 *
177 * Device ID of which remote sensor to use on the differential axis.
178 * This is used when the Differential Sensor Source is not Disabled or
179 * RemoteTalonFX_HalfDiff.
180 *
181 * - Minimum Value: 0
182 * - Maximum Value: 62
183 * - Default Value: 0
184 * - Units:
185 *
186 * \param newDifferentialRemoteSensorID Parameter to modify
187 * \returns Itself
188 */
189 constexpr DifferentialSensorsConfigs &WithDifferentialRemoteSensorID(int newDifferentialRemoteSensorID)
190 {
191 DifferentialRemoteSensorID = std::move(newDifferentialRemoteSensorID);
192 return *this;
193 }
194
195 /**
196 * \brief Modifies this configuration's SensorToDifferentialRatio parameter and returns itself for
197 * method-chaining and easier to use config API.
198 *
199 * The ratio of sensor rotations to the differential mechanism's
200 * difference output, where a ratio greater than 1 is a reduction.
201 *
202 * When using RemoteTalonFX_HalfDiff, the sensor is considered half of
203 * the difference between the two devices' mechanism
204 * positions/velocities. As a result, this should be set to the gear
205 * ratio on the difference axis when using RemoteTalonFX_HalfDiff, or
206 * any gear ratio between the sensor and the mechanism differential
207 * when using another sensor source.
208 *
209 * We recommend against using this config to perform onboard unit
210 * conversions. Instead, unit conversions should be performed in
211 * robot code using the units library.
212 *
213 * If this is set to zero, the device will reset back to one.
214 *
215 * - Minimum Value: -1000
216 * - Maximum Value: 1000
217 * - Default Value: 1.0
218 * - Units: scalar
219 *
220 * \param newSensorToDifferentialRatio Parameter to modify
221 * \returns Itself
222 */
223 constexpr DifferentialSensorsConfigs &WithSensorToDifferentialRatio(wpi::units::scalar_t newSensorToDifferentialRatio)
224 {
225 SensorToDifferentialRatio = std::move(newSensorToDifferentialRatio);
226 return *this;
227 }
228
229
230
231 std::string ToString() const override;
232
233 std::string Serialize() const final;
234 ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final;
235};
236
237}
238}
239}
wpi::units::scalar_t SensorToDifferentialRatio
The ratio of sensor rotations to the differential mechanism's difference output, where a ratio greate...
Definition DifferentialSensorsConfigs.hpp:106
constexpr DifferentialSensorsConfigs & WithDifferentialTalonFXSensorID(int newDifferentialTalonFXSensorID)
Modifies this configuration's DifferentialTalonFXSensorID parameter and returns itself for method-cha...
Definition DifferentialSensorsConfigs.hpp:167
constexpr DifferentialSensorsConfigs & WithDifferentialSensorSource(signals::DifferentialSensorSourceValue newDifferentialSensorSource)
Modifies this configuration's DifferentialSensorSource parameter and returns itself for method-chaini...
Definition DifferentialSensorsConfigs.hpp:142
constexpr DifferentialSensorsConfigs & WithSensorToDifferentialRatio(wpi::units::scalar_t newSensorToDifferentialRatio)
Modifies this configuration's SensorToDifferentialRatio parameter and returns itself for method-chain...
Definition DifferentialSensorsConfigs.hpp:223
ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final
signals::DifferentialSensorSourceValue DifferentialSensorSource
Choose what sensor source is used for differential control of a mechanism.
Definition DifferentialSensorsConfigs.hpp:57
int DifferentialRemoteSensorID
Device ID of which remote sensor to use on the differential axis.
Definition DifferentialSensorsConfigs.hpp:82
constexpr DifferentialSensorsConfigs & WithDifferentialRemoteSensorID(int newDifferentialRemoteSensorID)
Modifies this configuration's DifferentialRemoteSensorID parameter and returns itself for method-chai...
Definition DifferentialSensorsConfigs.hpp:189
int DifferentialTalonFXSensorID
Device ID of which remote Talon FX to use.
Definition DifferentialSensorsConfigs.hpp:71
Definition Configuration.hpp:17
Definition ExternalFeedbackConfigs.hpp:21
Definition ExternalFeedbackConfigs.hpp:16
Definition FrcUsageReport.hpp:12
Definition motor_constants.h:14
Choose what sensor source is used for differential control of a mechanism.
Definition SpnEnums.hpp:2343
static constexpr int Disabled
Disable differential control.
Definition SpnEnums.hpp:2349