iMSTK
Interactive Medical Simulation Toolkit
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
imstk::ProgrammableClient Class Reference

Allows setting the pose of the device from external caller without a real device connected. More...

#include <imstkProgrammableClient.h>

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

Classes

struct  CircularMovement
 Command for circular movement of an analytical geometry. More...
 
struct  Command
 General struct for command. Command will call activate when start time is reached, call updateDevice while active, and call complete when duration is over. More...
 
struct  Deformation
 Command for applying deformationt to a subset of vertices from an object. More...
 
struct  GraspAction
 Command for grasping an object. More...
 
struct  HoldCommand
 Command for holding a subset of vertices at a specific position. More...
 
struct  LinearMovement
 Command for linear movement of an analytical geometry. More...
 
struct  LinearVertexMovement
 Command for linear movement of a subset of vertices from an object. More...
 
struct  WaitCommand
 Command for waiting. Used to let system continue running with no active commands. More...
 

Public Types

enum  DeformationType { Compression, Tension, SimpleShear, PureShear }
 Enum for type of deformation.
 
- Public Types inherited from imstk::EventObject
using Observer = std::tuple< bool, std::weak_ptr< EventObject >, std::function< void(Event *)> >
 

Public Member Functions

 ProgrammableClient (const std::string &name="")
 Constructor.
 
 ~ProgrammableClient () override
 Destructor.
 
void setDeltaTime (double dt)
 Set the dt of the system. Should be the same as the simulation dt.
 
void update () override
 Update all commands.
 
bool addLinearMovement (Vec3d startPos, Vec3d stopPos, double startTime, double duration)
 Add a linear movement command to run. More...
 
bool addCircularMovement (Vec3d startPos, Vec3d centerPos, double startTime, double duration)
 Add a circular movement command to run. More...
 
bool addGrasping (std::shared_ptr< PbdObject > tool, std::shared_ptr< PbdObjectGrasping > objectGrasping, double startTime, double duration)
 Add a grasp command to run. More...
 
bool addLinearVertexMovement (std::shared_ptr< PbdObject > object, std::vector< int > vertexIds, Vec3d translation, std::vector< bool > pin, double startTime, double duration)
 Add a linear vertex movement command to run. More...
 
bool addDeformation (std::shared_ptr< PbdObject > object, std::vector< int > initPos, double strain, DeformationType defType, double poisson, std::vector< bool > pin, double startTime, double duration)
 Add a defomation command to run. More...
 
std::vector< int > findVertex (std::shared_ptr< PointSet > mesh, std::vector< Vec3d > initPos)
 
bool addWaitCommand (double startTime, double duration)
 Add a wait command to run. More...
 
bool addHoldCommand (std::shared_ptr< PbdObject > object, double startTime, double duration, std::vector< int > vertexIds)
 Add a hold command to run. More...
 
double getTotalDuration ()
 Returns to total duration of all commands.
 
bool isFinished ()
 Returns true if all commands have finished executing. Returns false otherwise.
 
void setOrientation (Quatd temp)
 
- 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...
 
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.
 

Protected Types

enum  CommandState { WAITING =0, ACTIVE, COMPLETE }
 Enum for current state of command.
 

Protected Member Functions

void run ()=delete
 
void cleanUp ()=delete
 
- Protected Member Functions inherited from imstk::DeviceClient
 DeviceClient (const std::string &name, const std::string &ip)
 

Protected Attributes

friend Command
 
double m_dt = 0.0
 
double m_currentTime = 0.0
 
bool m_complete = false
 
std::vector< Command * > m_commands
 
- 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

Allows setting the pose of the device from external caller without a real device connected.

Definition at line 24 of file imstkProgrammableClient.h.

Member Function Documentation

◆ addCircularMovement()

bool imstk::ProgrammableClient::addCircularMovement ( Vec3d  startPos,
Vec3d  centerPos,
double  startTime,
double  duration 
)

Add a circular movement command to run.

Parameters
startPosstarting position for movement
centerPoscenter of circle to move around
startTimetime when command should activate
durationtime when command should be active

Definition at line 126 of file imstkProgrammableClient.cpp.

Here is the caller graph for this function:

◆ addDeformation()

bool imstk::ProgrammableClient::addDeformation ( std::shared_ptr< PbdObject object,
std::vector< int >  initPos,
double  strain,
DeformationType  defType,
double  poisson,
std::vector< bool >  pin,
double  startTime,
double  duration 
)

Add a defomation command to run.

Parameters
objectpbdObject that contains vertices to move
initPossubset of vertex's initial positions to move
strainstrain of deofmration
DeformationTypetype of deforamtion to apply
poisson
pinvecotr of bools to control which dims to move
startTimetime when command should activate
durationtime when command should be active

Definition at line 279 of file imstkProgrammableClient.cpp.

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

◆ addGrasping()

bool imstk::ProgrammableClient::addGrasping ( std::shared_ptr< PbdObject tool,
std::shared_ptr< PbdObjectGrasping objectGrasping,
double  startTime,
double  duration 
)

Add a grasp command to run.

Parameters
toolpbdObject the perfroms the grasping
objectGraspinghow grasping action is defined
startTimetime when command should activate
durationtime when command should be active

Definition at line 177 of file imstkProgrammableClient.cpp.

Here is the caller graph for this function:

◆ addHoldCommand()

bool imstk::ProgrammableClient::addHoldCommand ( std::shared_ptr< PbdObject object,
double  startTime,
double  duration,
std::vector< int >  vertexIds 
)

Add a hold command to run.

Parameters
objectpbdObject that contains vertices to hold
startTimetime when command should activate
durationtime when command should be active
vertexIdsvecotr of vertex ids to hold

Definition at line 423 of file imstkProgrammableClient.cpp.

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

◆ addLinearMovement()

bool imstk::ProgrammableClient::addLinearMovement ( Vec3d  startPos,
Vec3d  stopPos,
double  startTime,
double  duration 
)

Add a linear movement command to run.

Parameters
startPosstarting position for movement
stopPosending position for movement
startTimetime when command should activate
durationtime when command should be active

Definition at line 82 of file imstkProgrammableClient.cpp.

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

◆ addLinearVertexMovement()

bool imstk::ProgrammableClient::addLinearVertexMovement ( std::shared_ptr< PbdObject object,
std::vector< int >  vertexIds,
Vec3d  translation,
std::vector< bool >  pin,
double  startTime,
double  duration 
)

Add a linear vertex movement command to run.

Parameters
objectpbdObject that contains vertices to move
vertexIdssubset of vertices to move
translationvector of distance to move
pinvecotr of booleans to control which dims to move
startTimetime when command should activate
durationtime when command should be active

Definition at line 203 of file imstkProgrammableClient.cpp.

Here is the caller graph for this function:

◆ addWaitCommand()

bool imstk::ProgrammableClient::addWaitCommand ( double  startTime,
double  duration 
)

Add a wait command to run.

Parameters
startTimetime when command should activate
durationtime when command should be active

Definition at line 407 of file imstkProgrammableClient.cpp.

Here is the caller graph for this function:

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