v_repExtCHAI3D.cpp File Reference
#include <algorithm>
#include <iostream>
#include "v_repExtCHAI3D.h"
#include "luaFunctionData.h"
#include "v_repLib.h"
#include "chai3d.h"

Classes

struct  State
 Data structure that contains an object state. More...
 
struct  Device
 Data structure that contains a haptic device handle and related state information. More...
 
class  Object
 Data structure that contains an object of type ObjectType used to generate haptic feedback. More...
 

Macros

#define PLUGIN_VERSION   1
 
#define CONCAT(x, y, z)   x y z
 
#define strConCat(x, y, z)   CONCAT(x,y,z)
 
#define LUA_START_COMMAND   "simExtCHAI3D_start"
 
#define LUA_RESET_COMMAND   "simExtCHAI3D_reset"
 
#define LUA_ADD_SHAPE_COMMAND   "simExtCHAI3D_addShape"
 
#define LUA_ADD_CONSTRAINT_POINT_COMMAND   "simExtCHAI3D_addConstraintPoint"
 
#define LUA_ADD_CONSTRAINT_SEGMENT_COMMAND   "simExtCHAI3D_addConstraintSegment"
 
#define LUA_ADD_CONSTRAINT_PLANE_COMMAND   "simExtCHAI3D_addConstraintPlane"
 
#define LUA_UPDATE_SHAPE_COMMAND   "simExtCHAI3D_updateShape"
 
#define LUA_UPDATE_CONSTRAINT_COMMAND   "simExtCHAI3D_updateConstraint"
 
#define LUA_REMOVE_OBJECT_COMMAND   "simExtCHAI3D_removeObject"
 
#define LUA_READ_POSITION_COMMAND   "simExtCHAI3D_readPosition"
 
#define LUA_READ_FORCE_COMMAND   "simExtCHAI3D_readForce"
 
#define LUA_READ_BUTTONS_COMMAND   "simExtCHAI3D_readButtons"
 

Enumerations

enum  ObjectType { SHAPE, CONSTRAINT_POINT, CONSTRAINT_SEGMENT, CONSTRAINT_PLANE }
 Types of haptic objects. More...
 

Functions

int addObject (Object *object)
 Add generic object to the scene. More...
 
bool updateShape (int objectID, float pos[3], float rot[3], float stiffnessFactor)
 Update the parameters of a SHAPE haptic object. More...
 
bool updateConstraint (int objectID, float pos[3], float dir[3], float Kp, float Kv, float Fmax)
 Update the parameters of a constraint haptic object. More...
 
bool removeObject (int objectID)
 Safely remove an object from the object list. More...
 
bool removeObject (Object *object)
 Safely remove an object from the object list. More...
 
void hapticLoop ()
 Main haptic loop. More...
 
void hapticStart ()
 Start the haptic loop. More...
 
void hapticStop ()
 Stop the haptic loop. More...
 
bool hapticConnect (int deviceIndex, float toolRadius, float workspaceRadius)
 
bool hapticDisconnect (int index)
 Disconnect from haptic device. More...
 
void hapticReset ()
 Clean up the scene. More...
 
void LUA_START_CALLBACK (SLuaCallBack *p)
 Connect to a haptic device. More...
 
void LUA_RESET_CALLBACK (SLuaCallBack *p)
 Disconnect from a haptic device and reset the scene. More...
 
void LUA_ADD_SHAPE_CALLBACK (SLuaCallBack *p)
 Add a SHAPE object to the scene. More...
 
void LUA_ADD_CONSTRAINT_POINT_CALLBACK (SLuaCallBack *p)
 Add a CONSTRAINT_POINT object to the scene. More...
 
void LUA_ADD_CONSTRAINT_SEGMENT_CALLBACK (SLuaCallBack *p)
 Add a CONSTRAINT_SEGMENT object to the scene. More...
 
void LUA_ADD_CONSTRAINT_PLANE_CALLBACK (SLuaCallBack *p)
 Add a CONSTRAINT_PLANE object to the scene. More...
 
void LUA_UPDATE_SHAPE_CALLBACK (SLuaCallBack *p)
 Update the parameters of a SHAPE haptic object. More...
 
void LUA_UPDATE_CONSTRAINT_CALLBACK (SLuaCallBack *p)
 Update the parameters of a constraint haptic object. More...
 
void LUA_REMOVE_OBJECT_CALLBACK (SLuaCallBack *p)
 Safely remove an object from the object list. More...
 
void LUA_READ_POSITION_CALLBACK (SLuaCallBack *p)
 Retrieve the current position of a haptic device (identified by its deviceIndex) in the scene. More...
 
void LUA_READ_FORCE_CALLBACK (SLuaCallBack *p)
 Retrieve the force currently displayed by a haptic device (identified by its deviceIndex). More...
 
void LUA_READ_BUTTONS_CALLBACK (SLuaCallBack *p)
 Retrieve a haptic device (identified by its deviceIndex) end-effector buttons status. More...
 
VREP_DLLEXPORT unsigned char v_repStart (void *reservedPointer, int reservedInt)
 V-REP shared library initialization. More...
 
VREP_DLLEXPORT void v_repEnd ()
 V-REP shared library disconnect. More...
 
VREP_DLLEXPORT void * v_repMessage (int message, int *auxiliaryData, void *customData, int *replyData)
 V-REP shared library message processing callback. More...
 

Variables

bool SimulationRunning
 Haptic thread control flag. More...
 
cThread * HapticThread
 Haptic thread handle. More...
 
cMutex * SimulationLock
 Haptic thread stop synchronization lock. More...
 
cMutex * SceneLock
 Haptic scene synchronization lock. More...
 
cMutex * ObjectLock
 Haptic objects synchronization lock. More...
 
vector< Object * > Objects
 Haptic objects list. More...
 
cHapticDeviceHandler * DeviceHandler
 CHAI3D haptic device handler. More...
 
cWorld * World
 Haptic scene container. More...
 
map< int, cGenericHapticDevicePtr > Devices
 CHAI3D haptic device list. More...
 
map< int, Device * > Cursors
 Haptic device list. More...
 
cPrecisionClock Clock
 
double BiggestRadius = 0.0
 
double LowestStiffness = -1.0
 
LIBRARY vrepLib
 
const int inArgs_START []
 
const int inArgs_RESET []
 
const int inArgs_ADD_SHAPE []
 
const int inArgs_ADD_CONSTRAINT_POINT []
 
const int inArgs_ADD_CONSTRAINT_SEGMENT []
 
const int inArgs_ADD_CONSTRAINT_PLANE []
 
const int inArgs_UPDATE_SHAPE []
 
const int inArgs_UPDATE_CONSTRAINT []
 
const int inArgs_REMOVE_OBJECT []
 
const int inArgs_READ_POSITION []
 
const int inArgs_READ_FORCE []
 
const int inArgs_READ_BUTTONS []
 

Macro Definition Documentation

#define PLUGIN_VERSION   1