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