Package com.revrobotics.servohub
Class ServoHubLowLevel
java.lang.Object
com.revrobotics.NativeResourceCleaner
com.revrobotics.servohub.ServoHubLowLevel
- All Implemented Interfaces:
REVDevice,AutoCloseable
- Direct Known Subclasses:
ServoHub
public abstract class ServoHubLowLevel
extends NativeResourceCleaner
implements REVDevice, AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassclassclassclassclassclassNested classes/interfaces inherited from class com.revrobotics.NativeResourceCleaner
NativeResourceCleaner.OnClean -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionServoHubLowLevel(int deviceId) Create a new object to control a ServoHub Servo Controller -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the ServoHub ControllervoidCreate the sim gui Fault Manager for this Servo Hubprotected NativeResourceCleaner.OnCleanNote: it is important that no reference to 'this' is taken in the implementation.intSet the control frame send period for the native CAN Send thread.intGet the configured Device ID of the ServoHub.Get the firmware version of the ServoHub.Get the firmware version of the ServoHub as a string.@Nullable ServoHubLowLevel.PeriodicStatus0@Nullable ServoHubLowLevel.PeriodicStatus1@Nullable ServoHubLowLevel.PeriodicStatus2@Nullable ServoHubLowLevel.PeriodicStatus3@Nullable ServoHubLowLevel.PeriodicStatus4voidsetCANMaxRetries(int numRetries) Set the maximum number of times to retry an RTR CAN frame.setCANTimeout(int timeout_ms) Sets the timeout duration for waiting for CAN responses from the device.voidsetControlFramePeriodMs(int periodMs) Set the control frame send period for the native CAN Send thread.voidsetPeriodicFrameTimeout(int timeout_ms) Set the amount of time to wait for a periodic status frame before returning a timeout error.protected voidMethods inherited from class com.revrobotics.NativeResourceCleaner
registerCleaner
-
Field Details
-
servoHubHandle
protected final long servoHubHandle
-
-
Constructor Details
-
ServoHubLowLevel
public ServoHubLowLevel(int deviceId) Create a new object to control a ServoHub Servo Controller- Parameters:
deviceId- The device ID.
-
-
Method Details
-
close
public void close()Closes the ServoHub Controller- Specified by:
closein interfaceAutoCloseable
-
getCleanAction
Description copied from class:NativeResourceCleanerNote: it is important that no reference to 'this' is taken in the implementation.- Specified by:
getCleanActionin classNativeResourceCleaner- Returns:
- an action to run on clean
-
getDeviceId
public int getDeviceId()Get the configured Device ID of the ServoHub.- Returns:
- int device ID
-
getFirmwareVersion
Get the firmware version of the ServoHub.- Returns:
- FirmwareVersion tbd
-
getFirmwareVersionString
Get the firmware version of the ServoHub as a string.- Returns:
- String Human readable firmware version string
-
setPeriodicFrameTimeout
public void setPeriodicFrameTimeout(int timeout_ms) Set the amount of time to wait for a periodic status frame before returning a timeout error. This timeout will apply to all periodic status frames for the ServoHub servo controller.To prevent invalid timeout errors, the minimum timeout for a given periodic status is 2.1 times its period. To use the minimum timeout for all status frames, set timeout_ms to 0.
The default timeout is 500ms.
- Parameters:
timeout_ms- The timeout in milliseconds
-
setCANTimeout
Sets the timeout duration for waiting for CAN responses from the device.- Parameters:
timeout_ms- The timeout in milliseconds.- Returns:
REVLibError.kOkif successful
-
setCANMaxRetries
public void setCANMaxRetries(int numRetries) Set the maximum number of times to retry an RTR CAN frame. This applies to calls such as GetFirmwareVersion where a request is made to the ServoHub and a response is expected. Anytime sending the request or receiving the response fails, it will retry the request a number of times, no more than the value set by this method. If an attempt succeeds, it will immediately return. The minimum number of retries is 0, where only a single attempt will be made and will return regardless of success or failure.The default maximum is 5 retries.
- Parameters:
numRetries- The maximum number of retries
-
setControlFramePeriodMs
public void setControlFramePeriodMs(int periodMs) Set the control frame send period for the native CAN Send thread.- Parameters:
periodMs- The send period in milliseconds between 1ms and 100ms or set to 0 to disable periodic sends.
-
getControlFramePeriodMs
public int getControlFramePeriodMs()Set the control frame send period for the native CAN Send thread.- Returns:
- int The send period in milliseconds.
-
getPeriodicStatus0
-
getPeriodicStatus1
-
getPeriodicStatus2
-
getPeriodicStatus3
-
getPeriodicStatus4
-
createSimFaultManager
public void createSimFaultManager()Create the sim gui Fault Manager for this Servo Hub -
throwIfClosed
protected void throwIfClosed()
-