SOFA plugin: Geomagic  master
Open source framework for multi-physics simuation
geomagic::GeomagicDriver Class Reference

#include <GeomagicDriver.h>

Inheritance diagram for geomagic::GeomagicDriver:

Detailed Description

Class providing a driver API to handle Geomagic haptic device and the servo loop scheduler. Position and angles of the device will be retrieve inside

See also
m_hapticData during a callback method executed by HD scheduler. This callback is also setting force to the device if a ForceFeedBack component is used in the simulation scene. Those data are then copied inside
m_simuData and used to update Device position in SOFA world in method
updatePosition()

Classes

struct  DeviceData
 These data are written by the omni they cnnot be accessed in the simulation loop. More...
 

Public Attributes

unsigned int HD_INVALID_HANDLE = 0
 
Data< std::string > d_deviceName
 Name of device Configuration. More...
 
Data< Vec3d_positionBase
 Position of the device base in the SOFA scene world coordinates. More...
 
Data< Quatd_orientationBase
 Orientation of the device base in the SOFA scene world coordinates. More...
 
Data< Quatd_orientationTool
 Orientation of the tool in the SOFA scene world coordinates. More...
 
Data< SReal > d_scale
 Default scale applied to the Device coordinates. More...
 
Data< SReal > d_forceScale
 Default scaling factor applied to the force feedback. More...
 
Data< SReal > d_maxInputForceFeedback
 Maximum value of the normed input force feedback for device security. More...
 
Data< Vec3d_inputForceFeedback
 Input force feedback in case of no LCPForceFeedback is found (manual setting) More...
 
Data< bool > d_manualStart
 If true, will not automatically initDevice at component init phase. More...
 
Data< bool > d_emitButtonEvent
 If true, will send event through the graph when button are pushed/released. More...
 
Data< bool > d_frameVisu
 Visualize the frame corresponding to the device tooltip. More...
 
Data< bool > d_omniVisu
 Visualize the Geomagic device in the virtual scene. More...
 
Data< Coordd_posDevice
 position of the base of the part of the device More...
 
Data< type::Vec6 > d_angle
 Angular values of joint (rad) More...
 
Data< bool > d_button_1
 Button state 1. More...
 
Data< bool > d_button_2
 Button state 2. More...
 
sofa::component::haptics::ForceFeedback::SPtr m_forceFeedback
 
SingleLink< GeomagicDriver, sofa::component::haptics::ForceFeedback, BaseLink::FLAG_STOREPATH|BaseLink::FLAG_STRONGLINK > l_forceFeedback
 
bool m_simulationStarted
 Boolean to warn scheduler when SOFA has started the simulation (changed by AnimateBeginEvent) More...
 
bool m_isInContact
 Boolean to warn SOFA side when scheduler has computer contact (forcefeedback no null) More...
 
DeviceData m_hapticData
 data structure used by scheduler More...
 
DeviceData m_simuData
 data structure used by SOFA loop, values are copied from More...
 
SHHD m_hHD
 ID the device. More...
 
std::vector< SHDSchedulerHandlem_hStateHandles
 List of ref to the workers scheduled. More...
 
- Public Attributes inherited from sofa::core::objectmodel::BaseObject
Data< bool > f_listening
 
- Public Attributes inherited from sofa::core::objectmodel::Base
std::vector< lifecycle::DeprecatedData * > m_oldAttributes
 
Data< int > d_messageLogCount
 
Data< std::string > name
 
Data< bool > f_printLog
 
Data< sofa::core::objectmodel::TagSetf_tags
 
Data< sofa::type::BoundingBoxf_bbox
 
Data< sofa::core::objectmodel::ComponentStated_componentState
 
std::string m_definitionSourceFileName
 
int m_definitionSourceFilePos
 
std::string m_instanciationSourceFileName
 
int m_instanciationSourceFilePos
 

Static Public Attributes

static bool s_schedulerRunning = false
 This static bool is used to know if HD scheduler is already running. No mechanism provided by Hd lib. More...
 

