REVLib - C++
A301.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2026 REV Robotics
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. Neither the name of REV Robotics nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#pragma once
30
31#include <memory>
32#include <string>
33
34#include <wpi/hardware/motor/MotorController.hpp>
35
36// TODO
37#include "rev/REVLibError.h"
38#include "rev/util/Signal.h"
39
40namespace first::a301 {
41
42namespace internal {
43class A301;
44} // namespace internal
45
46constexpr int defaultDeviceId{3};
47
48class A301 : public wpi::MotorController {
49public:
58 explicit A301(int busId, int deviceId = defaultDeviceId);
59
63 ~A301() override;
64
71 int GetBusId() const;
72
79 int GetDeviceId() const;
80
88 uint32_t GetFirmwareVersion();
89
90 uint32_t GetFirmwareVersion(bool& isDebugBuild);
91
98 std::string GetFirmwareString();
99
108
116
124
132
133 struct Faults {
134 bool other{};
135 bool motorType{};
136 bool sensor{};
137 bool can{};
140 bool escEeprom{};
141 bool firmware{};
142 uint16_t rawBits{};
143
144 Faults() = default;
145
146 explicit Faults(uint16_t faults);
147 };
148
156
167
168 struct Warnings {
169 bool brownout{};
171 bool escEeprom{};
172 bool extEeprom{};
173 bool sensor{};
174 bool stall{};
175 bool hasReset{};
176 bool other{};
177 uint16_t rawBits{};
178
179 Warnings() = default;
180
181 explicit Warnings(uint16_t warnings);
182 };
183
191
202
209
216
223
230
238
246
254
263
268
275 rev::REVLibError SetVelocity(double velocity);
276
283 rev::REVLibError SetPosition(double position);
284
292 rev::REVLibError SetAbsolutePosition(double absPosition, bool isContinuous);
293
300 rev::REVLibError SetCurrent(double current);
301
302 /**** MotorController Interface ****/
303
310 void SetThrottle(double throttle) override;
311
318 double GetThrottle() const override;
319
329 void SetVoltage(wpi::units::volt_t output) override;
330
336 void SetInverted(bool isInverted) override;
337
343 bool GetInverted() const override;
344
348 void Disable() override;
349
350private:
351 std::unique_ptr<internal::A301> p;
352};
353
354} // namespace first::a301
Definition: A301.h:48
rev::REVLibError SetVelocity(double velocity)
Definition: A301.cpp:550
rev::util::Signal< bool > HasActiveFault() const
Definition: A301.cpp:387
rev::util::Signal< bool > HasActiveWarning() const
Definition: A301.cpp:397
void Disable() override
Definition: A301.cpp:601
~A301() override
rev::util::Signal< double > GetMotorTemperature() const
Definition: A301.cpp:521
int GetDeviceId() const
Definition: A301.cpp:357
int GetBusId() const
Definition: A301.cpp:355
bool GetInverted() const override
Definition: A301.cpp:595
rev::REVLibError ClearFaults()
Definition: A301.cpp:545
rev::util::Signal< double > GetBusVoltage() const
Definition: A301.cpp:506
rev::util::Signal< Warnings > GetStickyWarnings() const
Definition: A301.cpp:478
rev::util::Signal< double > GetMotorCurrent() const
Definition: A301.cpp:516
rev::util::Signal< bool > HasStickyFault() const
Definition: A301.cpp:392
rev::REVLibError SetRelativeEncoderPosition(double position)
Definition: A301.cpp:571
rev::REVLibError SetCurrent(double current)
Definition: A301.cpp:567
rev::util::Signal< double > GetEncoderVelocity() const
Definition: A301.cpp:533
rev::util::Signal< Warnings > GetWarnings() const
Definition: A301.cpp:453
rev::util::Signal< bool > HasStickyWarning() const
Definition: A301.cpp:402
void SetThrottle(double throttle) override
Definition: A301.cpp:577
rev::REVLibError SetPosition(double position)
Definition: A301.cpp:554
std::string GetFirmwareString()
Definition: A301.cpp:373
void SetVoltage(wpi::units::volt_t output) override
Definition: A301.cpp:585
A301(int busId, int deviceId=defaultDeviceId)
Definition: A301.cpp:350
rev::util::Signal< double > GetAppliedOutput() const
Definition: A301.cpp:511
rev::util::Signal< double > GetAbsoluteEncoderPosition() const
Definition: A301.cpp:539
rev::REVLibError SetAbsolutePosition(double absPosition, bool isContinuous)
Definition: A301.cpp:559
double GetThrottle() const override
Definition: A301.cpp:583
rev::util::Signal< double > GetRelativeEncoderPosition() const
Definition: A301.cpp:527
rev::util::Signal< Faults > GetFaults() const
Definition: A301.cpp:407
void SetInverted(bool isInverted) override
Definition: A301.cpp:591
rev::util::Signal< Faults > GetStickyFaults() const
Definition: A301.cpp:429
uint32_t GetFirmwareVersion()
Definition: A301.cpp:359
Definition: Signal.h:42
Definition: A301.cpp:43
constexpr int defaultDeviceId
Definition: A301.h:46
REVLibError
Definition: REVLibError.h:33
Definition: A301.h:133
bool gateDriver
Definition: A301.h:139
bool other
Definition: A301.h:134
bool temperature
Definition: A301.h:138
bool escEeprom
Definition: A301.h:140
bool sensor
Definition: A301.h:136
uint16_t rawBits
Definition: A301.h:142
bool motorType
Definition: A301.h:135
bool can
Definition: A301.h:137
bool firmware
Definition: A301.h:141
Definition: A301.h:168
bool escEeprom
Definition: A301.h:171
bool stall
Definition: A301.h:174
bool sensor
Definition: A301.h:173
bool brownout
Definition: A301.h:169
bool other
Definition: A301.h:176
bool hasReset
Definition: A301.h:175
bool overcurrent
Definition: A301.h:170
bool extEeprom
Definition: A301.h:172
uint16_t rawBits
Definition: A301.h:177