CTRE Phoenix 6 C++ 26.1.1
Loading...
Searching...
No Matches
OpenLoopRampsConfigs.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 open-loop control of this motor
20 * controller.
21 *
22 * \details Open-loop ramp rates for the various control types.
23 */
25public:
26 constexpr OpenLoopRampsConfigs() = default;
27
28 /**
29 * \brief If non-zero, this determines how much time to ramp from 0%
30 * output to 100% during the open-loop DutyCycleOut control mode.
31 *
32 * This provides an easy way to limit the acceleration of the motor.
33 * However, the acceleration and current draw of the motor can be
34 * better restricted using current limits instead of a ramp rate.
35 *
36 * - Minimum Value: 0
37 * - Maximum Value: 1
38 * - Default Value: 0
39 * - Units: seconds
40 */
41 units::time::second_t DutyCycleOpenLoopRampPeriod = 0_s;
42 /**
43 * \brief If non-zero, this determines how much time to ramp from 0V
44 * output to 12V during the open-loop VoltageOut control mode.
45 *
46 * This provides an easy way to limit the acceleration of the motor.
47 * However, the acceleration and current draw of the motor can be
48 * better restricted using current limits instead of a ramp rate.
49 *
50 * - Minimum Value: 0
51 * - Maximum Value: 1
52 * - Default Value: 0
53 * - Units: seconds
54 */
55 units::time::second_t VoltageOpenLoopRampPeriod = 0_s;
56 /**
57 * \brief If non-zero, this determines how much time to ramp from 0A
58 * output to 300A during the open-loop TorqueCurrent control mode.
59 *
60 * Since TorqueCurrent is directly proportional to acceleration, this
61 * ramp limits jerk instead of acceleration.
62 *
63 * - Minimum Value: 0
64 * - Maximum Value: 10
65 * - Default Value: 0
66 * - Units: seconds
67 */
68 units::time::second_t TorqueOpenLoopRampPeriod = 0_s;
69
70 /**
71 * \brief Modifies this configuration's DutyCycleOpenLoopRampPeriod parameter and returns itself for
72 * method-chaining and easier to use config API.
73 *
74 * If non-zero, this determines how much time to ramp from 0% output
75 * to 100% during the open-loop DutyCycleOut control mode.
76 *
77 * This provides an easy way to limit the acceleration of the motor.
78 * However, the acceleration and current draw of the motor can be
79 * better restricted using current limits instead of a ramp rate.
80 *
81 * - Minimum Value: 0
82 * - Maximum Value: 1
83 * - Default Value: 0
84 * - Units: seconds
85 *
86 * \param newDutyCycleOpenLoopRampPeriod Parameter to modify
87 * \returns Itself
88 */
89 constexpr OpenLoopRampsConfigs &WithDutyCycleOpenLoopRampPeriod(units::time::second_t newDutyCycleOpenLoopRampPeriod)
90 {
91 DutyCycleOpenLoopRampPeriod = std::move(newDutyCycleOpenLoopRampPeriod);
92 return *this;
93 }
94
95 /**
96 * \brief Modifies this configuration's VoltageOpenLoopRampPeriod parameter and returns itself for
97 * method-chaining and easier to use config API.
98 *
99 * If non-zero, this determines how much time to ramp from 0V output
100 * to 12V during the open-loop VoltageOut control mode.
101 *
102 * This provides an easy way to limit the acceleration of the motor.
103 * However, the acceleration and current draw of the motor can be
104 * better restricted using current limits instead of a ramp rate.
105 *
106 * - Minimum Value: 0
107 * - Maximum Value: 1
108 * - Default Value: 0
109 * - Units: seconds
110 *
111 * \param newVoltageOpenLoopRampPeriod Parameter to modify
112 * \returns Itself
113 */
114 constexpr OpenLoopRampsConfigs &WithVoltageOpenLoopRampPeriod(units::time::second_t newVoltageOpenLoopRampPeriod)
115 {
116 VoltageOpenLoopRampPeriod = std::move(newVoltageOpenLoopRampPeriod);
117 return *this;
118 }
119
120 /**
121 * \brief Modifies this configuration's TorqueOpenLoopRampPeriod parameter and returns itself for
122 * method-chaining and easier to use config API.
123 *
124 * If non-zero, this determines how much time to ramp from 0A output
125 * to 300A during the open-loop TorqueCurrent control mode.
126 *
127 * Since TorqueCurrent is directly proportional to acceleration, this
128 * ramp limits jerk instead of acceleration.
129 *
130 * - Minimum Value: 0
131 * - Maximum Value: 10
132 * - Default Value: 0
133 * - Units: seconds
134 *
135 * \param newTorqueOpenLoopRampPeriod Parameter to modify
136 * \returns Itself
137 */
138 constexpr OpenLoopRampsConfigs &WithTorqueOpenLoopRampPeriod(units::time::second_t newTorqueOpenLoopRampPeriod)
139 {
140 TorqueOpenLoopRampPeriod = std::move(newTorqueOpenLoopRampPeriod);
141 return *this;
142 }
143
144
145
146 std::string ToString() const override;
147
148 std::string Serialize() const final;
149 ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final;
150};
151
152}
153}
154}
Configs that affect the open-loop control of this motor controller.
Definition OpenLoopRampsConfigs.hpp:24
constexpr OpenLoopRampsConfigs & WithVoltageOpenLoopRampPeriod(units::time::second_t newVoltageOpenLoopRampPeriod)
Modifies this configuration's VoltageOpenLoopRampPeriod parameter and returns itself for method-chain...
Definition OpenLoopRampsConfigs.hpp:114
constexpr OpenLoopRampsConfigs & WithDutyCycleOpenLoopRampPeriod(units::time::second_t newDutyCycleOpenLoopRampPeriod)
Modifies this configuration's DutyCycleOpenLoopRampPeriod parameter and returns itself for method-cha...
Definition OpenLoopRampsConfigs.hpp:89
units::time::second_t VoltageOpenLoopRampPeriod
If non-zero, this determines how much time to ramp from 0V output to 12V during the open-loop Voltage...
Definition OpenLoopRampsConfigs.hpp:55
units::time::second_t TorqueOpenLoopRampPeriod
If non-zero, this determines how much time to ramp from 0A output to 300A during the open-loop Torque...
Definition OpenLoopRampsConfigs.hpp:68
std::string ToString() const override
constexpr OpenLoopRampsConfigs & WithTorqueOpenLoopRampPeriod(units::time::second_t newTorqueOpenLoopRampPeriod)
Modifies this configuration's TorqueOpenLoopRampPeriod parameter and returns itself for method-chaini...
Definition OpenLoopRampsConfigs.hpp:138
units::time::second_t DutyCycleOpenLoopRampPeriod
If non-zero, this determines how much time to ramp from 0% output to 100% during the open-loop DutyCy...
Definition OpenLoopRampsConfigs.hpp:41
ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final
Definition Configuration.hpp:17
Definition motor_constants.h:14