Protected Attributes

std::unique_ptr< GeomagicVisualModelm_GeomagicVisualModel
 
- Protected Attributes inherited from sofa::component::controller::Controller
Data< bool > d_handleEventTriggersUpdate
 
- Protected Attributes inherited from sofa::core::objectmodel::BaseObject
SingleLink< BaseObject, BaseContext, BaseLink::FLAG_DOUBLELINK > l_context
 
LinkSlaves l_slaves
 
SingleLink< BaseObject, BaseObject, BaseLink::FLAG_DOUBLELINK > l_master
 
- Protected Attributes inherited from sofa::core::objectmodel::Base
std::map< std::string, sofa::core::DataTrackerCallbackm_internalEngine
 
VecData m_vecData
 
MapData m_aliasData
 
VecLink m_vecLink
 
MapLink m_aliasLink
 

Public Member Functions

 SOFA_CLASS (GeomagicDriver, Controller)
 
 GeomagicDriver ()
 
virtual ~GeomagicDriver ()
 
void init () override
 
void draw (const sofa::core::visual::VisualParams *vparams) override
 
void handleEvent (core::objectmodel::Event *) override
 
void computeBBox (const core::ExecParams *params, bool onlyVisible=false) override
 
virtual void initDevice ()
 Public method to init tool. Can be called from thirdparty if. More...
 
virtual void clearDevice ()
 Method to clear scheduler and free device. Called by default at driver destruction. More...
 
- Public Member Functions inherited from sofa::component::controller::Controller
 SOFA_CLASS (Controller, core::behavior::BaseController)
 
virtual void onMouseEvent (core::objectmodel::MouseEvent *)
 
virtual void onHapticDeviceEvent (core::objectmodel::HapticDeviceEvent *)
 
virtual void onKeyPressedEvent (core::objectmodel::KeypressedEvent *)
 
virtual void onKeyReleasedEvent (core::objectmodel::KeyreleasedEvent *)
 
virtual void onJoystickEvent (core::objectmodel::JoystickEvent *)
 
virtual void onBeginAnimationStep (const double)
 
virtual void onEndAnimationStep (const double)
 
virtual void onGUIEvent (core::objectmodel::GUIEvent *)
 
void handleEvent (core::objectmodel::Event *) override
 
- Public Member Functions inherited from sofa::core::behavior::BaseController
 SOFA_ABSTRACT_CLASS (BaseController, core::objectmodel::BaseObject)
 
- Public Member Functions inherited from sofa::core::objectmodel::BaseObject
 SOFA_CLASS (BaseObject, Base)
 
virtual void computeBBox (const core::ExecParams *, bool=false)
 
void setSrc (const std::string &v, std::vector< std::string > *attributeList=nullptr)
 
void setSrc (const std::string &v, const BaseObject *loader, std::vector< std::string > *attributeList=nullptr)
 
BasefindLinkDestClass (const BaseClass *destType, const std::string &path, const BaseLink *link) override
 
virtual std::string getPathName () const override
 
virtual bool insertInNode (BaseNode *)
 
virtual bool removeInNode (BaseNode *)
 
SReal getTime () const
 
const BaseContextgetContext () const
 
BaseContextgetContext ()
 
const BaseObjectgetMaster () const
 
BaseObjectgetMaster ()
 
const VecSlavesgetSlaves () const
 
BaseObjectgetSlave (const std::string &name) const
 
virtual void addSlave (BaseObject::SPtr s)
 
virtual void removeSlave (BaseObject::SPtr s)
 
virtual void handleTopologyChange ()
 
virtual void handleTopologyChange (core::topology::Topology *t)
 
void parse (BaseObjectDescription *arg) override
 
virtual void bwdInit ()
 
virtual void reinit ()
 
void updateInternal ()
 
virtual void storeResetState ()
 
virtual void reset ()
 
virtual void cleanup ()
 
SReal getTime () const
 
- Public Member Functions inherited from sofa::core::objectmodel::Base
virtual const BaseClassgetClass () const
 
