HAPI programming. HAPI overview Device handling Geometry/shape haptics rendering Surface/contact...
-
Upload
julius-jefferson -
Category
Documents
-
view
233 -
download
0
Transcript of HAPI programming. HAPI overview Device handling Geometry/shape haptics rendering Surface/contact...
HAPI programming
HAPI overview
Device handling Geometry/shape haptics rendering Surface/contact handling Force effects
Overview
HAPI
Application
Haptics device drivers
Shapes, effects
Force, torque
Threads Servo thread(~1000Hz)◦ Handles communication with the haptics device.◦ Renders simple primitives and force effects.
Client thread(30-60 Hz)◦ User program.◦ Determines which primitives that should be rendered
haptically.
Threads
Servo thread
Client thread Application
HAPI
Haptic primitives
Force
30-60 Hz
1000 Hz
Device handling Simple device independent interface. AnyHapticsDevice
Device handling functions bool initHapticsDevice()◦ Initialize the device and start the haptics thread.
bool releaseHapticsDevice()◦ Stop the haptics thread and release all resources.
bool enableHapticsDevice()◦ Start sending forces and update state.
bool disableHapticsDevice()◦ Disable force rendering and state updates.
Example
AnyHapticsDevice hd;
if( hd.initDevice() != HAPIHapticsDevice::SUCCESS ) { // handle error } hd.enableDevice();
// main program code ...
hd.disableDevice(); hd.releaseDevice();}
Device functions Calibration(Device space -> world space)◦ setPositionCalibration◦ setOrientationCalibration
Values◦ getDeviceValues◦ getLastDeviceValues◦ getRawDeviceValues◦ getLastRawDeviceValues
Rendering methods Effect rendering◦ free space force effects
Shape rendering◦ touching geometries
Force effects
Examples:◦ Spring, force field, wind, recoil
Haptics device state(pos, vel, orn, buttons) force, torque
Available effects HapticForceField HapticSpring HapticViscosity HapticShapeConstraint HapticPositionFunctionEffect HapticTimeFunctionEffect
Functions void addEffect( HapticForceEffect *effect )◦ Add a haptic effect to render by the haptics device. The effect
will be rendered until removed.
void removeEffect( HapticForceEffect *effect )◦ Remove a haptic effect currently being rendered.
void clearEffects() ◦ Remove all haptic effects currently rendered.
Example AnyHapticsDevice hd;
if( hd.initDevice() != HAPIHapticsDevice::SUCCESS ) { // handle error } hd.enableDevice();
HapticForceField *force_field = new HapticForceField( Vec3( 1, 0, 0 ) ); hd.addEffect( force_field ); hd.transferObjects();
// wait for ENTER string temp_string; cerr << "Press ENTER to exit" << endl; getline( cin, temp_string );
hd.disableDevice(); hd.releaseDevice();
Custom force effect Inherit from HAPIForceEffect◦Override calculateForces method
EffectOutput virtual calculateForces(HAPIHapticsDevice *hd, HAPITime dt ) { return EffectOutput( Vec3( 1, 0, 0 ), Vec3( 1, 0, 0 ) );
}
Shape rendering HapticPrimitive◦ Sphere, Point, Line, Triangle, Plane
HapticTriangleSet HapticLineSet HapticPointSet HapticTriangleTree HapticPrimitiveTree
Shape rendering Surfaces determine the feeling of the object(hardness,
roughness etc)◦ FrictionSurface
Stiffness, damping, static friction, dynamic friction◦ DepthMapSurface(image determines surface depth)◦OpenHapticsSurface(only with OpenHapticsRenderer)
Layers Each layer has a separate renderer. Total force is sum of layers.
Layer 0
Layer 1
Rendering algorithm Internal◦ GodObjectRenderer◦ RuspiniRenderer
External◦OpenHaptics◦ Chai3D
Functions void addShape( HAPIHapticShape *shape,
unsigned int layer = 0 )◦ Render a shape on the given layer.
void removeShape( HAPIHapticShape *shape, unsigned int layer = 0 )◦ Remove a shape currently being rendered.
void clearShapes( unsigned int layer = 0 )◦ Remove all shapes on a layer.
Example AnyHapticsDevice hd;
if( hd.initDevice() != HAPIHapticsDevice::SUCCESS ) { // handle error } hd.enableDevice();
HapticPrimitive *sphere = new HapticPrimitive( new Collision::Sphere( 100 ), new FrictionSurface ); hd.addShape( sphere ); hd.transferObjects();
// wait for ENTER string temp_string; cerr << "Press ENTER to exit" << endl; getline( cin, temp_string );
hd.disableDevice(); hd.releaseDevice();
Custom shapes Inherit from HAPIHapticShape and implement◦ lineIntersectShape◦ getConstraintsOfShape◦movingSphereIntersectShape◦ glRenderShape
Custom surfaces Inherit from HAPISurfaceObject◦ Implement getProxyMovement and getForces functions
FeedbackBufferCollector Uses the OpenGL feedback buffer to get geometric
primitives Example
vector< HAPI::Bounds::Triangle > triangles;
FeedbackBufferCollector::startCollecting();draw();FeedbackBufferCollector::endCollecting( triangles );
Exercise 1
Make a simple program that uses the available shapes to stop the haptics device from going under the y=0 plane.
Exercise 2
Make a simple program that uses the available force effects to lock it into position at position 0,0,0.
Exercise 3
Make a custom force effect that holds the haptics device to the plane y=0.
Exercise 4
Use the FeedbackBufferCollector to render a sphere haptically and graphically.
Exercise 5
Write a custom surface that ...