CTRE Phoenix 6 C++ 26.1.1
Loading...
Searching...
No Matches
MotorOutputConfigs.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 <units/dimensionless.h>
12#include <units/frequency.h>
13
14namespace ctre {
15namespace phoenix6 {
16
17
18namespace configs {
19
20/**
21 * \brief Configs that directly affect motor output.
22 *
23 * \details Includes motor invert, neutral mode, and other features
24 * related to motor output.
25 */
27public:
28 constexpr MotorOutputConfigs() = default;
29
30 /**
31 * \brief Invert state of the device as seen from the front of the
32 * motor.
33 *
34 */
36 /**
37 * \brief The state of the motor controller bridge when output is
38 * neutral or disabled.
39 *
40 */
42 /**
43 * \brief Configures the output deadband duty cycle during duty cycle
44 * and voltage based control modes.
45 *
46 * - Minimum Value: 0.0
47 * - Maximum Value: 0.25
48 * - Default Value: 0
49 * - Units: fractional
50 */
51 units::dimensionless::scalar_t DutyCycleNeutralDeadband = 0;
52 /**
53 * \brief Maximum (forward) output during duty cycle based control
54 * modes.
55 *
56 * - Minimum Value: -1.0
57 * - Maximum Value: 1.0
58 * - Default Value: 1
59 * - Units: fractional
60 */
61 units::dimensionless::scalar_t PeakForwardDutyCycle = 1;
62 /**
63 * \brief Minimum (reverse) output during duty cycle based control
64 * modes.
65 *
66 * - Minimum Value: -1.0
67 * - Maximum Value: 1.0
68 * - Default Value: -1
69 * - Units: fractional
70 */
71 units::dimensionless::scalar_t PeakReverseDutyCycle = -1;
72 /**
73 * \brief When a control request UseTimesync is enabled, this
74 * determines the time-sychronized frequency at which control requests
75 * are applied.
76 *
77 * \details The application of the control request will be delayed
78 * until the next timesync boundary at the frequency defined by this
79 * config. When set to 0 Hz, timesync will never be used for control
80 * requests, regardless of the value of UseTimesync.
81 *
82 * - Minimum Value: 50
83 * - Maximum Value: 500
84 * - Default Value: 0
85 * - Units: Hz
86 */
87 units::frequency::hertz_t ControlTimesyncFreqHz = 0_Hz;
88
89 /**
90 * \brief Modifies this configuration's Inverted parameter and returns itself for
91 * method-chaining and easier to use config API.
92 *
93 * Invert state of the device as seen from the front of the motor.
94 *
95 *
96 * \param newInverted Parameter to modify
97 * \returns Itself
98 */
100 {
101 Inverted = std::move(newInverted);
102 return *this;
103 }
104
105 /**
106 * \brief Modifies this configuration's NeutralMode parameter and returns itself for
107 * method-chaining and easier to use config API.
108 *
109 * The state of the motor controller bridge when output is neutral or
110 * disabled.
111 *
112 *
113 * \param newNeutralMode Parameter to modify
114 * \returns Itself
115 */
117 {
118 NeutralMode = std::move(newNeutralMode);
119 return *this;
120 }
121
122 /**
123 * \brief Modifies this configuration's DutyCycleNeutralDeadband parameter and returns itself for
124 * method-chaining and easier to use config API.
125 *
126 * Configures the output deadband duty cycle during duty cycle and
127 * voltage based control modes.
128 *
129 * - Minimum Value: 0.0
130 * - Maximum Value: 0.25
131 * - Default Value: 0
132 * - Units: fractional
133 *
134 * \param newDutyCycleNeutralDeadband Parameter to modify
135 * \returns Itself
136 */
137 constexpr MotorOutputConfigs &WithDutyCycleNeutralDeadband(units::dimensionless::scalar_t newDutyCycleNeutralDeadband)
138 {
139 DutyCycleNeutralDeadband = std::move(newDutyCycleNeutralDeadband);
140 return *this;
141 }
142
143 /**
144 * \brief Modifies this configuration's PeakForwardDutyCycle parameter and returns itself for
145 * method-chaining and easier to use config API.
146 *
147 * Maximum (forward) output during duty cycle based control modes.
148 *
149 * - Minimum Value: -1.0
150 * - Maximum Value: 1.0
151 * - Default Value: 1
152 * - Units: fractional
153 *
154 * \param newPeakForwardDutyCycle Parameter to modify
155 * \returns Itself
156 */
157 constexpr MotorOutputConfigs &WithPeakForwardDutyCycle(units::dimensionless::scalar_t newPeakForwardDutyCycle)
158 {
159 PeakForwardDutyCycle = std::move(newPeakForwardDutyCycle);
160 return *this;
161 }
162
163 /**
164 * \brief Modifies this configuration's PeakReverseDutyCycle parameter and returns itself for
165 * method-chaining and easier to use config API.
166 *
167 * Minimum (reverse) output during duty cycle based control modes.
168 *
169 * - Minimum Value: -1.0
170 * - Maximum Value: 1.0
171 * - Default Value: -1
172 * - Units: fractional
173 *
174 * \param newPeakReverseDutyCycle Parameter to modify
175 * \returns Itself
176 */
177 constexpr MotorOutputConfigs &WithPeakReverseDutyCycle(units::dimensionless::scalar_t newPeakReverseDutyCycle)
178 {
179 PeakReverseDutyCycle = std::move(newPeakReverseDutyCycle);
180 return *this;
181 }
182
183 /**
184 * \brief Modifies this configuration's ControlTimesyncFreqHz parameter and returns itself for
185 * method-chaining and easier to use config API.
186 *
187 * When a control request UseTimesync is enabled, this determines the
188 * time-sychronized frequency at which control requests are applied.
189 *
190 * \details The application of the control request will be delayed
191 * until the next timesync boundary at the frequency defined by this
192 * config. When set to 0 Hz, timesync will never be used for control
193 * requests, regardless of the value of UseTimesync.
194 *
195 * - Minimum Value: 50
196 * - Maximum Value: 500
197 * - Default Value: 0
198 * - Units: Hz
199 *
200 * \param newControlTimesyncFreqHz Parameter to modify
201 * \returns Itself
202 */
203 constexpr MotorOutputConfigs &WithControlTimesyncFreqHz(units::frequency::hertz_t newControlTimesyncFreqHz)
204 {
205 ControlTimesyncFreqHz = std::move(newControlTimesyncFreqHz);
206 return *this;
207 }
208
209
210
211 std::string ToString() const override;
212
213 std::string Serialize() const final;
214 ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final;
215};
216
217}
218}
219}
Configs that directly affect motor output.
Definition MotorOutputConfigs.hpp:26
units::dimensionless::scalar_t PeakReverseDutyCycle
Minimum (reverse) output during duty cycle based control modes.
Definition MotorOutputConfigs.hpp:71
signals::NeutralModeValue NeutralMode
The state of the motor controller bridge when output is neutral or disabled.
Definition MotorOutputConfigs.hpp:41
constexpr MotorOutputConfigs & WithNeutralMode(signals::NeutralModeValue newNeutralMode)
Modifies this configuration's NeutralMode parameter and returns itself for method-chaining and easier...
Definition MotorOutputConfigs.hpp:116
constexpr MotorOutputConfigs & WithControlTimesyncFreqHz(units::frequency::hertz_t newControlTimesyncFreqHz)
Modifies this configuration's ControlTimesyncFreqHz parameter and returns itself for method-chaining ...
Definition MotorOutputConfigs.hpp:203
units::dimensionless::scalar_t PeakForwardDutyCycle
Maximum (forward) output during duty cycle based control modes.
Definition MotorOutputConfigs.hpp:61
ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final
constexpr MotorOutputConfigs & WithPeakForwardDutyCycle(units::dimensionless::scalar_t newPeakForwardDutyCycle)
Modifies this configuration's PeakForwardDutyCycle parameter and returns itself for method-chaining a...
Definition MotorOutputConfigs.hpp:157
constexpr MotorOutputConfigs & WithDutyCycleNeutralDeadband(units::dimensionless::scalar_t newDutyCycleNeutralDeadband)
Modifies this configuration's DutyCycleNeutralDeadband parameter and returns itself for method-chaini...
Definition MotorOutputConfigs.hpp:137
std::string ToString() const override
signals::InvertedValue Inverted
Invert state of the device as seen from the front of the motor.
Definition MotorOutputConfigs.hpp:35
constexpr MotorOutputConfigs & WithInverted(signals::InvertedValue newInverted)
Modifies this configuration's Inverted parameter and returns itself for method-chaining and easier to...
Definition MotorOutputConfigs.hpp:99
constexpr MotorOutputConfigs & WithPeakReverseDutyCycle(units::dimensionless::scalar_t newPeakReverseDutyCycle)
Modifies this configuration's PeakReverseDutyCycle parameter and returns itself for method-chaining a...
Definition MotorOutputConfigs.hpp:177
units::dimensionless::scalar_t DutyCycleNeutralDeadband
Configures the output deadband duty cycle during duty cycle and voltage based control modes.
Definition MotorOutputConfigs.hpp:51
units::frequency::hertz_t ControlTimesyncFreqHz
When a control request UseTimesync is enabled, this determines the time-sychronized frequency at whic...
Definition MotorOutputConfigs.hpp:87
Definition Configuration.hpp:17
Definition motor_constants.h:14
Invert state of the device as seen from the front of the motor.
Definition SpnEnums.hpp:1548
static constexpr int CounterClockwise_Positive
Positive motor output results in counter-clockwise motion.
Definition SpnEnums.hpp:1554
The state of the motor controller bridge when output is neutral or disabled.
Definition SpnEnums.hpp:1603
static constexpr int Coast
Definition SpnEnums.hpp:1606