# cGeneric3dofPointer Class Reference
[Haptic Tools]

cGeneric3dofPointer represents a haptic tool that can apply forces in three degrees of freedom and maintains three or six degrees of device pose.
More...

`#include <CGeneric3dofPointer.h>`

Inheritance diagram for cGeneric3dofPointer:

[legend]

List of all members.

## Public Member Functions
| cGeneric3dofPointer (cWorld *a_world)
| Constructor of cGeneric3dofPointer.
virtual | ~cGeneric3dofPointer ()
| Destructor of cGeneric3dofPointer.
virtual int | start ()
| Start communication with the device connected to the tool (0 indicates success).
virtual int | stop ()
| Stop communication with the device connected to the tool (0 indicates success).
virtual int | initialize (const bool a_resetEncoders=false)
| Initialize the device connected to the tool (0 indicates success).
virtual int | setForcesON ()
| Toggle forces ON.
virtual int | setForcesOFF ()
| Toggle forces OFF.
virtual void | updatePose ()
| Update position and orientation of the device.
virtual void | computeInteractionForces ()
| Compute interaction forces with environment.
virtual void | applyForces ()
| Apply latest computed forces to device.
virtual cProxyPointForceAlgo * | getProxy ()
| Get a pointer to the proxy force algorithm.
virtual bool | isInContact (cGenericObject *a_object)
| Check if the tool is touching a particular object.
virtual cVector3d | getProxyGlobalPos ()
| Read position of proxy in global world coordinates.
virtual cMatrix3d | getProxyGlobalRot ()
| Read orientation of proxy in global world coordinates.
virtual cVector3d | getDeviceGlobalPos ()
| Read position of haptic device in global world coordinates.
virtual cMatrix3d | getDeviceGlobalRot ()
| Read orientation of haptic device in global world coordinates.
virtual cVector3d | getDeviceLocalPos ()
| Read position of haptic device in local coordinates.
virtual cMatrix3d | getDeviceLocalRot ()
| Read orientation of haptic device in local coordinates.
virtual void | setRadius (const double &a_radius)
| Set radius of pointer.
virtual void | setWorkspaceRadius (const double &a_workspaceRadius)
| Set virtual workspace dimensions in which tool will be working.
double | getWorkspaceRadius ()
| Read the radius of the workspace of the tool.
void | setWorkspaceScaleFactor (const double &a_workspaceScaleFactor)
| Set the scale factor between the workspace of the tool and one of the haptic device.
double | getWorkspaceScaleFactor ()
| Read the scale factor between the workspace of the tool and one of the haptic device.
virtual void | render (const int a_renderMode=0)
| Render the object in OpenGL.
## Public Attributes
cShapeSphere * | m_deviceSphere
| Sphere representing the device.
cShapeSphere * | m_proxySphere
| Sphere representing the proxy.
cMesh * | m_deviceMesh
| Mesh representing the device.
cMesh * | m_proxyMesh
| Mesh representing the proxy.
cColorf | m_colorLine
| Color of line connecting proxy and device position together.
cMaterial | m_materialProxy
| Material properties of proxy.
cMaterial | m_materialProxyButtonPressed
| Material properties of proxy when button is pressed.
cProxyPointForceAlgo * | m_proxyPointForceModel
| Finger-proxy algorithm model to handle interactions with mesh objects.
cPotentialFieldForceAlgo * | m_potentialFieldsForceModel
| Potential fields model.
cVector3d | m_lastComputedGlobalForce
cVector3d | m_lastComputedLocalForce
double | m_workspaceRadius
| Radius of the workspace which can be accessed by the tool.
double | m_workspaceScaleFactor
| Scale factor between the sizes of the tool workspace and the haptic device workspace.
cVector3d | m_deviceLocalPos
| Position of device in device local coordinate system.
cVector3d | m_deviceGlobalPos
| Position of device in world global coordinate system.
cVector3d | m_deviceLocalVel
| Velocity of device in device local coordinate system.
cVector3d | m_deviceGlobalVel
| Velocity of device in world global coordinate system.
cMatrix3d | m_deviceLocalRot
| Orientation of wrist in local coordinates of device.
cMatrix3d | m_deviceGlobalRot
| Orientation of wrist in global coordinates of device.
## Protected Attributes
cWorld * | m_world
| World in which tool is interacting.
double | m_displayRadius
| Radius of sphere representing position of pointer.
bool | m_userSwitch0
| Last status of user switch 0. This value is used by the graphical rendering function.
bool | m_forceON
| This flag records whether the user has enabled forces.
bool | m_forceStarted
| Flag to avoid initial bumps in force (has the user sent a _small_ force yet?).
bool | m_waitForSmallForce

## Detailed Description

cGeneric3dofPointer represents a haptic tool that can apply forces in three degrees of freedom and maintains three or six degrees of device pose.

This class provides i/o with haptic devices and a basic graphical representation of a tool.

## Constructor & Destructor Documentation

cGeneric3dofPointer::cGeneric3dofPointer | ( | cWorld * | a_world | ) |

Constructor of cGeneric3dofPointer.

