CTRE Phoenix 6 C++ 26.0.0-beta-1
Loading...
Searching...
No Matches
EmptyAnimation.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 * An empty animation, clearing any animation in the specified slot.
19 *
20 *
21 */
22class EmptyAnimation final : public ControlRequest {
23 ctre::phoenix::StatusCode SendRequest(const char *network, uint32_t deviceHash, std::shared_ptr<ControlRequest> &req) const override;
24
25public:
26 /**
27 * \brief The slot of this animation, within [0, 7]. Each slot on the CANdle can
28 * store and run one animation.
29 */
30 int Slot;
31
32 /**
33 * \brief The frequency at which this control will update.
34 * This is designated in Hertz, with a minimum of 20 Hz
35 * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
36 * Some update frequencies are not supported and will be
37 * promoted up to the next highest supported frequency.
38 *
39 * If this field is set to 0 Hz, the control request will
40 * be sent immediately as a one-shot frame. This may be useful
41 * for advanced applications that require outputs to be
42 * synchronized with data acquisition. In this case, we
43 * recommend not exceeding 50 ms between control calls.
44 */
45 units::frequency::hertz_t UpdateFreqHz{0_Hz};
46
47 /**
48 * \brief An empty animation, clearing any animation in the specified slot.
49 *
50 * \details
51 *
52 * \param Slot The slot of this animation, within [0, 7]. Each slot on the
53 * CANdle can store and run one animation.
54 */
56 Slot{std::move(Slot)}
57 {}
58
59 constexpr ~EmptyAnimation() override {}
60
61 /**
62 * \brief Gets the name of this control request.
63 *
64 * \returns Name of the control request
65 */
66 constexpr std::string_view GetName() const override
67 {
68 return "EmptyAnimation";
69 }
70
71 /**
72 * \brief Modifies this Control Request's Slot parameter and returns itself for
73 * method-chaining and easier to use request API.
74 *
75 * The slot of this animation, within [0, 7]. Each slot on the CANdle can store
76 * and run one animation.
77 *
78 * \param newSlot Parameter to modify
79 * \returns Itself
80 */
81 constexpr EmptyAnimation &WithSlot(int newSlot)
82 {
83 Slot = std::move(newSlot);
84 return *this;
85 }
86
87 /**
88 * \brief Sets the frequency at which this control will update.
89 * This is designated in Hertz, with a minimum of 20 Hz
90 * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
91 * Some update frequencies are not supported and will be
92 * promoted up to the next highest supported frequency.
93 *
94 * If this field is set to 0 Hz, the control request will
95 * be sent immediately as a one-shot frame. This may be useful
96 * for advanced applications that require outputs to be
97 * synchronized with data acquisition. In this case, we
98 * recommend not exceeding 50 ms between control calls.
99 *
100 * \param newUpdateFreqHz Parameter to modify
101 * \returns Itself
102 */
103 constexpr EmptyAnimation &WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
104 {
105 UpdateFreqHz = newUpdateFreqHz;
106 return *this;
107 }
108
109 /**
110 * \brief Returns a string representation of the object.
111 *
112 * \returns a string representation of the object.
113 */
114 std::string ToString() const override;
115
116 /**
117 * \brief Gets information about this control request.
118 *
119 * \returns Map of control parameter names and corresponding applied values
120 */
121 std::map<std::string, std::string> GetControlInfo() const override;
122};
123
124}
125}
126}
127
Common interface implemented by all control requests.
Definition ControlRequest.hpp:27
An empty animation, clearing any animation in the specified slot.
Definition EmptyAnimation.hpp:22
units::frequency::hertz_t UpdateFreqHz
The frequency at which this control will update.
Definition EmptyAnimation.hpp:45
constexpr EmptyAnimation & WithSlot(int newSlot)
Modifies this Control Request's Slot parameter and returns itself for method-chaining and easier to u...
Definition EmptyAnimation.hpp:81
std::map< std::string, std::string > GetControlInfo() const override
Gets information about this control request.
constexpr EmptyAnimation & WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
Sets the frequency at which this control will update.
Definition EmptyAnimation.hpp:103
std::string ToString() const override
Returns a string representation of the object.
constexpr EmptyAnimation(int Slot)
An empty animation, clearing any animation in the specified slot.
Definition EmptyAnimation.hpp:55
int Slot
The slot of this animation, within [0, 7].
Definition EmptyAnimation.hpp:30
constexpr ~EmptyAnimation() override
Definition EmptyAnimation.hpp:59
constexpr std::string_view GetName() const override
Gets the name of this control request.
Definition EmptyAnimation.hpp:66
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:28
Definition motor_constants.h:14