iMSTK
Interactive Medical Simulation Toolkit
Public Member Functions | Static Public Member Functions | List of all members
imstk::VRPNDeviceClient Class Reference

This class is the receiver of the updates sent by the vrpn_server. More...

#include <imstkVRPNDeviceClient.h>

Inheritance diagram for imstk::VRPNDeviceClient:
Inheritance graph
[legend]
Collaboration diagram for imstk::VRPNDeviceClient:
Collaboration graph
[legend]

Public Member Functions

 VRPNDeviceClient (const std::string &deviceName, VRPNDeviceType type, const std::string &ip="localhost")
 Constructor.
 
virtual ~VRPNDeviceClient () override=default
 Destructor.
 
VRPNDeviceType getType () const
 
- Public Member Functions inherited from imstk::DeviceClient
 SIGNAL (DeviceClient, buttonStateChanged)
 
bool getTrackingEnabled () const
 Get/Set what listeners to enable on the device: tracking, analogic, force, buttons.
 
void setTrackingEnabled (const bool status)
 
bool getAnalogicEnabled () const
 
void setAnalogicEnabled (const bool status)
 
bool getButtonsEnabled () const
 
void setButtonsEnabled (const bool status)
 
bool getForceEnabled () const
 
void setForceEnabled (const bool status)
 
Vec3d getPosition ()
 Get the device position.
 
Vec3d getVelocity ()
 Get the device velocity.
 
Vec3d getAngularVelocity ()
 Get the device angular velocity.
 
Quatd getOrientation ()
 Get the device orientation.
 
const Vec3d & getOffset () const
 Get offset from position for device end effector.
 
const std::unordered_map< int, int > & getButtons () const
 Get button map.
 
int getButton (const int buttonId)
 Get the state of a button returns 0 if can't find button.
 
std::vector< double > getAnalog () const
 get values of the analog input
 
double getAnalog (int i) const
 get single analog value More...
 
virtual void update ()
 Do runtime logic.
 
const std::string & getIp ()
 Get/Set the device IP.
 
void setIp (const std::string &ip)
 
const std::string & getDeviceName ()
 Get/Set the device name.
 
void setDeviceName (const std::string &deviceName)
 
Vec3d getForce ()
 Get/Set the device force.
 
void setForce (Vec3d force)
 
- Public Member Functions inherited from imstk::EventObject
template<typename T >
void postEvent (const T &e)
 Emits the event Direct observers will be immediately called, in sync Queued observers will receive the Command in their queue for later execution, reciever must implement doEvent.
 
template<typename T >
void queueEvent (const T &e)
 Queues event directly to this.
 
void doEvent ()
 Do an event, if none exists return.
 
void doAllEvents ()
 Do all the events in the event queue.
 
void foreachEvent (std::function< void(Command cmd)> func)
 Thread safe loop over all event commands, one can implement a custom handler.
 
void rforeachEvent (std::function< void(Command cmd)> func)
 thread safe reverse loop over all event commands, one can implement a custom handler
 
void clearEvents ()
 Removes all events from queue cleans up copies of the event.
 

Static Public Member Functions

static void VRPN_CALLBACK trackerPositionChangeHandler (void *userData, const _vrpn_TRACKERCB t)
 VRPN call back for position and orientation data. More...
 
static void VRPN_CALLBACK trackerVelocityChangeHandler (void *userData, const _vrpn_TRACKERVELCB v)
 VRPN call back for velocity data. More...
 
static void VRPN_CALLBACK analogChangeHandler (void *userData, const _vrpn_ANALOGCB a)
 VRPN call back analog data. More...
 
static void VRPN_CALLBACK buttonChangeHandler (void *userData, const _vrpn_BUTTONCB b)
 VRPN call back for button changed (pressed or released) More...
 

Additional Inherited Members

- Public Types inherited from imstk::EventObject
using Observer = std::tuple< bool, std::weak_ptr< EventObject >, std::function< void(Event *)> >
 
- Protected Member Functions inherited from imstk::DeviceClient
 DeviceClient (const std::string &name, const std::string &ip)
 
