SensAble.cpp File Reference

#include <stdio.h>
#include <assert.h>
#include <sofa/helper/system/gl.h>
#include <sofa/helper/system/glut.h>
#include <HD/hd.h>
#include <HDU/hduVector.h>
#include <HDU/hduError.h>
#include "SensAble.h"
#include <sofa/simulation/tree/GNode.h>
#include <sofa/simulation/common/MechanicalVisitor.h>
#include <sofa/simulation/common/UpdateMappingVisitor.h>
#include <sofa/core/objectmodel/KeypressedEvent.h>
#include <sofa/core/objectmodel/KeyreleasedEvent.h>
#include <sofa/core/ObjectFactory.h>

Include dependency graph for SensAble.cpp:

Go to the source code of this file.

Data Structures

struct  DeviceData
 Holds data retrieved from HDAPI. More...

Functions

HDCallbackCode HDCALLBACK SetForceCallback (void *pUserData)
HDCallbackCode HDCALLBACK applyForceCallback (void *)
 This routine allows the device to provide information about the current location of the stylus, and contains a mechanism for terminating the application.
HDCallbackCode HDCALLBACK updateDeviceCallback (void *)
 Checks the state of the gimbal button and gets the position of the device.
HDCallbackCode HDCALLBACK copyDeviceDataCallback (void *pUserData)
 Copies the state of the gimbal button and the position of the device.
int initDevice ()
 Sets up the device, runs main application loop, cleans up when finished.
int uninitDevice ()
 Performs cleanup, unschedules callbacks and stops the servo loop.
void getData ()
 gets the latest data

Variables

int SensAbleClass
static DeviceData gServoDeviceData
static DeviceData deviceData
static HDSchedulerHandle hUpdateHandle = 0
static HDSchedulerHandle hCallbackHandle = 0
static HHD hHD
HDErrorInfo error
static volatile HDboolean bRenderForce = false
static hduVector3Dd force
static volatile HDboolean bRenderPivot = false
static Vec3d devicePivot
bool isInitialized = false


Function Documentation

HDCallbackCode HDCALLBACK applyForceCallback ( void *   ) 

This routine allows the device to provide information about the current location of the stylus, and contains a mechanism for terminating the application.

Pressing the button causes the application to display the current location of the device. Holding the button down for N iterations causes the application to exit.

Definition at line 557 of file SensAble.cpp.

References bRenderForce, bRenderPivot, dot(), force, sofa::helper::Quater< Real >::fromMatrix(), DeviceData::m_buttonState1, DeviceData::m_buttonState2, DeviceData::m_devicePosition, DeviceData::m_error, sofa::defaulttype::Vec< N, real >::norm(), sofa::defaulttype::Vec< N, real >::normalize(), DeviceData::nupdates, DeviceData::quat, and DeviceData::transform.

Referenced by initDevice().

HDCallbackCode HDCALLBACK copyDeviceDataCallback ( void *  pUserData  ) 

Copies the state of the gimbal button and the position of the device.

Definition at line 114 of file SensAble.cpp.

References sofa::helper::Quater< Real >::normalize(), DeviceData::nupdates, and DeviceData::quat.

Referenced by getData().

void getData (  ) 

gets the latest data

Definition at line 179 of file SensAble.cpp.

References copyDeviceDataCallback().

Referenced by SensAble::draw().

int initDevice (  ) 

Sets up the device, runs main application loop, cleans up when finished.

Definition at line 131 of file SensAble.cpp.

References applyForceCallback(), error, hCallbackHandle, hHD, DeviceData::quat, and DeviceData::transform.

Referenced by SensAble::SensAble().

HDCallbackCode HDCALLBACK SetForceCallback ( void *  pUserData  ) 

Definition at line 723 of file SensAble.cpp.

References force.

Referenced by SensAble::updatePosition().

int uninitDevice (  ) 

Performs cleanup, unschedules callbacks and stops the servo loop.

Definition at line 168 of file SensAble.cpp.

References hCallbackHandle, and hHD.

HDCallbackCode HDCALLBACK updateDeviceCallback ( void *   ) 

Checks the state of the gimbal button and gets the position of the device.

Definition at line 89 of file SensAble.cpp.

References DeviceData::m_buttonState1, DeviceData::m_buttonState2, DeviceData::m_devicePosition, DeviceData::m_error, and DeviceData::transform.


Variable Documentation

volatile HDboolean bRenderForce = false [static]