void addDeprecatedAttribute (lifecycle::DeprecatedData *attribute)
 
void addUpdateCallback (const std::string &name, std::initializer_list< BaseData * > inputs, std::function< sofa::core::objectmodel::ComponentState(const DataTracker &)> function, std::initializer_list< BaseData * > outputs)
 
void addOutputsToCallback (const std::string &name, std::initializer_list< BaseData * > outputs)
 
const std::string & getName () const
 
void setName (const std::string &n)
 
void setName (const std::string &n, int counter)
 
std::string getTypeName () const
 
virtual std::string getClassName () const
 
virtual std::string getTemplateName () const final
 
std::string getNameSpaceName () const
 
void setDefinitionSourceFileName (const std::string &sourceFileName)
 
const std::string & getDefinitionSourceFileName () const
 
void setDefinitionSourceFilePos (const int)
 
int getDefinitionSourceFilePos () const
 
void setInstanciationSourceFileName (const std::string &sourceFileName)
 
const std::string & getInstanciationSourceFileName () const
 
void setInstanciationSourceFilePos (const int)
 
int getInstanciationSourceFilePos () const
 
void addMessage (const sofa::helper::logging::Message &m) const
 
size_t countLoggedMessages (sofa::helper::logging::Message::TypeSet t=sofa::helper::logging::Message::AnyTypes) const
 
const std::deque< sofa::helper::logging::Message > & getLoggedMessages () const
 
const std::string getLoggedMessagesAsString (sofa::helper::logging::Message::TypeSet t=sofa::helper::logging::Message::AnyTypes) const
 
void clearLoggedMessages () const
 
bool notMuted () const
 
const sofa::core::objectmodel::TagSetgetTags () const
 
bool hasTag (Tag t) const
 
void addTag (Tag t)
 
void removeTag (Tag t)
 
ComponentState getComponentState () const
 
bool isComponentStateValid () const
 
bool isComponentStateInvalid () const
 
 SOFA_ATTRIBUTE_DEPRECATED__TOBASECONSTRAINT () virtual const behavior
 
virtual bool parseField (const std::string &attribute, const std::string &value)
 
virtual bool hasField (const std::string &attribute) const
 
void parseFields (const std::list< std::string > &str)
 
virtual void parseFields (const std::map< std::string, std::string * > &str)
 
void writeDatas (std::map< std::string, std::string * > &str)=delete
 
void writeDatas (std::ostream &out, const std::string &separator=" ")
 
BaseDatafindData (const std::string &name) const
 
std::vector< BaseData * > findGlobalField (const std::string &name) const
 
BaseLinkfindLink (const std::string &name) const
 
std::vector< BaseLink * > findLinks (const std::string &name) const
 
virtual void updateLinks (bool logErrors=true)
 
BaseData::BaseInitData initData (::sofa::core::objectmodel::Data< T > *field, const char *name, const char *help, ::sofa::core::objectmodel::BaseData::DataFlags dataflags)
 
BaseData::BaseInitData initData (Data< T > *field, const char *name, const char *help, bool isDisplayed=true, bool isReadOnly=false)
 
Data< T >::InitData initData (Data< T > *field, const T &value, const char *name, const char *help, bool isDisplayed=true, bool isReadOnly=false)
 
void addData (BaseData *f, const std::string &name)
 
void addData (BaseData *f)
 
void removeData (BaseData *f)
 
void addAlias (BaseData *field, const char *alias)
 
void addLink (BaseLink *l)
 
void addAlias (BaseLink *link, const char *alias)
 
const VecDatagetDataFields () const
 
const MapDatagetDataAliases () const
 
const VecLinkgetLinks () const
 
const MapLinkgetLinkAliases () const
 
virtual bool findDataLinkDest (BaseData *&ptr, const std::string &path, const BaseLink *link)
 
bool findLinkDest (T *&ptr, const std::string &path, const BaseLink *link)
 
const sofa::core::objectmodel::TagSetgetTags () const
 
bool hasTag (Tag t) const
 
