CTRE Phoenix 6 C++ 26.0.0-beta-1
Loading...
Searching...
No Matches
ClosedLoopRampsConfigs.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 <units/time.h>
11
12namespace ctre {
13namespace phoenix6 {
14
15
16namespace configs {
17
18/**
19 * \brief Configs that affect the closed-loop control of this motor
20 * controller.
21 *
22 * \details Closed-loop ramp rates for the various control types.
23 */
25public:
26 constexpr ClosedLoopRampsConfigs() = default;
27
28 /**
29 * \brief If non-zero, this determines how much time to ramp from 0%
30 * output to 100% during the closed-loop DutyCycle control modes.
31 *
32 * If the goal is to limit acceleration, it is more useful to ramp the
33 * closed-loop setpoint instead of the output. This can be achieved
34 * using Motion Magic® controls.
35 *
36 * The acceleration and current draw of the motor can also be better
37 * restricted using current limits instead of a ramp rate.
38 *
39 * - Minimum Value: 0
40 * - Maximum Value: 1
41 * - Default Value: 0
42 * - Units: seconds
43 */
44 units::time::second_t DutyCycleClosedLoopRampPeriod = 0_s;
45 /**
46 * \brief If non-zero, this determines how much time to ramp from 0V
47 * output to 12V during the closed-loop Voltage control modes.
48 *
49 * If the goal is to limit acceleration, it is more useful to ramp the
50 * closed-loop setpoint instead of the output. This can be achieved
51 * using Motion Magic® controls.
52 *
53 * The acceleration and current draw of the motor can also be better
54 * restricted using current limits instead of a ramp rate.
55 *
56 * - Minimum Value: 0
57 * - Maximum Value: 1
58 * - Default Value: 0
59 * - Units: seconds
60 */
61 units::time::second_t VoltageClosedLoopRampPeriod = 0_s;
62 /**
63 * \brief If non-zero, this determines how much time to ramp from 0A
64 * output to 300A during the closed-loop TorqueCurrent control modes.
65 *
66 * Since TorqueCurrent is directly proportional to acceleration, this
67 * ramp limits jerk instead of acceleration.
68 *
69 * If the goal is to limit acceleration or jerk, it is more useful to
70 * ramp the closed-loop setpoint instead of the output. This can be
71 * achieved using Motion Magic® controls.
72 *
73 * The acceleration and current draw of the motor can also be better
74 * restricted using current limits instead of a ramp rate.
75 *
76 * - Minimum Value: 0
77 * - Maximum Value: 10
78 * - Default Value: 0
79 * - Units: seconds
80 */
81 units::time::second_t TorqueClosedLoopRampPeriod = 0_s;
82
83 /**
84 * \brief Modifies this configuration's DutyCycleClosedLoopRampPeriod parameter and returns itself for
85 * method-chaining and easier to use config API.
86 *
87 * If non-zero, this determines how much time to ramp from 0% output
88 * to 100% during the closed-loop DutyCycle control modes.
89 *
90 * If the goal is to limit acceleration, it is more useful to ramp the
91 * closed-loop setpoint instead of the output. This can be achieved
92 * using Motion Magic® controls.
93 *
94 * The acceleration and current draw of the motor can also be better
95 * restricted using current limits instead of a ramp rate.
96 *
97 * - Minimum Value: 0
98 * - Maximum Value: 1
99 * - Default Value: 0
100 * - Units: seconds
101 *
102 * \param newDutyCycleClosedLoopRampPeriod Parameter to modify
103 * \returns Itself
104 */
105 constexpr ClosedLoopRampsConfigs &WithDutyCycleClosedLoopRampPeriod(units::time::second_t newDutyCycleClosedLoopRampPeriod)
106 {
107 DutyCycleClosedLoopRampPeriod = std::move(newDutyCycleClosedLoopRampPeriod);
108 return *this;
109 }
110
111 /**
112 * \brief Modifies this configuration's VoltageClosedLoopRampPeriod parameter and returns itself for
113 * method-chaining and easier to use config API.
114 *
115 * If non-zero, this determines how much time to ramp from 0V output
116 * to 12V during the closed-loop Voltage control modes.
117 *
118 * If the goal is to limit acceleration, it is more useful to ramp the
119 * closed-loop setpoint instead of the output. This can be achieved
120 * using Motion Magic® controls.
121 *
122 * The acceleration and current draw of the motor can also be better
123 * restricted using current limits instead of a ramp rate.
124 *
125 * - Minimum Value: 0
126 * - Maximum Value: 1
127 * - Default Value: 0
128 * - Units: seconds
129 *
130 * \param newVoltageClosedLoopRampPeriod Parameter to modify
131 * \returns Itself
132 */
133 constexpr ClosedLoopRampsConfigs &WithVoltageClosedLoopRampPeriod(units::time::second_t newVoltageClosedLoopRampPeriod)
134 {
135 VoltageClosedLoopRampPeriod = std::move(newVoltageClosedLoopRampPeriod);
136 return *this;
137 }
138
139 /**
140 * \brief Modifies this configuration's TorqueClosedLoopRampPeriod parameter and returns itself for
141 * method-chaining and easier to use config API.
142 *
143 * If non-zero, this determines how much time to ramp from 0A output
144 * to 300A during the closed-loop TorqueCurrent control modes.
145 *
146 * Since TorqueCurrent is directly proportional to acceleration, this
147 * ramp limits jerk instead of acceleration.
148 *
149 * If the goal is to limit acceleration or jerk, it is more useful to
150 * ramp the closed-loop setpoint instead of the output. This can be
151 * achieved using Motion Magic® controls.
152 *
153 * The acceleration and current draw of the motor can also be better
154 * restricted using current limits instead of a ramp rate.
155 *
156 * - Minimum Value: 0
157 * - Maximum Value: 10
158 * - Default Value: 0
159 * - Units: seconds
160 *
161 * \param newTorqueClosedLoopRampPeriod Parameter to modify
162 * \returns Itself
163 */
164 constexpr ClosedLoopRampsConfigs &WithTorqueClosedLoopRampPeriod(units::time::second_t newTorqueClosedLoopRampPeriod)
165 {
166 TorqueClosedLoopRampPeriod = std::move(newTorqueClosedLoopRampPeriod);
167 return *this;
168 }
169
170
171
172 std::string ToString() const override;
173
174 std::string Serialize() const final;
175 ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final;
176};
177
178}
179}
180}
Configs that affect the closed-loop control of this motor controller.
Definition ClosedLoopRampsConfigs.hpp:24
constexpr ClosedLoopRampsConfigs & WithDutyCycleClosedLoopRampPeriod(units::time::second_t newDutyCycleClosedLoopRampPeriod)
Modifies this configuration's DutyCycleClosedLoopRampPeriod parameter and returns itself for method-c...
Definition ClosedLoopRampsConfigs.hpp:105
units::time::second_t DutyCycleClosedLoopRampPeriod
If non-zero, this determines how much time to ramp from 0% output to 100% during the closed-loop Duty...
Definition ClosedLoopRampsConfigs.hpp:44
constexpr ClosedLoopRampsConfigs & WithTorqueClosedLoopRampPeriod(units::time::second_t newTorqueClosedLoopRampPeriod)
Modifies this configuration's TorqueClosedLoopRampPeriod parameter and returns itself for method-chai...
Definition ClosedLoopRampsConfigs.hpp:164
ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final
constexpr ClosedLoopRampsConfigs & WithVoltageClosedLoopRampPeriod(units::time::second_t newVoltageClosedLoopRampPeriod)
Modifies this configuration's VoltageClosedLoopRampPeriod parameter and returns itself for method-cha...
Definition ClosedLoopRampsConfigs.hpp:133
units::time::second_t TorqueClosedLoopRampPeriod
If non-zero, this determines how much time to ramp from 0A output to 300A during the closed-loop Torq...
Definition ClosedLoopRampsConfigs.hpp:81
units::time::second_t VoltageClosedLoopRampPeriod
If non-zero, this determines how much time to ramp from 0V output to 12V during the closed-loop Volta...
Definition ClosedLoopRampsConfigs.hpp:61
Definition Configuration.hpp:17
Definition motor_constants.h:14