![]() |
A class that manages Novint Falcon devices. More...
#include <SurgSim/Devices/Novint/NovintScaffold.h>
Classes | |
class | Callback |
struct | DeviceData |
class | Handle |
struct | StateData |
Public Member Functions | |
NovintScaffold (std::shared_ptr< SurgSim::Framework::Logger > logger=nullptr) | |
Constructor. More... | |
~NovintScaffold () | |
Destructor. More... | |
std::shared_ptr< SurgSim::Framework::Logger > | getLogger () const |
Gets the logger used by this object and the devices it manages. More... | |
Static Public Member Functions | |
static std::shared_ptr< NovintScaffold > | getOrCreateSharedInstance () |
Gets or creates the scaffold shared by all NovintDevice and Novint7DofDevice instances. More... | |
static void | setDefaultLogLevel (SurgSim::Framework::LogLevel logLevel) |
Sets the default log level. More... | |
Private Member Functions | |
bool | registerDevice (NovintCommonDevice *device) |
Registers the specified device object. More... | |
bool | unregisterDevice (const NovintCommonDevice *device) |
Unregisters the specified device object. More... | |
bool | initializeDeviceState (DeviceData *info) |
Initializes a single device, creating the necessary HDAL resources. More... | |
bool | finalizeDeviceState (DeviceData *info) |
Finalizes a single device, destroying the necessary HDAL resources. More... | |
bool | updateDevice (DeviceData *info) |
Updates the device information for a single device. More... | |
void | checkDeviceHoming (DeviceData *info) |
Checks whether a device has been homed. More... | |
void | calculateForceAndTorque (DeviceData *info) |
Calculates forces, and torques if the device is a 7Dof, and sends them to the HDAL. More... | |
void | setInputData (DeviceData *info) |
Sets the input DataGroup, which will be pushed to the InputComponent. More... | |
bool | initializeSdk () |
Initializes the HDAL SDK. More... | |
bool | finalizeSdk () |
Finalizes (de-initializes) the HDAL SDK. More... | |
bool | runHapticFrame () |
Executes the operations for a single haptic frame. More... | |
bool | createHapticLoop () |
Creates the haptic loop callback. More... | |
bool | destroyHapticLoop () |
Destroys the haptic loop callback. More... | |
bool | startScheduler () |
Starts the HDAL scheduler. More... | |
bool | stopScheduler () |
Stops the HDAL scheduler. More... | |
bool | getGravityCompensation (const DeviceData *info, bool *gravityCompensationState) |
Gets the gravity compensation flag for the current device. More... | |
bool | enforceGravityCompensation (const DeviceData *info, bool gravityCompensationState) |
Attempts to force the gravity compensation flag for the current device to the specified value. More... | |
bool | setGravityCompensation (const DeviceData *info, bool gravityCompensationState) |
Sets the gravity compensation flag for the current device, unless it's already set as desired. More... | |
bool | checkForFatalError (const char *message) |
Check for HDAL errors, display them, and signal fatal errors. More... | |
bool | checkForFatalError (bool previousError, const char *message) |
Check for HDAL errors, display them, and signal fatal errors. More... | |
void | setPositionScale (const NovintCommonDevice *device, double scale) |
Sets the position scale for this device. More... | |
void | setOrientationScale (const NovintCommonDevice *device, double scale) |
Sets the orientation scale for this device. More... | |
Static Private Member Functions | |
static SurgSim::DataStructures::DataGroup | buildDeviceInputData () |
Builds the data layout for the application input (i.e. device output). More... | |
Private Attributes | |
std::shared_ptr< SurgSim::Framework::Logger > | m_logger |
Logger used by the scaffold and all devices. More... | |
std::unique_ptr< StateData > | m_state |
Internal scaffold state. More... | |
Static Private Attributes | |
static SurgSim::Framework::LogLevel | m_defaultLogLevel = SurgSim::Framework::LOG_LEVEL_INFO |
The default logging level. More... | |
Friends | |
class | NovintCommonDevice |
class | NovintDevice |
A class that manages Novint Falcon devices.
This should support any device that can communicate using the Novint HDAL SDK toolkit, such as the off-the-shelf Novint Falcon gaming controller and the Novint Falcon with the Open Surgery Grip.
|
explicit |
Constructor.
logger | (optional) The logger to be used for the scaffold object and the devices it manages. If unspecified or empty, a console logger will be created and used. |
SurgSim::Device::NovintScaffold::~NovintScaffold | ( | ) |
Destructor.
|
staticprivate |
Builds the data layout for the application input (i.e. device output).
|
private |
Calculates forces, and torques if the device is a 7Dof, and sends them to the HDAL.
The force to output is composed of a vector named "force" in the output data, plus contributions from two optional Jacobians. If the matrix "springJacobian" is provided in the output data, a spring force & torque are generated from its product with the difference between the current pose and the pose in the output data named "inputPose". A damping force & torque are generated similarly. The intention is for a Behavior to calculate a nominal force & torque as well as the desired linearized changes to the force & torque based on changes to the input's pose & velocities. Then the linearized deltas to the output force & torque can be calculated at the haptic update rates, thereby smoothing the output response to motion.
info | The device data. |
|
private |
Checks whether a device has been homed.
If the position and/or orientation have not been homed, zeros the respective Values. Call this before setting the data to send to the Input Component. The DeviceData's parameter mutex should be locked before this function is called.
info | The device data. |
|
private |
Check for HDAL errors, display them, and signal fatal errors.
Exactly equivalent to checkForFatalError(false, message)
.
message | An additional descriptive message. |
|
inlineprivate |
Check for HDAL errors, display them, and signal fatal errors.
Exactly equivalent to checkForFatalError(message) || previousError
, but less nasty to read.
previousError | True if a previous error has occurred. |
message | An additional descriptive message. |
|
private |
Creates the haptic loop callback.
|
private |
Destroys the haptic loop callback.
Should be called while NOT holding the internal device list mutex, to prevent deadlock.
|
private |
Attempts to force the gravity compensation flag for the current device to the specified value.
Sets the flag repeatedly, until it reports the desired value, in order to work around the problem where attempts to set the gravity compensation do not always change the actual gravity compensation flag in the device.
Logs a message if the state is known to have been changed.
info | The device data. |
gravityCompensationState | Desired state of the gravity compensation flag. |
|
private |
Finalizes a single device, destroying the necessary HDAL resources.
[in,out] | info | The device data. |
|
private |
Finalizes (de-initializes) the HDAL SDK.
|
private |
Gets the gravity compensation flag for the current device.
info | The device data. | |
[out] | gravityCompensationState | State of the gravity compensation flag. |
std::shared_ptr< SurgSim::Framework::Logger > SurgSim::Device::NovintScaffold::getLogger | ( | ) | const |
Gets the logger used by this object and the devices it manages.
|
static |
Gets or creates the scaffold shared by all NovintDevice and Novint7DofDevice instances.
The scaffold is managed using a SingleInstance object, so it will be destroyed when all devices are released.
|
private |
Initializes a single device, creating the necessary HDAL resources.
[in,out] | info | The device data. |
|
private |
Initializes the HDAL SDK.
|
private |
Registers the specified device object.
If successful, the device object will become connected to an unused controller.
device | The device object to be used, which should have a unique name. |
|
private |
Executes the operations for a single haptic frame.
Should only be called from the context of a HDAL callback.
|
static |
Sets the default log level.
Has no effect unless called before a scaffold is created (i.e. before the first device).
logLevel | The log level. |
|
private |
Sets the gravity compensation flag for the current device, unless it's already set as desired.
info | The device data. |
gravityCompensationState | Desired state of the gravity compensation flag. |
|
private |
Sets the input DataGroup, which will be pushed to the InputComponent.
info | The device data |
|
private |
Sets the orientation scale for this device.
device | A pointer to the device. |
scale | The multiplicative factor to apply to the rotation angles. |
|
private |
Sets the position scale for this device.
device | A pointer to the device. |
scale | The multiplicative factor to apply to the position. |
|
private |
Starts the HDAL scheduler.
|
private |
Stops the HDAL scheduler.
|
private |
Unregisters the specified device object.
The corresponding controller will become unused, and can be re-registered later.
device | The device object. |
|
private |
Updates the device information for a single device.
info | The device data. |
|
friend |
|
friend |
|
staticprivate |
The default logging level.
|
private |
Logger used by the scaffold and all devices.
|
private |
Internal scaffold state.