REVLib - C++
ServoHub.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024-2025 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
42namespace rev::servohub {
43
44class ServoHub : public ServoHubLowLevel {
45 friend class ServoHubSim;
46
47public:
57
58public:
64 explicit ServoHub(int deviceID);
65
69 ~ServoHub() override;
70
72
87 [[deprecated(
88 "Use Configure(rev::ResetMode) instead. This method will be removed in "
89 "2027.")]]
91 ServoHubConfig& config,
93
107 ServoHubConfig& config,
109
130 ServoHubConfig& config,
132
151 ServoHubConfig& config,
153
160 bool HasActiveFault() const;
161
168 bool HasStickyFault() const;
169
176 bool HasActiveWarning() const;
177
184 bool HasStickyWarning() const;
185
186 struct Faults {
191 uint16_t rawBits;
192
193 explicit Faults(uint16_t faults);
194 };
195
202 Faults GetFaults() const;
203
213 Faults GetStickyFaults() const;
214
215 struct Warnings {
226 uint16_t rawBits;
227
228 explicit Warnings(uint16_t warnings);
229 };
230
237 Warnings GetWarnings() const;
238
249
256
260 double GetDeviceVoltage() const;
261
265 double GetDeviceCurrent() const;
266
270 double GetServoVoltage() const;
271
279
280 enum class Bank { kBank0_2 = 0, kBank3_5 = 1 };
281
289 REVLibError SetBankPulsePeriod(Bank bank, int pulsePeriod_us);
290
291private:
292 std::vector<ServoChannel> m_servoChannels;
293};
294
295} // namespace rev::servohub
Definition: ServoChannel.h:39
ChannelId
Definition: ServoChannel.h:48
Definition: ServoHubConfigAccessor.h:35
Definition: ServoHubConfig.h:39
Definition: ServoHub.h:44
REVLibError ClearFaults()
Definition: ServoHub.cpp:175
Warnings GetWarnings() const
Definition: ServoHub.cpp:159
bool HasActiveWarning() const
Definition: ServoHub.cpp:100
double GetDeviceCurrent() const
Definition: ServoHub.cpp:189
Warnings GetStickyWarnings() const
Definition: ServoHub.cpp:167
bool HasStickyFault() const
Definition: ServoHub.cpp:93
REVLibError Configure(ServoHubConfig &config, ResetMode resetMode=ResetMode::kNoResetSafeParameters)
Definition: ServoHub.cpp:54
REVLibError ConfigureAsync(ServoHubConfig &config, ResetMode resetMode=ResetMode::kNoResetSafeParameters)
Definition: ServoHub.cpp:72
REVLibError SetBankPulsePeriod(Bank bank, int pulsePeriod_us)
Definition: ServoHub.cpp:213
Bank
Definition: ServoHub.h:280
bool HasStickyWarning() const
Definition: ServoHub.cpp:107
ServoHub(int deviceID)
Definition: ServoHub.cpp:40
~ServoHub() override
Definition: ServoHub.cpp:52
ServoChannel & GetServoChannel(ServoChannel::ChannelId channelId)
Definition: ServoHub.cpp:206
Faults GetFaults() const
Definition: ServoHub.cpp:123
ResetMode
Definition: ServoHub.h:71
double GetServoVoltage() const
Definition: ServoHub.cpp:196
bool HasActiveFault() const
Definition: ServoHub.cpp:86
Faults GetStickyFaults() const
Definition: ServoHub.cpp:131
ServoHubConfigAccessor configAccessor
Definition: ServoHub.h:56
double GetDeviceVoltage() const
Definition: ServoHub.cpp:182
Definition: ServoHubLowLevel.h:39
Definition: ServoHubSim.h:41
Definition: ServoChannelConfig.h:34
REVLibError
Definition: REVLibError.h:33
ResetMode
Definition: ConfigureTypes.h:33
Definition: ServoHub.h:186
bool lowBattery
Definition: ServoHub.h:190
bool hardware
Definition: ServoHub.h:188
bool regulatorPowerGood
Definition: ServoHub.h:187
bool firmware
Definition: ServoHub.h:189
uint16_t rawBits
Definition: ServoHub.h:191
Faults(uint16_t faults)
Definition: ServoHub.cpp:114
Definition: ServoHub.h:215
bool hasReset
Definition: ServoHub.h:219
bool channel0Overcurrent
Definition: ServoHub.h:220
bool channel2Overcurrent
Definition: ServoHub.h:222
Warnings(uint16_t warnings)
Definition: ServoHub.cpp:139
bool channel4Overcurrent
Definition: ServoHub.h:224
bool channel3Overcurrent
Definition: ServoHub.h:223
bool canBusOff
Definition: ServoHub.h:218
bool canWarning
Definition: ServoHub.h:217
bool brownout
Definition: ServoHub.h:216
bool channel1Overcurrent
Definition: ServoHub.h:221
bool channel5Overcurrent
Definition: ServoHub.h:225
uint16_t rawBits
Definition: ServoHub.h:226