CTRE Phoenix 6 C++ 26.0.0-beta-1
Loading...
Searching...
No Matches
CoastOut.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/frequency.h>
11#include <units/time.h>
12
13namespace ctre {
14namespace phoenix6 {
15namespace controls {
16
17/**
18 * Request coast neutral output of actuator. The bridge is disabled and the
19 * rotor is allowed to coast.
20 */
21class CoastOut final : public ControlRequest {
22 ctre::phoenix::StatusCode SendRequest(const char *network, uint32_t deviceHash, std::shared_ptr<ControlRequest> &req) const override;
23
24public:
25 /**
26 * \brief Set to true to delay applying this control request until a timesync
27 * boundary (requires Phoenix Pro and CANivore). This eliminates the impact of
28 * nondeterministic network delays in exchange for a larger but deterministic
29 * control latency.
30 *
31 * This requires setting the ControlTimesyncFreqHz config in MotorOutputConfigs.
32 * Additionally, when this is enabled, the UpdateFreqHz of this request should
33 * be set to 0 Hz.
34 */
35 bool UseTimesync = false;
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{20_Hz};
51
52 /**
53 * \brief Request coast neutral output of actuator. The bridge is disabled and
54 * the rotor is allowed to coast.
55 *
56 */
57 constexpr CoastOut() : ControlRequest{}
58 {}
59
60 constexpr ~CoastOut() override {}
61
62 /**
63 * \brief Gets the name of this control request.
64 *
65 * \returns Name of the control request
66 */
67 constexpr std::string_view GetName() const override
68 {
69 return "CoastOut";
70 }
71
72 /**
73 * \brief Modifies this Control Request's UseTimesync parameter and returns itself for
74 * method-chaining and easier to use request API.
75 *
76 * Set to true to delay applying this control request until a timesync boundary
77 * (requires Phoenix Pro and CANivore). This eliminates the impact of
78 * nondeterministic network delays in exchange for a larger but deterministic
79 * control latency.
80 *
81 * This requires setting the ControlTimesyncFreqHz config in MotorOutputConfigs.
82 * Additionally, when this is enabled, the UpdateFreqHz of this request should
83 * be set to 0 Hz.
84 *
85 * \param newUseTimesync Parameter to modify
86 * \returns Itself
87 */
88 constexpr CoastOut &WithUseTimesync(bool newUseTimesync)
89 {
90 UseTimesync = std::move(newUseTimesync);
91 return *this;
92 }
93
94 /**
95 * \brief Sets the frequency at which this control will update.
96 * This is designated in Hertz, with a minimum of 20 Hz
97 * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
98 * Some update frequencies are not supported and will be
99 * promoted up to the next highest supported frequency.
100 *
101 * If this field is set to 0 Hz, the control request will
102 * be sent immediately as a one-shot frame. This may be useful
103 * for advanced applications that require outputs to be
104 * synchronized with data acquisition. In this case, we
105 * recommend not exceeding 50 ms between control calls.
106 *
107 * \param newUpdateFreqHz Parameter to modify
108 * \returns Itself
109 */
110 constexpr CoastOut &WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
111 {
112 UpdateFreqHz = newUpdateFreqHz;
113 return *this;
114 }
115
116 /**
117 * \brief Returns a string representation of the object.
118 *
119 * \returns a string representation of the object.
120 */
121 std::string ToString() const override;
122
123 /**
124 * \brief Gets information about this control request.
125 *
126 * \returns Map of control parameter names and corresponding applied values
127 */
128 std::map<std::string, std::string> GetControlInfo() const override;
129};
130
131}
132}
133}
134
Request coast neutral output of actuator.
Definition CoastOut.hpp:21
std::string ToString() const override
Returns a string representation of the object.
constexpr std::string_view GetName() const override
Gets the name of this control request.
Definition CoastOut.hpp:67
constexpr CoastOut & WithUseTimesync(bool newUseTimesync)
Modifies this Control Request's UseTimesync parameter and returns itself for method-chaining and easi...
Definition CoastOut.hpp:88
std::map< std::string, std::string > GetControlInfo() const override
Gets information about this control request.
units::frequency::hertz_t UpdateFreqHz
The frequency at which this control will update.
Definition CoastOut.hpp:50
bool UseTimesync
Set to true to delay applying this control request until a timesync boundary (requires Phoenix Pro an...
Definition CoastOut.hpp:35
constexpr CoastOut()
Request coast neutral output of actuator.
Definition CoastOut.hpp:57
constexpr ~CoastOut() override
Definition CoastOut.hpp:60
constexpr CoastOut & WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
Sets the frequency at which this control will update.
Definition CoastOut.hpp:110
Common interface implemented by all control requests.
Definition ControlRequest.hpp:27
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:28
Definition motor_constants.h:14