Constructor of cGeneric3dofPointer.

Parameters:

  | a_world | World in which the tool will operate.

## Member Function Documentation

void cGeneric3dofPointer::applyForces | ( |  | ) | `[virtual]`

Apply latest computed forces to device.

Apply the latest computed force to the device.

Reimplemented from cGenericTool.

void cGeneric3dofPointer::computeInteractionForces | ( |  | ) | `[virtual]`

Compute interaction forces with environment.

Compute the interaction forces between the tool and the virtual object inside the virtual world.

Reimplemented from cGenericTool.

int cGeneric3dofPointer::initialize | ( | const bool | a_resetEncoders = `false` | ) | `[virtual]`

Initialize the device connected to the tool (0 indicates success).

Initialize device

Parameters:

  | a_resetEncoders | If true, this resets the device's 0 position to the current position (if this device supports re-zero'ing). That means that if your device supports re-zero'ing (e.g. Phantom premiums), you should be careful about calling this function in the middle of your program with a_resetEncoders set to 'true'. Or if you do call it with a_resetEncoders set to true, you should make sure your user knows to hold the Phantom in place.

Returns:
  0 indicates success, non-zero indicates an error

Reimplemented from cGenericTool.

bool cGeneric3dofPointer::isInContact | ( | cGenericObject * | a_object | ) | `[virtual]`

Check if the tool is touching a particular object.

Check if the tool is currently interacting with the given object.

Returns:
  Return true if the tool is interacting with the object

Reimplemented from cGenericTool.

void cGeneric3dofPointer::render | ( | const int | a_renderMode = `0` | ) | `[virtual]`

Render the object in OpenGL.

Render the current tool in OpenGL.

Parameters:

  | a_renderMode | rendering mode; see cGenericObject.cpp.

Reimplemented from cGenericTool.

int cGeneric3dofPointer::setForcesOFF | ( |  | ) | `[virtual]`

Toggle forces OFF.

Turns forces OFF.

Returns:
  0 indicates success, non-zero indicates an error

Reimplemented from cGenericTool.

int cGeneric3dofPointer::setForcesON | ( |  | ) | `[virtual]`

Toggle forces ON.

Turns forces ON.

Returns:
  0 indicates success, non-zero indicates an error

Reimplemented from cGenericTool.

void cGeneric3dofPointer::setRadius | ( | const double & | a_radius | ) | `[virtual]`

Set radius of pointer.

Set the radius of the proxy. The value passed as parameter corresponds to the size of the sphere which is rendered graphically. The physical size of the proxy, one which collides with the triangles is set to CHAI_SCALE_PROXY_RADIUS * a_radius.

Parameters:

  | a_radius | radius of pointer.

void cGeneric3dofPointer::setWorkspaceRadius | ( | const double & | a_workspaceRadius | ) | `[virtual]`

Set virtual workspace dimensions in which tool will be working.

Sets the virtual volume in which the virtual tool will be moving.

Parameters:

  | a_workspaceRadius | Radius of the workspace.

void cGeneric3dofPointer::setWorkspaceScaleFactor | ( | const double & | a_workspaceScaleFactor | ) |

Set the scale factor between the workspace of the tool and one of the haptic device.

Define a scale factor between the physical workspace of the haptic device and the workspace span by the virtual tool.

Parameters:

  | a_workspaceScaleFactor | Workspace scale factor.

int cGeneric3dofPointer::start | ( |  | ) | `[virtual]`

Start communication with the device connected to the tool (0 indicates success).

Starts communication with the haptic device.

Returns:
  0 indicates success, non-zero indicates an error

Reimplemented from cGenericTool.

int cGeneric3dofPointer::stop | ( |  | ) | `[virtual]`

Stop communication with the device connected to the tool (0 indicates success).

Stop system. Apply zero force to device

Returns:
  0 indicates success, non-zero indicates an error

Reimplemented from cGenericTool.

void cGeneric3dofPointer::updatePose | ( |  | ) | `[virtual]`

Update position and orientation of the device.

Update position of pointer and orientation of wrist.

Reimplemented from cGenericTool.

## Member Data Documentation

cVector3d cGeneric3dofPointer::m_lastComputedGlobalForce

The last force computed for application to this tool, in the world coordinate system. [N]

If you want to manually send forces to a device, you can modify this value before calling 'applyForces'.

cVector3d cGeneric3dofPointer::m_lastComputedLocalForce

The last force computed for application to this tool, in the device coordinate. system. [N]

bool cGeneric3dofPointer::m_waitForSmallForce`[protected]`

Normally this class waits for a very small force before initializing forces to avoid initial "jerks" (a safety feature); you can bypass that requirement with this variable.

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

- D:/CHAI3D/build-2-0-0/2.0.0/win32/src/tools/CGeneric3dofPointer.h
- D:/CHAI3D/build-2-0-0/2.0.0/win32/src/tools/CGeneric3dofPointer.cpp

CHAI3D 2.0.0 documentation
Please address any questions to support@chai3d.org
(C) 2003-2009 - CHAI 3D
All Rights Reserved.