CTRE Phoenix 6 C++ 26.0.0-beta-1
Loading...
Searching...
No Matches
Diff_DutyCycleOut_Velocity.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
12
13namespace ctre {
14namespace phoenix6 {
15namespace controls {
16namespace compound {
17
18/**
19 * \private
20 * Requires Phoenix Pro and CANivore;
21 * Differential control with duty cycle average target and velocity difference
22 * target.
23 */
24class Diff_DutyCycleOut_Velocity final : public ControlRequest {
25 ctre::phoenix::StatusCode SendRequest(const char *network, uint32_t deviceHash, std::shared_ptr<ControlRequest> &req) const override;
26
27public:
28 /**
29 * \brief Average DutyCycleOut request of the mechanism.
30 */
31 DutyCycleOut AverageRequest;
32 /**
33 * \brief Differential VelocityDutyCycle request of the mechanism.
34 */
35 VelocityDutyCycle DifferentialRequest;
36
37 /**
38 * \brief The frequency at which this control will update.
39 * This is designated in Hertz, with a minimum of 20 Hz
40 * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
41 * Some update frequencies are not supported and will be
42 * promoted up to the next highest supported frequency.
43 *
44 * If this field is set to 0 Hz, the control request will
45 * be sent immediately as a one-shot frame. This may be useful
46 * for advanced applications that require outputs to be
47 * synchronized with data acquisition. In this case, we
48 * recommend not exceeding 50 ms between control calls.
49 */
50 units::frequency::hertz_t UpdateFreqHz{100_Hz};
51
52 /**
53 * \brief Requires Phoenix Pro and CANivore;
54 * Differential control with duty cycle average target and velocity
55 * difference target.
56 *
57 * \param AverageRequest Average DutyCycleOut request of the mechanism.
58 * \param DifferentialRequest Differential VelocityDutyCycle request of the
59 * mechanism.
60 */
61 constexpr Diff_DutyCycleOut_Velocity(DutyCycleOut AverageRequest, VelocityDutyCycle DifferentialRequest) : ControlRequest{},
62 AverageRequest{std::move(AverageRequest)},
63 DifferentialRequest{std::move(DifferentialRequest)}
64 {}
65
66 constexpr ~Diff_DutyCycleOut_Velocity() override {}
67
68 /**
69 * \brief Gets the name of this control request.
70 *
71 * \returns Name of the control request
72 */
73 constexpr std::string_view GetName() const override
74 {
75 return "Diff_DutyCycleOut_Velocity";
76 }
77
78 /**
79 * \brief Modifies this Control Request's AverageRequest parameter and returns itself for
80 * method-chaining and easier to use request API.
81 *
82 * Average DutyCycleOut request of the mechanism.
83 *
84 * \param newAverageRequest Parameter to modify
85 * \returns Itself
86 */
87 constexpr Diff_DutyCycleOut_Velocity &WithAverageRequest(DutyCycleOut newAverageRequest)
88 {
89 AverageRequest = std::move(newAverageRequest);
90 return *this;
91 }
92
93 /**
94 * \brief Modifies this Control Request's DifferentialRequest parameter and returns itself for
95 * method-chaining and easier to use request API.
96 *
97 * Differential VelocityDutyCycle request of the mechanism.
98 *
99 * \param newDifferentialRequest Parameter to modify
100 * \returns Itself
101 */
102 constexpr Diff_DutyCycleOut_Velocity &WithDifferentialRequest(VelocityDutyCycle newDifferentialRequest)
103 {
104 DifferentialRequest = std::move(newDifferentialRequest);
105 return *this;
106 }
107
108 /**
109 * \brief Sets the frequency at which this control will update.
110 * This is designated in Hertz, with a minimum of 20 Hz
111 * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
112 * Some update frequencies are not supported and will be
113 * promoted up to the next highest supported frequency.
114 *
115 * If this field is set to 0 Hz, the control request will
116 * be sent immediately as a one-shot frame. This may be useful
117 * for advanced applications that require outputs to be
118 * synchronized with data acquisition. In this case, we
119 * recommend not exceeding 50 ms between control calls.
120 *
121 * \param newUpdateFreqHz Parameter to modify
122 * \returns Itself
123 */
124 constexpr Diff_DutyCycleOut_Velocity &WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
125 {
126 UpdateFreqHz = newUpdateFreqHz;
127 return *this;
128 }
129
130 /**
131 * \brief Returns a string representation of the object.
132 *
133 * \returns a string representation of the object.
134 */
135 std::string ToString() const override;
136
137 /**
138 * \brief Gets information about this control request.
139 *
140 * \returns Map of control parameter names and corresponding applied values
141 */
142 std::map<std::string, std::string> GetControlInfo() const override;
143};
144
145}
146}
147}
148}
149
constexpr ControlRequest()=default
Constructs a new Control Request.
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:28
Definition motor_constants.h:14