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