CTRE Phoenix 6 C++ 26.0.0-beta-1
Loading...
Searching...
No Matches
Diff_MotionMagicVelocityDutyCycle_Open.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 Motion Magic® Velocity average target and duty
22 * cycle difference target.
23 */
24class Diff_MotionMagicVelocityDutyCycle_Open 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 MotionMagicVelocityDutyCycle request of the mechanism.
30 */
31 MotionMagicVelocityDutyCycle AverageRequest;
32 /**
33 * \brief Differential DutyCycleOut request of the mechanism.
34 */
35 DutyCycleOut 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 Motion Magic® Velocity average target and
55 * duty cycle difference target.
56 *
57 * \param AverageRequest Average MotionMagicVelocityDutyCycle request of the
58 * mechanism.
59 * \param DifferentialRequest Differential DutyCycleOut request of the
60 * mechanism.
61 */
62 constexpr Diff_MotionMagicVelocityDutyCycle_Open(MotionMagicVelocityDutyCycle AverageRequest, DutyCycleOut DifferentialRequest) : ControlRequest{},
63 AverageRequest{std::move(AverageRequest)},
64 DifferentialRequest{std::move(DifferentialRequest)}
65 {}
66
67 constexpr ~Diff_MotionMagicVelocityDutyCycle_Open() override {}
68
69 /**
70 * \brief Gets the name of this control request.
71 *
72 * \returns Name of the control request
73 */
74 constexpr std::string_view GetName() const override
75 {
76 return "Diff_MotionMagicVelocityDutyCycle_Open";
77 }
78
79 /**
80 * \brief Modifies this Control Request's AverageRequest parameter and returns itself for
81 * method-chaining and easier to use request API.
82 *
83 * Average MotionMagicVelocityDutyCycle request of the mechanism.
84 *
85 * \param newAverageRequest Parameter to modify
86 * \returns Itself
87 */
88 constexpr Diff_MotionMagicVelocityDutyCycle_Open &WithAverageRequest(MotionMagicVelocityDutyCycle newAverageRequest)
89 {
90 AverageRequest = std::move(newAverageRequest);
91 return *this;
92 }
93
94 /**
95 * \brief Modifies this Control Request's DifferentialRequest parameter and returns itself for
96 * method-chaining and easier to use request API.
97 *
98 * Differential DutyCycleOut request of the mechanism.
99 *
100 * \param newDifferentialRequest Parameter to modify
101 * \returns Itself
102 */
103 constexpr Diff_MotionMagicVelocityDutyCycle_Open &WithDifferentialRequest(DutyCycleOut newDifferentialRequest)
104 {
105 DifferentialRequest = std::move(newDifferentialRequest);
106 return *this;
107 }
108
109 /**
110 * \brief Sets the frequency at which this control will update.
111 * This is designated in Hertz, with a minimum of 20 Hz
112 * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
113 * Some update frequencies are not supported and will be
114 * promoted up to the next highest supported frequency.
115 *
116 * If this field is set to 0 Hz, the control request will
117 * be sent immediately as a one-shot frame. This may be useful
118 * for advanced applications that require outputs to be
119 * synchronized with data acquisition. In this case, we
120 * recommend not exceeding 50 ms between control calls.
121 *
122 * \param newUpdateFreqHz Parameter to modify
123 * \returns Itself
124 */
125 constexpr Diff_MotionMagicVelocityDutyCycle_Open &WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
126 {
127 UpdateFreqHz = newUpdateFreqHz;
128 return *this;
129 }
130
131 /**
132 * \brief Returns a string representation of the object.
133 *
134 * \returns a string representation of the object.
135 */
136 std::string ToString() const override;
137
138 /**
139 * \brief Gets information about this control request.
140 *
141 * \returns Map of control parameter names and corresponding applied values
142 */
143 std::map<std::string, std::string> GetControlInfo() const override;
144};
145
146}
147}
148}
149}
150
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