void addTag (Tag t)
 
void removeTag (Tag t)
 
ComponentState getComponentState () const
 
bool isComponentStateValid () const
 
bool isComponentStateInvalid () const
 
 SOFA_ATTRIBUTE_DEPRECATED__TOBASECONSTRAINT () virtual const behavior
 

Protected Member Functions

void updatePosition ()
 Internal method to update the position of the device in SOFA world using. More...
 
void updateButtonStates ()
 
- Protected Member Functions inherited from sofa::component::controller::Controller
 Controller ()
 
 ~Controller () override
 
- Protected Member Functions inherited from sofa::core::objectmodel::BaseObject
 BaseObject ()
 
 ~BaseObject () override
 
virtual void doUpdateInternal ()
 
void changeContextLink (BaseContext *before, BaseContext *&after)
 
void changeSlavesLink (BaseObject::SPtr ptr, std::size_t, bool add)
 
void trackInternalData (const BaseData &data)
 
void cleanTracker ()
 
bool hasDataChanged (const BaseData &data)
 
- Protected Member Functions inherited from sofa::core::objectmodel::Base
 Base ()
 
virtual ~Base ()
 
void initData0 (BaseData *field, BaseData::BaseInitData &res, const char *name, const char *help, bool isDisplayed=true, bool isReadOnly=false)
 
void initData0 (BaseData *field, BaseData::BaseInitData &res, const char *name, const char *help, BaseData::DataFlags dataFlags)
 
void initData0 (Data< T > *field, typename Data< T >::InitData &res, const T &value, const char *name, const char *help, bool isDisplayed=true, bool isReadOnly=false)
 
- Protected Member Functions inherited from sofa::core::IntrusiveObject
virtual ~IntrusiveObject ()=default
 

Additional Inherited Members

- Static Public Member Functions inherited from sofa::core::objectmodel::BaseObject
static bool canCreate (T *, BaseContext *, BaseObjectDescription *)
 
static T::SPtr create (T *, BaseContext *context, BaseObjectDescription *arg)
 
- Static Public Member Functions inherited from sofa::core::objectmodel::Base
static const BaseClassGetClass ()
 
static std::string shortName (const T *ptr=nullptr, BaseObjectDescription *=nullptr)
 

Attribute details

◆ d_angle

Data<type::Vec6> geomagic::GeomagicDriver::d_angle

Angular values of joint (rad)

◆ d_button_1

Data<bool> geomagic::GeomagicDriver::d_button_1

Button state 1.

◆ d_button_2

Data<bool> geomagic::GeomagicDriver::d_button_2

Button state 2.

◆ d_deviceName

Data< std::string > geomagic::GeomagicDriver::d_deviceName

Name of device Configuration.

◆ d_emitButtonEvent

Data<bool> geomagic::GeomagicDriver::d_emitButtonEvent

If true, will send event through the graph when button are pushed/released.

◆ d_forceScale

Data<SReal> geomagic::GeomagicDriver::d_forceScale

Default scaling factor applied to the force feedback.

◆ d_frameVisu

Data<bool> geomagic::GeomagicDriver::d_frameVisu

Visualize the frame corresponding to the device tooltip.

◆ d_inputForceFeedback

Data<Vec3> geomagic::GeomagicDriver::d_inputForceFeedback

Input force feedback in case of no LCPForceFeedback is found (manual setting)

◆ d_manualStart

Data<bool> geomagic::GeomagicDriver::d_manualStart

If true, will not automatically initDevice at component init phase.

◆ d_maxInputForceFeedback

Data<SReal> geomagic::GeomagicDriver::d_maxInputForceFeedback

Maximum value of the normed input force feedback for device security.

◆ d_omniVisu

Data<bool> geomagic::GeomagicDriver::d_omniVisu

Visualize the Geomagic device in the virtual scene.

◆ d_orientationBase

Data<Quat> geomagic::GeomagicDriver::d_orientationBase

Orientation of the device base in the SOFA scene world coordinates.

◆ d_orientationTool