volatile HDboolean bRenderPivot = false [static]

Definition at line 79 of file SensAble.cpp.

Referenced by applyForceCallback(), SensAble::draw(), and SensAble::handleEvent().

Definition at line 69 of file SensAble.cpp.

Vec3d devicePivot [static]

Definition at line 80 of file SensAble.cpp.

HDErrorInfo error

hduVector3Dd force [static]

Definition at line 78 of file SensAble.cpp.

Referenced by sofa::component::forcefield::BeamFEMForceField< DataTypes >::accumulateForceLarge(), sofa::core::ObjectFactory::AddAlias(), sofa::component::forcefield::TriangularTensorMassForceField< DataTypes >::addDForce(), sofa::component::forcefield::TetrahedralTensorMassForceField< DataTypes >::addDForce(), sofa::component::forcefield::PenalityContactForceField< CudaVec3fTypes >::addForce(), sofa::component::interactionforcefield::RepulsiveSpringForceField< DataTypes >::addForce(), sofa::component::forcefield::VectorSpringForceField< DataTypes >::addForce(), sofa::component::forcefield::TriangularTensorMassForceField< DataTypes >::addForce(), sofa::component::forcefield::TriangularQuadraticSpringsForceField< DataTypes >::addForce(), sofa::component::forcefield::TriangularBiquadraticSpringsForceField< DataTypes >::addForce(), sofa::component::forcefield::TriangularBendingSprings< DataTypes >::addForce(), sofa::component::forcefield::TrianglePressureForceField< DataTypes >::addForce(), sofa::component::forcefield::TetrahedralTensorMassForceField< DataTypes >::addForce(), sofa::component::forcefield::SpringEdgeDataForceField< DataTypes >::addForce(), sofa::component::forcefield::SphereForceField< DataTypes >::addForce(), sofa::component::forcefield::QuadularBendingSprings< DataTypes >::addForce(), sofa::component::forcefield::PlaneForceField< DataTypes >::addForce(), sofa::component::forcefield::PenalityContactForceField< DataTypes >::addForce(), sofa::component::forcefield::LennardJonesForceField< DataTypes >::addForce(), sofa::component::forcefield::EllipsoidForceField< DataTypes >::addForce(), sofa::component::forcefield::EdgePressureForceField< DataTypes >::addForce(), sofa::component::forcefield::ConicalForceField< DataTypes >::addForce(), sofa::component::forcefield::StiffSpringForceField< DataTypes >::addSpringForce(), sofa::component::forcefield::SpringForceField< DataTypes >::addSpringForce(), sofa::component::forcefield::JointSpringForceField< DataTypes >::addSpringForce(), sofa::component::constraint::UncoupledConstraintCorrection< TDataTypes >::applyContactForce(), sofa::component::constraint::PrecomputedConstraintCorrection< TDataTypes >::applyContactForce(), sofa::component::constraint::LinearSolverConstraintCorrection< TDataTypes >::applyContactForce(), applyForceCallback(), sofa::component::interactionforcefield::InteractionEllipsoidForceField< DataTypes1, DataTypes2 >::calcF(), sofa::component::odesolver::EulerKaapiSolver::computeAcc(), sofa::component::controller::LCPForceFeedback::computeForce(), sofa::component::constraint::PrecomputedConstraintCorrection< TDataTypes >::init(), sofa::component::constraint::UncoupledConstraintCorrection< TDataTypes >::resetContactForce(), sofa::component::constraint::PrecomputedConstraintCorrection< TDataTypes >::resetContactForce(), sofa::component::constraint::LinearSolverConstraintCorrection< TDataTypes >::resetContactForce(), SetForceCallback(), and SensAble::updatePosition().

Definition at line 68 of file SensAble.cpp.

HDSchedulerHandle hCallbackHandle = 0 [static]

Definition at line 71 of file SensAble.cpp.

Referenced by initDevice(), and uninitDevice().

HHD hHD [static]

Definition at line 72 of file SensAble.cpp.

Referenced by initDevice(), and uninitDevice().

HDSchedulerHandle hUpdateHandle = 0 [static]

Definition at line 70 of file SensAble.cpp.

Definition at line 126 of file SensAble.cpp.

Initial value:

 sofa::core::RegisterObject("Phantom device")
.add< SensAble >()

Definition at line 54 of file SensAble.cpp.


Generated on Sun Nov 23 04:05:58 2008 for Sofa by  doxygen 1.5.7.1