REVLib - C++
ServoHubLowLevel.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 <string>
34
35#include "rev/REVLibError.h"
36#include "rev/util/Signal.h"
37
38namespace rev::servohub {
39
41 friend class ServoChannel;
43
44public:
48 virtual ~ServoHubLowLevel();
49
56 int GetBusId() const;
57
63 int GetDeviceId() const;
64
66 uint8_t firmwareFix;
68 uint8_t firmwareYear;
71 };
78
84 std::string GetFirmwareVersionString() const;
85
99 void SetPeriodicFrameTimeout(int timeout_ms);
100
107 REVLibError SetCANTimeout(int timeout_ms);
108
123 void SetCANMaxRetries(int numRetries);
124
131 void SetControlFramePeriodMs(int period_ms);
132
138 int GetControlFramePeriodMs() const;
139
140 enum class CommunicationMode { kNone = 0, kCAN = 1, kRS_485 = 2 };
141
143 double voltage;
151 uint64_t timestamp;
152 };
154
184 uint64_t timestamp;
185 };
187
198 uint64_t timestamp;
199 };
201
212 uint64_t timestamp;
213 };
215
223 uint64_t timestamp;
224 };
226
231
232protected:
233 ServoHubLowLevel(int busID, int deviceID);
234
235 // The type is void* because we don't want to expose c_ServoHub_handle to
236 // the consumers of this header file
237 void* m_servoHubHandle{nullptr};
238
239private:
240 int m_busID;
241 int m_deviceID;
242};
243
244} // namespace rev::servohub
Definition: ServoChannel.h:42
Definition: ServoHubLowLevel.h:40
rev::util::Signal< PeriodicStatus4 > GetPeriodicStatus4() const
Definition: ServoHubLowLevel.cpp:229
ServoHubLowLevel(int busID, int deviceID)
Definition: ServoHubLowLevel.cpp:41
void SetControlFramePeriodMs(int period_ms)
Definition: ServoHubLowLevel.cpp:110
std::string GetFirmwareVersionString() const
Definition: ServoHubLowLevel.cpp:86
CommunicationMode
Definition: ServoHubLowLevel.h:140
void SetCANMaxRetries(int numRetries)
Definition: ServoHubLowLevel.cpp:105
int GetDeviceId() const
Definition: ServoHubLowLevel.cpp:74
rev::util::Signal< PeriodicStatus0 > GetPeriodicStatus0() const
Definition: ServoHubLowLevel.cpp:119
virtual ~ServoHubLowLevel()
Definition: ServoHubLowLevel.cpp:67
REVLibError SetCANTimeout(int timeout_ms)
Definition: ServoHubLowLevel.cpp:99
rev::util::Signal< PeriodicStatus1 > GetPeriodicStatus1() const
Definition: ServoHubLowLevel.cpp:140
FirmwareVersion GetFirmwareVersion() const
Definition: ServoHubLowLevel.cpp:76
int GetBusId() const
Definition: ServoHubLowLevel.cpp:72
int GetControlFramePeriodMs() const
Definition: ServoHubLowLevel.cpp:114
rev::util::Signal< PeriodicStatus2 > GetPeriodicStatus2() const
Definition: ServoHubLowLevel.cpp:187
void SetPeriodicFrameTimeout(int timeout_ms)
Definition: ServoHubLowLevel.cpp:94
void CreateSimFaultManager()
Definition: ServoHubLowLevel.cpp:247
void * m_servoHubHandle
Definition: ServoHubLowLevel.h:237
rev::util::Signal< PeriodicStatus3 > GetPeriodicStatus3() const
Definition: ServoHubLowLevel.cpp:208
Definition: ServoHubSimFaultManager.h:40
Definition: Signal.h:42
Definition: ServoChannelConfig.h:34
REVLibError
Definition: REVLibError.h:33
Definition: ServoHubLowLevel.h:65
uint8_t firmwareFix
Definition: ServoHubLowLevel.h:66
uint8_t firmwareYear
Definition: ServoHubLowLevel.h:68
uint8_t hardwareMajor
Definition: ServoHubLowLevel.h:70
uint8_t firmwareMinor
Definition: ServoHubLowLevel.h:67
uint8_t hardwareMinor
Definition: ServoHubLowLevel.h:69
Definition: ServoHubLowLevel.h:142
bool programmingEnabled
Definition: ServoHubLowLevel.h:149
uint64_t timestamp
Definition: ServoHubLowLevel.h:151
bool primaryHeartbeatLock
Definition: ServoHubLowLevel.h:146
double deviceCurrent
Definition: ServoHubLowLevel.h:145
bool activelyProgramming
Definition: ServoHubLowLevel.h:150
double voltage
Definition: ServoHubLowLevel.h:143
CommunicationMode communicationMode
Definition: ServoHubLowLevel.h:148
double servoVoltage
Definition: ServoHubLowLevel.h:144
bool systemEnabled
Definition: ServoHubLowLevel.h:147
Definition: ServoHubLowLevel.h:155
bool stickyChannel3Overcurrent
Definition: ServoHubLowLevel.h:181
bool stickyBrownout
Definition: ServoHubLowLevel.h:171
bool regulatorPowerGoodFault
Definition: ServoHubLowLevel.h:156
bool channel5Overcurrent
Definition: ServoHubLowLevel.h:169
bool brownout
Definition: ServoHubLowLevel.h:157
bool stickyCanBusOff
Definition: ServoHubLowLevel.h:173
bool hardwareFault
Definition: ServoHubLowLevel.h:160
bool stickyRegulatorPowerGoodFault
Definition: ServoHubLowLevel.h:170
bool stickyCanWarning
Definition: ServoHubLowLevel.h:172
bool stickyChannel4Overcurrent
Definition: ServoHubLowLevel.h:182
bool stickyChannel1Overcurrent
Definition: ServoHubLowLevel.h:179
bool stickyHasReset
Definition: ServoHubLowLevel.h:176
bool channel3Overcurrent
Definition: ServoHubLowLevel.h:167
bool channel2Overcurrent
Definition: ServoHubLowLevel.h:166
bool lowBatteryFault
Definition: ServoHubLowLevel.h:163
bool stickyChannel2Overcurrent
Definition: ServoHubLowLevel.h:180
bool channel0Overcurrent
Definition: ServoHubLowLevel.h:164
bool channel4Overcurrent
Definition: ServoHubLowLevel.h:168
bool canBusOff
Definition: ServoHubLowLevel.h:159
bool stickyChannel5Overcurrent
Definition: ServoHubLowLevel.h:183
bool stickyLowBatteryFault
Definition: ServoHubLowLevel.h:177
uint64_t timestamp
Definition: ServoHubLowLevel.h:184
bool channel1Overcurrent
Definition: ServoHubLowLevel.h:165
bool canWarning
Definition: ServoHubLowLevel.h:158
bool stickyFirmwareFault
Definition: ServoHubLowLevel.h:175
bool hasReset
Definition: ServoHubLowLevel.h:162
bool stickyHardwareFault
Definition: ServoHubLowLevel.h:174
bool stickyChannel0Overcurrent
Definition: ServoHubLowLevel.h:178
bool firmwareFault
Definition: ServoHubLowLevel.h:161
Definition: ServoHubLowLevel.h:188
uint16_t channel2PulseWidth
Definition: ServoHubLowLevel.h:191
bool channel2OutOfRange
Definition: ServoHubLowLevel.h:197
bool channel1Enabled
Definition: ServoHubLowLevel.h:193
uint16_t channel1PulseWidth
Definition: ServoHubLowLevel.h:190
bool channel2Enabled
Definition: ServoHubLowLevel.h:194
uint16_t channel0PulseWidth
Definition: ServoHubLowLevel.h:189
bool channel0OutOfRange
Definition: ServoHubLowLevel.h:195
bool channel1OutOfRange
Definition: ServoHubLowLevel.h:196
uint64_t timestamp
Definition: ServoHubLowLevel.h:198
bool channel0Enabled
Definition: ServoHubLowLevel.h:192
Definition: ServoHubLowLevel.h:202
bool channel3OutOfRange
Definition: ServoHubLowLevel.h:209
uint16_t channel5PulseWidth
Definition: ServoHubLowLevel.h:205
bool channel5Enabled
Definition: ServoHubLowLevel.h:208
uint16_t channel3PulseWidth
Definition: ServoHubLowLevel.h:203
bool channel5OutOfRange
Definition: ServoHubLowLevel.h:211
bool channel4OutOfRange
Definition: ServoHubLowLevel.h:210
bool channel4Enabled
Definition: ServoHubLowLevel.h:207
uint16_t channel4PulseWidth
Definition: ServoHubLowLevel.h:204
uint64_t timestamp
Definition: ServoHubLowLevel.h:212
bool channel3Enabled
Definition: ServoHubLowLevel.h:206
Definition: ServoHubLowLevel.h:216
double channel0Current
Definition: ServoHubLowLevel.h:217
double channel5Current
Definition: ServoHubLowLevel.h:222
uint64_t timestamp
Definition: ServoHubLowLevel.h:223
double channel3Current
Definition: ServoHubLowLevel.h:220
double channel2Current
Definition: ServoHubLowLevel.h:219
double channel1Current
Definition: ServoHubLowLevel.h:218
double channel4Current
Definition: ServoHubLowLevel.h:221