Data<Quat> geomagic::GeomagicDriver::d_orientationTool

Orientation of the tool in the SOFA scene world coordinates.

◆ d_posDevice

Data<Coord> geomagic::GeomagicDriver::d_posDevice

position of the base of the part of the device

◆ d_positionBase

Data<Vec3> geomagic::GeomagicDriver::d_positionBase

Position of the device base in the SOFA scene world coordinates.

◆ d_scale

Data<SReal> geomagic::GeomagicDriver::d_scale

Default scale applied to the Device coordinates.

◆ HD_INVALID_HANDLE

unsigned int geomagic::GeomagicDriver::HD_INVALID_HANDLE = 0

◆ l_forceFeedback

SingleLink<GeomagicDriver, sofa::component::haptics::ForceFeedback, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> geomagic::GeomagicDriver::l_forceFeedback

◆ m_forceFeedback

sofa::component::haptics::ForceFeedback::SPtr geomagic::GeomagicDriver::m_forceFeedback

◆ m_GeomagicVisualModel

std::unique_ptr<GeomagicVisualModel> geomagic::GeomagicDriver::m_GeomagicVisualModel
protected

◆ m_hapticData

DeviceData geomagic::GeomagicDriver::m_hapticData

data structure used by scheduler

◆ m_hHD

SHHD geomagic::GeomagicDriver::m_hHD

ID the device.

◆ m_hStateHandles

std::vector< SHDSchedulerHandle > geomagic::GeomagicDriver::m_hStateHandles

List of ref to the workers scheduled.

◆ m_isInContact

bool geomagic::GeomagicDriver::m_isInContact

Boolean to warn SOFA side when scheduler has computer contact (forcefeedback no null)

◆ m_simuData

DeviceData geomagic::GeomagicDriver::m_simuData

data structure used by SOFA loop, values are copied from

See also
m_hapticData

◆ m_simulationStarted

bool geomagic::GeomagicDriver::m_simulationStarted

Boolean to warn scheduler when SOFA has started the simulation (changed by AnimateBeginEvent)

◆ s_schedulerRunning

bool geomagic::GeomagicDriver::s_schedulerRunning = false
inlinestatic

This static bool is used to know if HD scheduler is already running. No mechanism provided by Hd lib.

Constructor details

◆ GeomagicDriver()

geomagic::GeomagicDriver::GeomagicDriver ( )

◆ ~GeomagicDriver()

geomagic::GeomagicDriver::~GeomagicDriver ( )
virtual

Function details

◆ clearDevice()

void geomagic::GeomagicDriver::clearDevice ( )
virtual

Method to clear scheduler and free device. Called by default at driver destruction.

Reimplemented in geomagic::GeomagicEmulator.

◆ computeBBox()

void geomagic::GeomagicDriver::computeBBox ( const core::ExecParams *  params,
bool  onlyVisible = false 
)
override

◆ draw()

void geomagic::GeomagicDriver::draw ( const sofa::core::visual::VisualParams vparams)
overridevirtual

◆ handleEvent()

void geomagic::GeomagicDriver::handleEvent ( core::objectmodel::Event *  event)
override

◆ init()

void geomagic::GeomagicDriver::init ( void  )
overridevirtual

◆ initDevice()

void geomagic::GeomagicDriver::initDevice ( )
virtual

Public method to init tool. Can be called from thirdparty if.

See also
d_manualStart is set to true

Reimplemented in geomagic::GeomagicEmulator.

◆ SOFA_CLASS()

geomagic::GeomagicDriver::SOFA_CLASS ( GeomagicDriver  ,
Controller   
)

◆ updateButtonStates()

void geomagic::GeomagicDriver::updateButtonStates ( )
protected

Internal method called by

See also
updatePosition() to handle the button status part using as well
m_simuData if
d_emitButtonEvent is set to true, event will be fired by this method if button is pressed or released

◆ updatePosition()

void geomagic::GeomagicDriver::updatePosition ( )
protected

Internal method to update the position of the device in SOFA world using.

See also
m_simuData