CTRE Phoenix 6 C++ 26.0.0-beta-1
Loading...
Searching...
No Matches
CustomBrushlessMotorConfigs.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
12namespace ctre {
13namespace phoenix6 {
14
15
16namespace configs {
17
18/**
19 * \brief Configs related to using a custom brushless motor that is
20 * not formally supported by Talon FXS.
21 *
22 * \details Configs are only used when Motor Arrangement is set to
23 * Custom Brushless Motor. Note this feature will only work
24 * device is not FRC-Locked.
25 *
26 * Users are responsible for ensuring that these configs are
27 * accurate to the motor. CTR Electronics is not responsible
28 * for damage caused by an incorrect custom motor
29 * configuration.
30 */
32public:
33 constexpr CustomBrushlessMotorConfigs() = default;
34
35 /**
36 * \brief Kv constant of the connected custom brushless motor. This
37 * can usually be determined by consulting the motor manufacturer data
38 * sheet.
39 *
40 * - Minimum Value: 0
41 * - Maximum Value: 2047
42 * - Default Value: 500
43 * - Units: RPM/V
44 */
46 /**
47 * \brief Number of pole pairs in the connected custom brushless motor
48 * (number of poles divided by 2). This can usually be determined by
49 * consulting the motor manufacturer data sheet.
50 *
51 * \details For example, if motor has ten poles, then specify five
52 * pole pairs.
53 *
54 * - Minimum Value: 1
55 * - Maximum Value: 8
56 * - Default Value: 1
57 * - Units:
58 */
60 /**
61 * \brief Expected Hall Value when motor controller applies A+ and B-.
62 *
63 * \details Hall Values are little endian [CBA]. For example, if
64 * halls report: HA=0, HB=0, HC=1, then the Hall Value is 4.
65 *
66 * - Minimum Value: 0
67 * - Maximum Value: 6
68 * - Default Value: 0
69 * - Units:
70 */
71 int HallDuringAB = 0;
72 /**
73 * \brief Expected Hall Value when motor controller applies A+ and C-.
74 *
75 * \details Hall Values are little endian [CBA]. For example, if
76 * halls report: HA=0, HB=0, HC=1, then the Hall Value is 4.
77 *
78 * - Minimum Value: 0
79 * - Maximum Value: 6
80 * - Default Value: 0
81 * - Units:
82 */
83 int HallDuringAC = 0;
84 /**
85 * \brief Optional configuration to correct clockwise versus
86 * counter-clockwise rotor spin.
87 *
88 * \details Depending on the mechanical design of the motor, rotor may
89 * spin clockwise during positive output when Inverted is set to
90 * counterclockwise. This configuration can be toggled so that the
91 * rest of the API is canonically true.
92 *
93 * - Default Value: False
94 */
95 bool HallCCWSelect = false;
96 /**
97 * \brief Determines expected Hall direction for rotor velocity
98 * signage.
99 *
100 * \details If RotorVelocity is signed opposite of applied voltage,
101 * flip this configuration.
102 *
103 * - Default Value: False
104 */
105 bool HallDirection = false;
106
107 /**
108 * \brief Modifies this configuration's MotorKv parameter and returns itself for
109 * method-chaining and easier to use config API.
110 *
111 * Kv constant of the connected custom brushless motor. This can
112 * usually be determined by consulting the motor manufacturer data
113 * sheet.
114 *
115 * - Minimum Value: 0
116 * - Maximum Value: 2047
117 * - Default Value: 500
118 * - Units: RPM/V
119 *
120 * \param newMotorKv Parameter to modify
121 * \returns Itself
122 */
124 {
125 MotorKv = std::move(newMotorKv);
126 return *this;
127 }
128
129 /**
130 * \brief Modifies this configuration's PolePairCount parameter and returns itself for
131 * method-chaining and easier to use config API.
132 *
133 * Number of pole pairs in the connected custom brushless motor
134 * (number of poles divided by 2). This can usually be determined by
135 * consulting the motor manufacturer data sheet.
136 *
137 * \details For example, if motor has ten poles, then specify five
138 * pole pairs.
139 *
140 * - Minimum Value: 1
141 * - Maximum Value: 8
142 * - Default Value: 1
143 * - Units:
144 *
145 * \param newPolePairCount Parameter to modify
146 * \returns Itself
147 */
148 constexpr CustomBrushlessMotorConfigs &WithPolePairCount(int newPolePairCount)
149 {
150 PolePairCount = std::move(newPolePairCount);
151 return *this;
152 }
153
154 /**
155 * \brief Modifies this configuration's HallDuringAB parameter and returns itself for
156 * method-chaining and easier to use config API.
157 *
158 * Expected Hall Value when motor controller applies A+ and B-.
159 *
160 * \details Hall Values are little endian [CBA]. For example, if
161 * halls report: HA=0, HB=0, HC=1, then the Hall Value is 4.
162 *
163 * - Minimum Value: 0
164 * - Maximum Value: 6
165 * - Default Value: 0
166 * - Units:
167 *
168 * \param newHallDuringAB Parameter to modify
169 * \returns Itself
170 */
171 constexpr CustomBrushlessMotorConfigs &WithHallDuringAB(int newHallDuringAB)
172 {
173 HallDuringAB = std::move(newHallDuringAB);
174 return *this;
175 }
176
177 /**
178 * \brief Modifies this configuration's HallDuringAC parameter and returns itself for
179 * method-chaining and easier to use config API.
180 *
181 * Expected Hall Value when motor controller applies A+ and C-.
182 *
183 * \details Hall Values are little endian [CBA]. For example, if
184 * halls report: HA=0, HB=0, HC=1, then the Hall Value is 4.
185 *
186 * - Minimum Value: 0
187 * - Maximum Value: 6
188 * - Default Value: 0
189 * - Units:
190 *
191 * \param newHallDuringAC Parameter to modify
192 * \returns Itself
193 */
194 constexpr CustomBrushlessMotorConfigs &WithHallDuringAC(int newHallDuringAC)
195 {
196 HallDuringAC = std::move(newHallDuringAC);
197 return *this;
198 }
199
200 /**
201 * \brief Modifies this configuration's HallCCWSelect parameter and returns itself for
202 * method-chaining and easier to use config API.
203 *
204 * Optional configuration to correct clockwise versus
205 * counter-clockwise rotor spin.
206 *
207 * \details Depending on the mechanical design of the motor, rotor may
208 * spin clockwise during positive output when Inverted is set to
209 * counterclockwise. This configuration can be toggled so that the
210 * rest of the API is canonically true.
211 *
212 * - Default Value: False
213 *
214 * \param newHallCCWSelect Parameter to modify
215 * \returns Itself
216 */
217 constexpr CustomBrushlessMotorConfigs &WithHallCCWSelect(bool newHallCCWSelect)
218 {
219 HallCCWSelect = std::move(newHallCCWSelect);
220 return *this;
221 }
222
223 /**
224 * \brief Modifies this configuration's HallDirection parameter and returns itself for
225 * method-chaining and easier to use config API.
226 *
227 * Determines expected Hall direction for rotor velocity signage.
228 *
229 * \details If RotorVelocity is signed opposite of applied voltage,
230 * flip this configuration.
231 *
232 * - Default Value: False
233 *
234 * \param newHallDirection Parameter to modify
235 * \returns Itself
236 */
237 constexpr CustomBrushlessMotorConfigs &WithHallDirection(bool newHallDirection)
238 {
239 HallDirection = std::move(newHallDirection);
240 return *this;
241 }
242
243
244
245 std::string ToString() const override;
246
247 std::string Serialize() const final;
248 ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final;
249};
250
251}
252}
253}
Configs related to using a custom brushless motor that is not formally supported by Talon FXS.
Definition CustomBrushlessMotorConfigs.hpp:31
constexpr CustomBrushlessMotorConfigs & WithMotorKv(ctre::unit::rpm_per_volt_t newMotorKv)
Modifies this configuration's MotorKv parameter and returns itself for method-chaining and easier to ...
Definition CustomBrushlessMotorConfigs.hpp:123
bool HallCCWSelect
Optional configuration to correct clockwise versus counter-clockwise rotor spin.
Definition CustomBrushlessMotorConfigs.hpp:95
constexpr CustomBrushlessMotorConfigs & WithHallCCWSelect(bool newHallCCWSelect)
Modifies this configuration's HallCCWSelect parameter and returns itself for method-chaining and easi...
Definition CustomBrushlessMotorConfigs.hpp:217
bool HallDirection
Determines expected Hall direction for rotor velocity signage.
Definition CustomBrushlessMotorConfigs.hpp:105
constexpr CustomBrushlessMotorConfigs & WithPolePairCount(int newPolePairCount)
Modifies this configuration's PolePairCount parameter and returns itself for method-chaining and easi...
Definition CustomBrushlessMotorConfigs.hpp:148
ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final
constexpr CustomBrushlessMotorConfigs & WithHallDirection(bool newHallDirection)
Modifies this configuration's HallDirection parameter and returns itself for method-chaining and easi...
Definition CustomBrushlessMotorConfigs.hpp:237
int HallDuringAC
Expected Hall Value when motor controller applies A+ and C-.
Definition CustomBrushlessMotorConfigs.hpp:83
ctre::unit::rpm_per_volt_t MotorKv
Kv constant of the connected custom brushless motor.
Definition CustomBrushlessMotorConfigs.hpp:45
constexpr CustomBrushlessMotorConfigs & WithHallDuringAC(int newHallDuringAC)
Modifies this configuration's HallDuringAC parameter and returns itself for method-chaining and easie...
Definition CustomBrushlessMotorConfigs.hpp:194
int PolePairCount
Number of pole pairs in the connected custom brushless motor (number of poles divided by 2).
Definition CustomBrushlessMotorConfigs.hpp:59
constexpr CustomBrushlessMotorConfigs & WithHallDuringAB(int newHallDuringAB)
Modifies this configuration's HallDuringAB parameter and returns itself for method-chaining and easie...
Definition CustomBrushlessMotorConfigs.hpp:171
int HallDuringAB
Expected Hall Value when motor controller applies A+ and B-.
Definition CustomBrushlessMotorConfigs.hpp:71
Definition Configuration.hpp:17
units::unit_t< rpm_per_volt > rpm_per_volt_t
Definition motor_constants.h:21
Definition motor_constants.h:14