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