REVLib - C++
ServoHub.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024-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 <stdint.h>
32
33#include <vector>
34
35#include "rev/ConfigureTypes.h"
36#include "rev/REVLibError.h"
37#include "rev/ServoChannel.h"
41#include "rev/util/Signal.h"
42
43namespace rev::servohub {
44
45class ServoHub : public ServoHubLowLevel {
46 friend class ServoHubSim;
47
48public:
58
59public:
66 ServoHub(int busID, int deviceID);
67
71 ~ServoHub() override;
72
74
88 ServoHubConfig& config,
90
109 ServoHubConfig& config,
111
119
127
135
143
144 struct Faults {
146 bool hardware{};
147 bool firmware{};
149 uint16_t rawBits{};
150
151 Faults() = default;
152 explicit Faults(uint16_t faults);
153 };
154
162
173
174 struct Warnings {
175 bool brownout{};
177 bool canBusOff{};
178 bool hasReset{};
185 uint16_t rawBits{};
186
187 Warnings() = default;
188 explicit Warnings(uint16_t warnings);
189 };
190
199
211
218
223
228
233
241
242 enum class Bank { kBank0_2 = 0, kBank3_5 = 1 };
243
251 REVLibError SetBankPulsePeriod(Bank bank, int pulsePeriod_us);
252
253private:
254 std::vector<ServoChannel> m_servoChannels;
255};
256
257} // namespace rev::servohub
Definition: ServoChannel.h:42
ChannelId
Definition: ServoChannel.h:51
Definition: ServoHubConfigAccessor.h:35
Definition: ServoHubConfig.h:39
Definition: ServoHub.h:45
REVLibError ClearFaults()
Definition: ServoHub.cpp:199
rev::util::Signal< double > GetDeviceVoltage() const
Definition: ServoHub.cpp:206
ServoHub(int busID, int deviceID)
Definition: ServoHub.cpp:41
rev::util::Signal< bool > HasActiveWarning() const
Definition: ServoHub.cpp:85
REVLibError SetBankPulsePeriod(Bank bank, int pulsePeriod_us)
Definition: ServoHub.cpp:231
Bank
Definition: ServoHub.h:242
REVLibError ConfigureAsync(ServoHubConfig &config, rev::ResetMode resetMode=rev::ResetMode::kNoResetSafeParameters)
Definition: ServoHub.cpp:68
rev::util::Signal< Warnings > GetStickyWarnings() const
Definition: ServoHub.cpp:175
~ServoHub() override
Definition: ServoHub.cpp:52
rev::util::Signal< Warnings > GetWarnings() const
Definition: ServoHub.cpp:151
ServoChannel & GetServoChannel(ServoChannel::ChannelId channelId)
Definition: ServoHub.cpp:224
rev::util::Signal< double > GetServoVoltage() const
Definition: ServoHub.cpp:216
rev::util::Signal< bool > HasStickyWarning() const
Definition: ServoHub.cpp:89
ResetMode
Definition: ServoHub.h:73
rev::util::Signal< bool > HasStickyFault() const
Definition: ServoHub.cpp:81
rev::util::Signal< Faults > GetFaults() const
Definition: ServoHub.cpp:103
rev::util::Signal< bool > HasActiveFault() const
Definition: ServoHub.cpp:77
ServoHubConfigAccessor configAccessor
Definition: ServoHub.h:57
rev::util::Signal< double > GetDeviceCurrent() const
Definition: ServoHub.cpp:211
REVLibError Configure(ServoHubConfig &config, rev::ResetMode resetMode=rev::ResetMode::kNoResetSafeParameters)
Definition: ServoHub.cpp:54
rev::util::Signal< Faults > GetStickyFaults() const
Definition: ServoHub.cpp:117
Definition: ServoHubLowLevel.h:40
Definition: ServoHubSim.h:41
Definition: Signal.h:42
Definition: ServoChannelConfig.h:34
REVLibError
Definition: REVLibError.h:33
ResetMode
Definition: ConfigureTypes.h:33
Definition: ServoHub.h:144
bool lowBattery
Definition: ServoHub.h:148
bool hardware
Definition: ServoHub.h:146
bool regulatorPowerGood
Definition: ServoHub.h:145
bool firmware
Definition: ServoHub.h:147
uint16_t rawBits
Definition: ServoHub.h:149
Definition: ServoHub.h:174
bool hasReset
Definition: ServoHub.h:178
bool channel0Overcurrent
Definition: ServoHub.h:179
bool channel2Overcurrent
Definition: ServoHub.h:181
bool channel4Overcurrent
Definition: ServoHub.h:183
bool channel3Overcurrent
Definition: ServoHub.h:182
bool canBusOff
Definition: ServoHub.h:177
bool canWarning
Definition: ServoHub.h:176
bool brownout
Definition: ServoHub.h:175
bool channel1Overcurrent
Definition: ServoHub.h:180
bool channel5Overcurrent
Definition: ServoHub.h:184
uint16_t rawBits
Definition: ServoHub.h:185