# cGenericHapticDevice Class Reference
[Devices]

cGenericHapticDevice describes a virtual class from which all 2D or 3D point contact haptic devices are derived. These include for instance the delta.x, omega.x or Phantom haptic devices. More...

`#include <CGenericHapticDevice.h>`

Inheritance diagram for cGenericHapticDevice:

[legend]

List of all members.

## Public Member Functions
| cGenericHapticDevice ()
| Constructor of cGenericHapticDevice.
virtual | ~cGenericHapticDevice ()
| Destructor of cGenericHapticDevice.
virtual int | open ()
| Open connection to haptic device (0 indicates success).
virtual int | close ()
| Close connection to haptic device (0 indicates success).
virtual int | initialize (const bool a_resetEncoders=false)
| Initialize or calibrate haptic device (0 indicates success).
virtual int | command (int a_command, void *a_data)
| Send a generic command to the haptic device (0 indicates success).
virtual int | getPosition (cVector3d &a_position)
| Read the position of the device. Units are meters [m].
virtual int | getLinearVelocity (cVector3d &a_linearVelocity)
| Read the linear velocity of the device. Units are meters per second [m/s].
virtual int | getRotation (cMatrix3d &a_rotation)
| Read the orientation frame of the device end-effector.
virtual int | getAngularVelocity (cVector3d &a_angularVelocity)
| Read the angular velocity of the device. Units are in radians per second [m/s].
virtual int | getGripperAngleRad (double &a_angle)
| Read the gripper angle in radian.
virtual int | getGripperVelocity (double &a_gripperVelocity)
| Read the angular velocity of the gripper. Units are in radians per second [m/s].
virtual int | setForce (cVector3d &a_force)
| Send a force [N] to the haptic device.
virtual int | getForce (cVector3d &a_force)
| Read a sensed force [N] from the haptic device.
virtual int | setTorque (cVector3d &a_torque)
| Send a torque [N*m] to the haptic device.
virtual int | getTorque (cVector3d &a_torque)
| Read a sensed torque [N*m] from the haptic device.
virtual int | setGripperTorque (double a_gripperTorque)
| Send a torque [N*m] to the gripper.
virtual int | getGripperTorque (double a_gripperTorque)
| Read a sensed torque [N*m] from the gripper.
virtual int | setForceAndTorqueAndGripper (cVector3d &a_force, cVector3d &a_torque, double a_gripperTorque)
| Send a force [N], a torque [N*m] and a gripper torque [N*m] to the haptic device.
virtual int | getUserSwitch (int a_switchIndex, bool &a_status)
| read the status of the user switch [true = ON / false = OFF].
cHapticDeviceInfo | getSpecifications ()
| Get the specifications of the current device.
## Protected Member Functions
void | estimateLinearVelocity (cVector3d &a_newPosition)
| Estimate the linear velocity by passing the latest position.
void | estimateAngularVelocity (cMatrix3d &a_newRotation)
| Estimate the angular velocity by passing the latest orientation frame.
void | estimateGripperVelocity (double a_newGripperPosition)
| Estimate the velocity of the gripper by passing the latest gripper position.
## Protected Attributes
cHapticDeviceInfo | m_specifications
| Technical specifications of the current haptic device.
cVector3d | m_prevForce
| Previous sent force to the haptic device.
cVector3d | m_prevTorque
| Previous sent torque to the haptic device.
double | m_prevGripperTorque
| Previous sent gripper torque to the haptic device.
cVector3d | m_linearVelocity
| Last estimated linear velocity.
cVector3d | m_angularVelocity
| Last estimated angular velocity.
double | m_gripperVelocity
| Last estimated gripper velocity.
cTimestampPos | m_historyPos [CHAI_DEVICE_HISTORY_SIZE]
| History position data of the device.
cTimestampRot | m_historyRot [CHAI_DEVICE_HISTORY_SIZE]
| History orientation data of the device.
cTimestampValue | m_historyGripper [CHAI_DEVICE_HISTORY_SIZE]
| History position of the device gripper.
int | m_indexHistoryPos
| Current index position in History data table.
int | m_indexHistoryRot
| Current index position in History data table.
int | m_indexHistoryGripper
| Current index position in History data table.
int | m_indexHistoryPosWin
| Last index position used to compute velocity.
int | m_indexHistoryRotWin
| Last index position used to compute velocity.
int | m_indexHistoryGripperWin
| Last index position used to compute velocity.
double | m_linearVelocityWindowSize
| Window time interval for measuring linear velocity.
double | m_angularVelocityWindowSize
| Window time interval for measuring angular velocity.
double | m_gripperVelocityWindowSize
| Window time interval for measuring gripper velocity.
cPrecisionClock | m_clockGeneral
| General clock when the device was started.

## Detailed Description

cGenericHapticDevice describes a virtual class from which all 2D or 3D point contact haptic devices are derived. These include for instance the delta.x, omega.x or Phantom haptic devices.

## Constructor & Destructor Documentation

cGenericHapticDevice::cGenericHapticDevice | ( |  | ) |

Constructor of cGenericHapticDevice.

Constructor of cGenericHapticDevice. Initialize basic parameters of generic haptic device.

## Member Function Documentation

int cGenericHapticDevice::command | ( | int | a_command,
|  | void * | a_data |
| ) |  |  | `[virtual]`

Send a generic command to the haptic device (0 indicates success).

Set command for the haptic device

Parameters:

  | a_command | Selected command.
  | a_data | Pointer to the corresponding data structure.

Returns:
  Return status of command.

Reimplemented from cGenericDevice.

void cGenericHapticDevice::estimateAngularVelocity | ( | cMatrix3d & | a_newRotation | ) | `[protected]`

Estimate the angular velocity by passing the latest orientation frame.

Estimate the angular velocity by passing the latest orientation frame.

Parameters:

  | a_newRotation | New orientation frame of the device.

void cGenericHapticDevice::estimateGripperVelocity | ( | double | a_newGripperPosition | ) | `[protected]`

Estimate the velocity of the gripper by passing the latest gripper position.

Estimate the velocity of the gripper by passing the latest gripper position.

Parameters:

  | a_newGripperPosition | New position of the gripper.

void cGenericHapticDevice::estimateLinearVelocity | ( | cVector3d & | a_newPosition | ) | `[protected]`

Estimate the linear velocity by passing the latest position.

Estimate the linear velocity by passing the latest position.

Parameters:

  | a_newPosition | New position of the device.

Returns:
  Return 0 if no error occurred.

int cGenericHapticDevice::setForceAndTorqueAndGripper | ( | cVector3d & | a_force,
|  | cVector3d & | a_torque,
|  | double | a_gripperTorque |
| ) |  |  | `[virtual]`

Send a force [N], a torque [N*m] and a gripper torque [N*m] to the haptic device.

Send a force [N] and a torque [N*m] and gripper force [N] to the haptic device.

Parameters:

  | a_force | Force command.
  | a_torque | Torque command.
  | a_gripperTorque | Gripper torque command.

Returns:
  Return 0 if no error occurred.

Reimplemented in cDeltaDevice, cFreedom6SDevice, and cMyCustomDevice.

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

- D:/CHAI3D/build-2-0-0/2.0.0/win32/src/devices/CGenericHapticDevice.h
- D:/CHAI3D/build-2-0-0/2.0.0/win32/src/devices/CGenericHapticDevice.cpp

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