CTRE Phoenix 6 C++ 26.1.1
Loading...
Searching...
No Matches
VoltageConfigs.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#include <units/voltage.h>
12
13namespace ctre {
14namespace phoenix6 {
15
16
17namespace configs {
18
19/**
20 * \brief Configs that affect Voltage control types.
21 *
22 * \details Includes peak output voltages and other configs affecting
23 * voltage measurements.
24 */
26public:
27 constexpr VoltageConfigs() = default;
28
29 /**
30 * \brief The time constant (in seconds) of the low-pass filter for
31 * the supply voltage.
32 *
33 * \details This impacts the filtering for the reported supply
34 * voltage, and any control strategies that use the supply voltage
35 * (such as voltage control on a motor controller).
36 *
37 * - Minimum Value: 0.0
38 * - Maximum Value: 0.1
39 * - Default Value: 0
40 * - Units: seconds
41 */
42 units::time::second_t SupplyVoltageTimeConstant = 0_s;
43 /**
44 * \brief Maximum (forward) output during voltage based control modes.
45 *
46 * - Minimum Value: -32
47 * - Maximum Value: 32
48 * - Default Value: 16
49 * - Units: V
50 */
51 units::voltage::volt_t PeakForwardVoltage = 16_V;
52 /**
53 * \brief Minimum (reverse) output during voltage based control modes.
54 *
55 * - Minimum Value: -32
56 * - Maximum Value: 32
57 * - Default Value: -16
58 * - Units: V
59 */
60 units::voltage::volt_t PeakReverseVoltage = -16_V;
61
62 /**
63 * \brief Modifies this configuration's SupplyVoltageTimeConstant parameter and returns itself for
64 * method-chaining and easier to use config API.
65 *
66 * The time constant (in seconds) of the low-pass filter for the
67 * supply voltage.
68 *
69 * \details This impacts the filtering for the reported supply
70 * voltage, and any control strategies that use the supply voltage
71 * (such as voltage control on a motor controller).
72 *
73 * - Minimum Value: 0.0
74 * - Maximum Value: 0.1
75 * - Default Value: 0
76 * - Units: seconds
77 *
78 * \param newSupplyVoltageTimeConstant Parameter to modify
79 * \returns Itself
80 */
81 constexpr VoltageConfigs &WithSupplyVoltageTimeConstant(units::time::second_t newSupplyVoltageTimeConstant)
82 {
83 SupplyVoltageTimeConstant = std::move(newSupplyVoltageTimeConstant);
84 return *this;
85 }
86
87 /**
88 * \brief Modifies this configuration's PeakForwardVoltage parameter and returns itself for
89 * method-chaining and easier to use config API.
90 *
91 * Maximum (forward) output during voltage based control modes.
92 *
93 * - Minimum Value: -32
94 * - Maximum Value: 32
95 * - Default Value: 16
96 * - Units: V
97 *
98 * \param newPeakForwardVoltage Parameter to modify
99 * \returns Itself
100 */
101 constexpr VoltageConfigs &WithPeakForwardVoltage(units::voltage::volt_t newPeakForwardVoltage)
102 {
103 PeakForwardVoltage = std::move(newPeakForwardVoltage);
104 return *this;
105 }
106
107 /**
108 * \brief Modifies this configuration's PeakReverseVoltage parameter and returns itself for
109 * method-chaining and easier to use config API.
110 *
111 * Minimum (reverse) output during voltage based control modes.
112 *
113 * - Minimum Value: -32
114 * - Maximum Value: 32
115 * - Default Value: -16
116 * - Units: V
117 *
118 * \param newPeakReverseVoltage Parameter to modify
119 * \returns Itself
120 */
121 constexpr VoltageConfigs &WithPeakReverseVoltage(units::voltage::volt_t newPeakReverseVoltage)
122 {
123 PeakReverseVoltage = std::move(newPeakReverseVoltage);
124 return *this;
125 }
126
127
128
129 std::string ToString() const override;
130
131 std::string Serialize() const final;
132 ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final;
133};
134
135}
136}
137}
Definition Configuration.hpp:17
Configs that affect Voltage control types.
Definition VoltageConfigs.hpp:25
units::voltage::volt_t PeakForwardVoltage
Maximum (forward) output during voltage based control modes.
Definition VoltageConfigs.hpp:51
constexpr VoltageConfigs & WithPeakReverseVoltage(units::voltage::volt_t newPeakReverseVoltage)
Modifies this configuration's PeakReverseVoltage parameter and returns itself for method-chaining and...
Definition VoltageConfigs.hpp:121
std::string Serialize() const final
std::string ToString() const override
units::time::second_t SupplyVoltageTimeConstant
The time constant (in seconds) of the low-pass filter for the supply voltage.
Definition VoltageConfigs.hpp:42
ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final
constexpr VoltageConfigs & WithPeakForwardVoltage(units::voltage::volt_t newPeakForwardVoltage)
Modifies this configuration's PeakForwardVoltage parameter and returns itself for method-chaining and...
Definition VoltageConfigs.hpp:101
constexpr VoltageConfigs & WithSupplyVoltageTimeConstant(units::time::second_t newSupplyVoltageTimeConstant)
Modifies this configuration's SupplyVoltageTimeConstant parameter and returns itself for method-chain...
Definition VoltageConfigs.hpp:81
units::voltage::volt_t PeakReverseVoltage
Minimum (reverse) output during voltage based control modes.
Definition VoltageConfigs.hpp:60
Definition motor_constants.h:14