- Main Page
- Classes
- Files
- Directories

- Class List
- Class Hierarchy
- Class Members

# cGeneric3dofPointer Class Reference

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:

List of all members.

## Public Member Functions
| cGeneric3dofPointer (cWorld *a_world)
| Constructor of cGeneric3dofPointer.
virtual | ~cGeneric3dofPointer ()
| Destructor of cGeneric3dofPointer.
virtual void | render (const int a_renderMode=0)
| Render the object in OpenGL.
virtual void | visualizeFrames (const bool &a_showToolFrame)
| toggle on/off the tool frame
virtual void | setToolFrame (const bool &a_showToolFrame, const double &a_toolFrameSize)
| set the visual settings of the tool frame
virtual void | setRenderingMode (const proxy_render_modes &render_mode)
| Control proxy rendering options.
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 | computeForces ()
| Compute interaction forces with environment.
virtual void | applyForces ()
| Apply latest computed forces to device.
virtual cVector3d | getWorkspaceScaleFactors ()
virtual void | setRadius (const double &a_radius)
| Set radius of pointer.
virtual void | setDevice (cGenericDevice *a_device)
| Set haptic device driver.
virtual cGenericDevice * | getDevice ()
| Get haptic device driver.
virtual cProxyPointForceAlgo * | getProxy ()
| This is a convenience function; it searches the list of force functions for a proxy.
virtual void | setWorkspace (const double &a_workspaceAxisX, const double &a_workspaceAxisY, const double &a_workspaceAxisZ)
| Set virtual workspace dimensions in which tool will be working.
virtual void | useNormalizedPositions (const bool &a_useNormalizedPositions)
| Enable or disable normalized position values (vs. absolute mm) (defaults to true, i.e. normalized).
virtual bool | getNormalizedPositionsEnabled ()
| Are we currently using normalized position values (vs. absolute mm)?
## Public Attributes
cColorf | m_colorDevice
| Color of sphere representing position of device.
cColorf | m_colorProxy
| Color of sphere representing position of tool (proxy).
cColorf | m_colorProxyButtonOn
| Color of sphere representing position of tool (proxy) when switch in ON.
cColorf | m_colorLine
| Color of line connecting proxy and device position together.
cMatrix3d | m_deviceLocalRot
| Orientation of wrist in local coordinates of device.
cMatrix3d | m_deviceGlobalRot
| Orientation of wrist in global coordinates of device.
bool | m_waitForSmallForce
std::vector< cGenericPointForceAlgo * > | m_pointForceAlgos
double | m_halfWorkspaceAxisX
| Width of workspace. Ignored when m_useNormalizedPositions is false.
double | m_halfWorkspaceAxisY
| Height of workspace. Ignored when m_useNormalizedPositions is false.
double | m_halfWorkspaceAxisZ
| Depth of workspace. Ignored when m_useNormalizedPositions is false.
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.
cVector3d | m_lastComputedGlobalForce
cVector3d | m_lastComputedLocalForce
## Protected Attributes
double | m_displayRadius
| Radius of sphere representing position of pointer.
cGenericDevice * | m_device
| haptic device driver.
cWorld * | m_world
| World in which tool is interacting.
bool | m_showToolFrame
| flag for frame visualization of the proxy
double | m_toolFrameSize
| size of the frame visualization of the proxy
proxy_render_modes | m_render_mode
| Should we render the device position, the proxy position, or both?
bool | m_useNormalizedPositions
| Should we be returning normalized (vs. absolute _mm_) positions?
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?)

## 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.

cGeneric3dofPointer::~cGeneric3dofPointer | ( |  | ) | `[virtual]`

Destructor of cGeneric3dofPointer.

Destructor of cGeneric3dofPointer.

## Member Function Documentation

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.

void cGeneric3dofPointer::setToolFrame | ( | const bool & | a_showToolFrame,
|  | const double & | a_toolFrameSize |
| ) |  |  | `[virtual]`

set the visual settings of the tool frame

Toggles on and off the visualization of a reference frame located on the tool's point.

Parameters:

  | a_showToolFrame | Flag which controls the tool frame display.
  | a_toolFrameSize | Size of the tool frame.

virtual void cGeneric3dofPointer::setRenderingMode | ( | const proxy_render_modes & | render_mode | ) | `[inline, virtual]`

Control proxy rendering options.

Set to RENDER_PROXY, RENDER_DEVICE, or RENDER_PROXY_AND_DEVICE

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.

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.

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

Toggle forces on.

Turns forces ON

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

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.

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

Update position and orientation of the device.

Update position of pointer and orientation of wrist.

Reimplemented from cGenericTool.

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

Compute interaction forces with environment.

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

Reimplemented from cGenericTool.

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

Apply latest computed forces to device.

Apply the latest computed force to the device.

Reimplemented from cGenericTool.

cVector3d cGeneric3dofPointer::getWorkspaceScaleFactors | ( |  | ) | `[virtual]`

Returns scale factors from normalized coordinates to millimeters. I.e., if you take pointer position and multiply by these values, you get millimeters.

If a device does not provide this information, zeros are returned.

By default, cGeneric3dofPointer accesses the _normalized_ device position; this lets you convert back to absolute coordinates.

Returns:
  Scale factors: coordinates * scale = mm

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::setDevice | ( | cGenericDevice * | a_device | ) | `[virtual]`

Set haptic device driver.

Define a haptic device driver for this tool.

Parameters:

  | a_device | This is the device that should be associated with this tool.

cProxyPointForceAlgo * cGeneric3dofPointer::getProxy | ( |  | ) | `[virtual]`

This is a convenience function; it searches the list of force functions for a proxy.

This function searches the vector of point force algorithms and returns the first proxy (instance of cProxyPointForceAlgo) that it can find. If it does not find any, it returns NULL. By default, a proxy was entered into this list in the constructor, so it should return this default proxy unless you have removed it.

This is a convenience function. If you want to find all the available proxies or all the available force-rendering algorithms, you should search the m_pointForceAlgos list.

void cGeneric3dofPointer::setWorkspace | ( | const double & | a_width,
|  | const double & | a_height,
|  | const double & | a_depth |
| ) |  |  | `[virtual]`

Set virtual workspace dimensions in which tool will be working.

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

Normalized coordinates received from the device (ranging from -1.0 --> 1.0) are multiplied by half of the workspace edges to get the values that are used to position the pointer.

Parameters:

  | a_width | Width of workspace.
  | a_height | Height of workspace.
  | a_depth | Depth of workspace.

## Member Data Documentation

bool cGeneric3dofPointer::m_waitForSmallForce

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

std::vector<cGenericPointForceAlgo*> cGeneric3dofPointer::m_pointForceAlgos

Vector of force algorithms. By default, a proxy algorithm object and a potential field object are added to this list (in that order).

When a tool is asked to compute forces, it walks this list and asks each algorithm to compute its forces.

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)

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

- chai3d/src/tools/CGeneric3dofPointer.h
- chai3d/src/tools/CGeneric3dofPointer.cpp