CTRE Phoenix 6 C++ 26.0.0-beta-1
Loading...
Searching...
No Matches
MotionMagicConfigs.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
10#include "ctre/unit/pid_ff.h"
11#include <units/angular_acceleration.h>
12#include <units/angular_jerk.h>
13#include <units/angular_velocity.h>
14
15namespace ctre {
16namespace phoenix6 {
17
18
19namespace configs {
20
21/**
22 * \brief Configs for Motion Magic®.
23 *
24 * \details Includes Velocity, Acceleration, Jerk, and Expo
25 * parameters.
26 */
28public:
29 constexpr MotionMagicConfigs() = default;
30
31 /**
32 * \brief This is the maximum velocity Motion Magic® based control
33 * modes are allowed to use. Motion Magic® Velocity control modes do
34 * not use this config.
35 *
36 * When using Motion Magic® Expo control modes, setting this to 0 will
37 * allow the profile to run to the max possible velocity based on
38 * Expo_kV.
39 *
40 * - Minimum Value: 0
41 * - Maximum Value: 9999
42 * - Default Value: 0
43 * - Units: rot per sec
44 */
45 units::angular_velocity::turns_per_second_t MotionMagicCruiseVelocity = 0_tps;
46 /**
47 * \brief This is the target acceleration Motion Magic® based control
48 * modes are allowed to use. Motion Magic® Expo control modes do not
49 * use this config.
50 *
51 * - Minimum Value: 0
52 * - Maximum Value: 9999
53 * - Default Value: 0
54 * - Units: rot per sec²
55 */
56 units::angular_acceleration::turns_per_second_squared_t MotionMagicAcceleration = 0_tr_per_s_sq;
57 /**
58 * \brief This is the target jerk (acceleration derivative) Motion
59 * Magic® based control modes are allowed to use. Motion Magic® Expo
60 * control modes do not use this config. This allows Motion Magic® to
61 * generate S-Curve profiles.
62 *
63 * Jerk is optional; if this is set to zero, then Motion Magic® will
64 * not apply a Jerk limit.
65 *
66 * - Minimum Value: 0
67 * - Maximum Value: 9999
68 * - Default Value: 0
69 * - Units: rot per sec³
70 */
71 units::angular_jerk::turns_per_second_cubed_t MotionMagicJerk = 0_tr_per_s_cu;
72 /**
73 * \brief This is the target kV used only by Motion Magic® Expo
74 * control modes. Unlike the kV slot gain, this is always in units of
75 * V/rps.
76 *
77 * This represents the amount of voltage necessary to hold a velocity.
78 * In terms of the Motion Magic® Expo profile, a higher kV results in
79 * a slower maximum velocity.
80 *
81 * - Minimum Value: 0.001
82 * - Maximum Value: 100
83 * - Default Value: 0.12
84 * - Units: V/rps
85 */
86 ctre::unit::volts_per_turn_per_second_t MotionMagicExpo_kV = 0.12_V / 1_tps;
87 /**
88 * \brief This is the target kA used only by Motion Magic® Expo
89 * control modes. Unlike the kA slot gain, this is always in units of
90 * V/rps².
91 *
92 * This represents the amount of voltage necessary to achieve an
93 * acceleration. In terms of the Motion Magic® Expo profile, a higher
94 * kA results in a slower acceleration.
95 *
96 * - Minimum Value: 1e-05
97 * - Maximum Value: 100
98 * - Default Value: 0.1
99 * - Units: V/rps²
100 */
101 ctre::unit::volts_per_turn_per_second_squared_t MotionMagicExpo_kA = 0.1_V / 1_tr_per_s_sq;
102
103 /**
104 * \brief Modifies this configuration's MotionMagicCruiseVelocity parameter and returns itself for
105 * method-chaining and easier to use config API.
106 *
107 * This is the maximum velocity Motion Magic® based control modes are
108 * allowed to use. Motion Magic® Velocity control modes do not use
109 * this config.
110 *
111 * When using Motion Magic® Expo control modes, setting this to 0 will
112 * allow the profile to run to the max possible velocity based on
113 * Expo_kV.
114 *
115 * - Minimum Value: 0
116 * - Maximum Value: 9999
117 * - Default Value: 0
118 * - Units: rot per sec
119 *
120 * \param newMotionMagicCruiseVelocity Parameter to modify
121 * \returns Itself
122 */
123 constexpr MotionMagicConfigs &WithMotionMagicCruiseVelocity(units::angular_velocity::turns_per_second_t newMotionMagicCruiseVelocity)
124 {
125 MotionMagicCruiseVelocity = std::move(newMotionMagicCruiseVelocity);
126 return *this;
127 }
128
129 /**
130 * \brief Modifies this configuration's MotionMagicAcceleration parameter and returns itself for
131 * method-chaining and easier to use config API.
132 *
133 * This is the target acceleration Motion Magic® based control modes
134 * are allowed to use. Motion Magic® Expo control modes do not use
135 * this config.
136 *
137 * - Minimum Value: 0
138 * - Maximum Value: 9999
139 * - Default Value: 0
140 * - Units: rot per sec²
141 *
142 * \param newMotionMagicAcceleration Parameter to modify
143 * \returns Itself
144 */
145 constexpr MotionMagicConfigs &WithMotionMagicAcceleration(units::angular_acceleration::turns_per_second_squared_t newMotionMagicAcceleration)
146 {
147 MotionMagicAcceleration = std::move(newMotionMagicAcceleration);
148 return *this;
149 }
150
151 /**
152 * \brief Modifies this configuration's MotionMagicJerk parameter and returns itself for
153 * method-chaining and easier to use config API.
154 *
155 * This is the target jerk (acceleration derivative) Motion Magic®
156 * based control modes are allowed to use. Motion Magic® Expo control
157 * modes do not use this config. This allows Motion Magic® to
158 * generate S-Curve profiles.
159 *
160 * Jerk is optional; if this is set to zero, then Motion Magic® will
161 * not apply a Jerk limit.
162 *
163 * - Minimum Value: 0
164 * - Maximum Value: 9999
165 * - Default Value: 0
166 * - Units: rot per sec³
167 *
168 * \param newMotionMagicJerk Parameter to modify
169 * \returns Itself
170 */
171 constexpr MotionMagicConfigs &WithMotionMagicJerk(units::angular_jerk::turns_per_second_cubed_t newMotionMagicJerk)
172 {
173 MotionMagicJerk = std::move(newMotionMagicJerk);
174 return *this;
175 }
176
177 /**
178 * \brief Modifies this configuration's MotionMagicExpo_kV parameter and returns itself for
179 * method-chaining and easier to use config API.
180 *
181 * This is the target kV used only by Motion Magic® Expo control
182 * modes. Unlike the kV slot gain, this is always in units of V/rps.
183 *
184 * This represents the amount of voltage necessary to hold a velocity.
185 * In terms of the Motion Magic® Expo profile, a higher kV results in
186 * a slower maximum velocity.
187 *
188 * - Minimum Value: 0.001
189 * - Maximum Value: 100
190 * - Default Value: 0.12
191 * - Units: V/rps
192 *
193 * \param newMotionMagicExpo_kV Parameter to modify
194 * \returns Itself
195 */
196 constexpr MotionMagicConfigs &WithMotionMagicExpo_kV(ctre::unit::volts_per_turn_per_second_t newMotionMagicExpo_kV)
197 {
198 MotionMagicExpo_kV = std::move(newMotionMagicExpo_kV);
199 return *this;
200 }
201
202 /**
203 * \brief Modifies this configuration's MotionMagicExpo_kA parameter and returns itself for
204 * method-chaining and easier to use config API.
205 *
206 * This is the target kA used only by Motion Magic® Expo control
207 * modes. Unlike the kA slot gain, this is always in units of V/rps².
208 *
209 * This represents the amount of voltage necessary to achieve an
210 * acceleration. In terms of the Motion Magic® Expo profile, a higher
211 * kA results in a slower acceleration.
212 *
213 * - Minimum Value: 1e-05
214 * - Maximum Value: 100
215 * - Default Value: 0.1
216 * - Units: V/rps²
217 *
218 * \param newMotionMagicExpo_kA Parameter to modify
219 * \returns Itself
220 */
221 constexpr MotionMagicConfigs &WithMotionMagicExpo_kA(ctre::unit::volts_per_turn_per_second_squared_t newMotionMagicExpo_kA)
222 {
223 MotionMagicExpo_kA = std::move(newMotionMagicExpo_kA);
224 return *this;
225 }
226
227
228
229 std::string ToString() const override;
230
231 std::string Serialize() const final;
232 ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final;
233};
234
235}
236}
237}
Configs for Motion Magic®.
Definition MotionMagicConfigs.hpp:27
ctre::unit::volts_per_turn_per_second_squared_t MotionMagicExpo_kA
This is the target kA used only by Motion Magic® Expo control modes.
Definition MotionMagicConfigs.hpp:101
constexpr MotionMagicConfigs & WithMotionMagicAcceleration(units::angular_acceleration::turns_per_second_squared_t newMotionMagicAcceleration)
Modifies this configuration's MotionMagicAcceleration parameter and returns itself for method-chainin...
Definition MotionMagicConfigs.hpp:145
ctre::unit::volts_per_turn_per_second_t MotionMagicExpo_kV
This is the target kV used only by Motion Magic® Expo control modes.
Definition MotionMagicConfigs.hpp:86
constexpr MotionMagicConfigs & WithMotionMagicCruiseVelocity(units::angular_velocity::turns_per_second_t newMotionMagicCruiseVelocity)
Modifies this configuration's MotionMagicCruiseVelocity parameter and returns itself for method-chain...
Definition MotionMagicConfigs.hpp:123
units::angular_acceleration::turns_per_second_squared_t MotionMagicAcceleration
This is the target acceleration Motion Magic® based control modes are allowed to use.
Definition MotionMagicConfigs.hpp:56
constexpr MotionMagicConfigs & WithMotionMagicJerk(units::angular_jerk::turns_per_second_cubed_t newMotionMagicJerk)
Modifies this configuration's MotionMagicJerk parameter and returns itself for method-chaining and ea...
Definition MotionMagicConfigs.hpp:171
units::angular_velocity::turns_per_second_t MotionMagicCruiseVelocity
This is the maximum velocity Motion Magic® based control modes are allowed to use.
Definition MotionMagicConfigs.hpp:45
units::angular_jerk::turns_per_second_cubed_t MotionMagicJerk
This is the target jerk (acceleration derivative) Motion Magic® based control modes are allowed to us...
Definition MotionMagicConfigs.hpp:71
std::string ToString() const override
constexpr MotionMagicConfigs & WithMotionMagicExpo_kA(ctre::unit::volts_per_turn_per_second_squared_t newMotionMagicExpo_kA)
Modifies this configuration's MotionMagicExpo_kA parameter and returns itself for method-chaining and...
Definition MotionMagicConfigs.hpp:221
ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final
constexpr MotionMagicConfigs & WithMotionMagicExpo_kV(ctre::unit::volts_per_turn_per_second_t newMotionMagicExpo_kV)
Modifies this configuration's MotionMagicExpo_kV parameter and returns itself for method-chaining and...
Definition MotionMagicConfigs.hpp:196
Definition Configuration.hpp:17
Definition motor_constants.h:14