![]() |
A class that manages Sensable PHANTOM devices. More...
#include <SurgSim/Devices/Phantom/PhantomScaffold.h>
Classes | |
class | Callback |
struct | DeviceData |
class | Handle |
struct | StateData |
Public Member Functions | |
PhantomScaffold (std::shared_ptr< SurgSim::Framework::Logger > logger=nullptr) | |
Constructor. More... | |
~PhantomScaffold () | |
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< PhantomScaffold > | getOrCreateSharedInstance () |
Gets or creates the scaffold shared by all PhantomDevice instances. More... | |
static void | setDefaultLogLevel (SurgSim::Framework::LogLevel logLevel) |
Sets the default log level. More... | |
Private Member Functions | |
bool | registerDevice (PhantomDevice *device) |
Registers the specified device object. More... | |
bool | unregisterDevice (const PhantomDevice *device) |
Unregisters the specified device object. More... | |
bool | initializeDeviceState (DeviceData *info) |
Initializes a single device, creating the necessary HDAPI resources. More... | |
bool | finalizeDeviceState (DeviceData *info) |
Finalizes a single device, destroying the necessary HDAPI resources. More... | |
bool | updateDevice (DeviceData *info) |
Updates the device information for a single device. More... | |
void | calculateForceAndTorque (DeviceData *info) |
Calculates forces and torques and sends them to the device library. More... | |
void | setInputData (DeviceData *info) |
Sets the input DataGroup, which will be pushed to the InputComponent. More... | |
bool | initializeSdk () |
Initializes the OpenHaptics SDK. More... | |
bool | finalizeSdk () |
Finalizes (de-initializes) the OpenHaptics 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 OpenHaptics scheduler. More... | |
bool | stopScheduler () |
Stops the OpenHaptics scheduler. More... | |
bool | checkForFatalError (const char *message) |
Check for OpenHaptics HDAPI errors, display them, and signal fatal errors. 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 | PhantomDevice |
A class that manages Sensable PHANTOM devices.
This should support any PHANTOM device that can communicate using OpenHaptics 3.0 toolkit, such as PHANTOM Omni, PHANTOM Desktop, and the PHANTOM Premium series devices. The implementation is currently limited to 3DoF haptic output (forces only, no torques).
|
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::PhantomScaffold::~PhantomScaffold | ( | ) |
Destructor.
|
staticprivate |
Builds the data layout for the application input (i.e. device output).
|
private |
Calculates forces and torques and sends them to the device library.
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 |
Check for OpenHaptics HDAPI errors, display them, and signal fatal errors.
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 |
Finalizes a single device, destroying the necessary HDAPI resources.
[in,out] | info | The device data. |
|
private |
Finalizes (de-initializes) the OpenHaptics SDK.
|
inline |
Gets the logger used by this object and the devices it manages.
|
static |
Gets or creates the scaffold shared by all PhantomDevice 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 HDAPI resources.
[in,out] | info | The device data. |
|
private |
Initializes the OpenHaptics 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 an OpenHaptics 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 input DataGroup, which will be pushed to the InputComponent.
info | The device data |
|
private |
Starts the OpenHaptics scheduler.
|
private |
Stops the OpenHaptics 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 |
|
staticprivate |
The default logging level.
|
private |
Logger used by the scaffold and all devices.
|
private |
Internal scaffold state.