- Protected Attributes inherited from imstk::DeviceClient
std::string m_deviceName
 Device Name.
 
std::string m_ip
 Connection device IP.
 
bool m_trackingEnabled = true
 Tracking enabled if true.
 
bool m_analogicEnabled = true
 Analogic enabled if true.
 
bool m_buttonsEnabled = true
 Buttons enabled if true.
 
bool m_forceEnabled = false
 Force enabled if true.
 
Vec3d m_position
 Position of end effector.
 
Vec3d m_velocity
 Linear velocity of end effector.
 
Vec3d m_angularVelocity
 Angular velocity of the end effector.
 
Quatd m_orientation
 Orientation of the end effector.
 
Vec3d m_force
 Force vector.
 
Vec3d m_endEffectorOffset = Vec3d(0.0, 0.0, 0.0)
 Offset from origin.
 
std::unordered_map< int, int > m_buttons
 
std::vector< double > m_analogChannels
 
ParallelUtils::SpinLock m_transformLock
 Used for devices filling data from other threads.
 
ParallelUtils::SpinLock m_forceLock
 Used for devices filling data from other threads.
 
ParallelUtils::SpinLock m_dataLock
 Used for button and analog data.
 
- Protected Attributes inherited from imstk::EventObject
ParallelUtils::SpinLock eventQueueLock
 
std::deque< CommandeventQueue
 
std::vector< std::pair< std::string, std::vector< Observer > > > queuedObservers
 
std::vector< std::pair< std::string, std::vector< Observer > > > directObservers
 

Detailed Description

This class is the receiver of the updates sent by the vrpn_server.

After adding a VRPNDeviceClient to the VRPNDeviceManger the static functions in this class will be called whenever new data comes in from vrpn_server.

Definition at line 27 of file imstkVRPNDeviceClient.h.

Member Function Documentation

◆ analogChangeHandler()

void VRPN_CALLBACK imstk::VRPNDeviceClient::analogChangeHandler ( void *  userData,
const _vrpn_ANALOGCB  a 
)
static

VRPN call back analog data.

Parameters
userDataPointer to a VRPNDeviceClient to allow updating internal data the server class used the device client pointer when registering
aVRPN callback structure for the analog data

Definition at line 42 of file imstkVRPNDeviceClient.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ buttonChangeHandler()

void VRPN_CALLBACK imstk::VRPNDeviceClient::buttonChangeHandler ( void *  userData,
const _vrpn_BUTTONCB  b 
)
static

VRPN call back for button changed (pressed or released)

Parameters
userDataPointer to a VRPNDeviceClient to allow updating internal data the server class used the device client pointer when registering
bVRPN callback structure containing new button data

Definition at line 69 of file imstkVRPNDeviceClient.cpp.

Here is the caller graph for this function:

◆ getType()

imstk::VRPNDeviceType imstk::VRPNDeviceClient::getType ( ) const
Returns
all the types that this client is tracking

Definition at line 76 of file imstkVRPNDeviceClient.cpp.

◆ trackerPositionChangeHandler()

void VRPN_CALLBACK imstk::VRPNDeviceClient::trackerPositionChangeHandler ( void *  userData,
const _vrpn_TRACKERCB  t 
)
static

VRPN call back for position and orientation data.

Parameters
userDataPointer to a VRPNDeviceClient to allow updating internal data the server class used the device client pointer when registering
tVRPN callback structure containing new position and orientation data

Definition at line 25 of file imstkVRPNDeviceClient.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ trackerVelocityChangeHandler()

void VRPN_CALLBACK imstk::VRPNDeviceClient::trackerVelocityChangeHandler ( void *  userData,
const _vrpn_TRACKERVELCB  v 
)
static

VRPN call back for velocity data.

Parameters
userDataPointer to a VRPNDeviceClient to allow updating internal data the server class used the device client pointer when registering
vVRPN callback structure tracker velocity

Definition at line 55 of file imstkVRPNDeviceClient.cpp.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: