3D TOUCH™ SDK
OPENHAPTICS™ TOOLKIT
VERSION 1.0
PROGRAMMER’S GUIDE
Copyright Notice
©2004. SensAble Technologies, Inc. All rights reserved.
Printed in the USA.
Except as permitted by license, no part of this publication may be reproduced, stored in a retrieval
system, or transmitted, in any form or by any means electronic, mechanical, recording or otherwise,
without prior written consent of SensAble Technologies.
Trademarks
FreeForm, FreeForm Concept, FreeForm Modeling, FreeForm Modeling Plus, FreeForm Mold,
GHOST, HapticSound, OpenHaptics, PHANTOM, PHANTOM Desktop, PHANTOM Omni, 3D
Touch, Splodge, SensAble, and SensAble Technologies, Inc. are trademarks or registered
trademarks of SensAble Technologies, Inc. Other brand and product names are trademarks of their
respective holders.
Warranties and Disclaimers
SensAble Technologies does not warrant that this publication is error free. This publication could
include technical or typographical errors or other inaccuracies. SensAble may make changes to the
product described in this publication or to this publication at any time, without notice.
Questions or Comments
If you have any questions for our technical support staff, please contact us at
support@sensable.com. You can also phone 1-888-SENSABL (U.S.A. only) or
1-781-937-8315 (International).
If you have any questions or comments about the documentation, please contact us at
documentation@sensable.com.
Corporate Headquarters
SensAble Technologies, Inc.
15 Constitution Way
Woburn, MA 01801
Phone: 1-888-SENSABL (U.S.A. only) or 1-781-937-8315 (International)
E-mail: support@sensable.com
Internet: http://www.sensable.com
Last Updated - 5 August, 2004 6:33 pm
P/N - 02523 R3
Contents
i
Preface.........................................................................
Introduction ................................................................ 1-1
HDAPI vs. HLAPI .............................................................................. 1-1
Installation .................................................................. 2-1
System Requirements .......................................................................... 2-1
Installing the OpenHaptics Toolkit ..................................................... 2-2
Directory Structure .............................................................................. 2-5
Creating Haptic Environments ................................. 3-1
Introduction to Forces ......................................................................... 3-2
Force Rendering .................................................................................. 3-2
Contact and Constraints ...................................................................... 3-5
Combining Haptics with Graphics ...................................................... 3-6
Combining Haptics with Dynamics .................................................... 3-8
Haptic UI Conventions ........................................................................ 3-9
HDAPI Overview ........................................................ 4-1
Getting Started ..................................................................................... 4-2
The Device .......................................................................................... 4-2
The Scheduler ...................................................................................... 4-3
Developing HDAPI Applications ........................................................ 4-3
Design of Typical HDAPI Program .................................................... 4-6
HDAPI Programming ................................................. 5-1
Haptic Device Operations ................................................................... 5-2
Haptic Frames ..................................................................................... 5-3
Scheduler Operations .......................................................................... 5-4
State ..................................................................................................... 5-7
Calibration Interface .......................................................................... 5-10
Error Reporting and Handling ........................................................... 5-12
Cleanup .............................................................................................. 5-13
HLAPI Overview ......................................................... 6-1
Generating Forces ............................................................................... 6-2
OpenHaptics Toolkit - Programmer’s Guide
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Leveraging OpenGL ............................................................................6-2
Proxy Rendering ..................................................................................6-3
Threading .............................................................................................6-4
Design of Typical HLAPI Program .....................................................6-5
HLAPI Programming ................................................. 7-1
Device Setup ........................................................................................7-2
Rendering Contexts ..............................................................................7-2
Haptic Frames ......................................................................................7-3
Rendering Shapes .................................................................................7-5
Mapping Haptic Device to Graphics Scene .......................................7-16
Drawing a 3D Cursor .........................................................................7-20
Material Properties .............................................................................7-22
Surface Constraints ............................................................................7-24
Effects ................................................................................................7-26
Events .................................................................................................7-28
Calibration ..........................................................................................7-31
Dynamic Objects ................................................................................7-33
Direct Proxy Rendering .....................................................................7-36
Multiple Devices ................................................................................7-37
Extending HLAPI ..............................................................................7-37
Utilities ....................................................................... 8-1
Vector/Matrix Math .............................................................................8-2
Workspace to Camera Mapping ...........................................................8-4
Snap Constraints ..................................................................................8-7
C++ Haptic Device Wrapper ...............................................................8-8
hduError .............................................................................................8-10
hduRecord ..........................................................................................8-10
Haptic Mouse .....................................................................................8-11
Deploying OpenHaptics Applications ..................... 9-1
Troubleshooting ...................................................... 10-1
Device Initialization ...........................................................................10-2
Frames ................................................................................................10-2
Thread Safety .....................................................................................10-3
Race Conditions .................................................................................10-6
Calibration ..........................................................................................10-6
Buzzing ..............................................................................................10-7
Force Kicking ...................................................................................10-12
No Forces .........................................................................................10-15
Device Stuttering ..............................................................................10-15
OpenHaptics Toolkit - Programmer’s Guide
Error Handling ................................................................................. 10-16
Index ........................................................................ A-1
OpenHaptics Toolkit - Programmer’s Guide
OpenHaptics Toolkit - Programmer’s Guide
Preface
This guide explains the SensAble 3D Touch™ SDK OpenHaptics™ toolkit.
This document will introduce you to the architecture of the toolkit, how it
works, and what you can do with it. The guide will also introduce you to the
fundamental components of creating haptic environments and walk you
through installing the toolkit and deploying your haptically enabled
application.
A more recent version of this document may be available for download from
the SensAble online Developer Support Center (DSC). To access the DSC,
visit the SensAble Support page at http://www.sensable.com/support/.
The DSC provides customers with 24 x 7 access to the most current
information and forums for the 3D Touch and GHOST® SDKs. Please note
that you will be asked to create a registration profile and have your customer
information authenticated before you will have access to the DSC.
What is Haptics?
Haptics is the science of incorporating the sense of touch and control into
computer applications through force (kinesthetic) or tactile feedback. By
using special input/output devices—called haptic devices—with a haptically
enabled application, users can feel and manipulate virtual three-dimensional
objects. The type of feedback used to convey the sense of touch is determined
by the type of haptic device being used.
Application areas for haptics are varied and continually expanding. These
include:
•
•
• Military applications such as aerospace and military training and
Surgical simulation and medical training
Painting, sculpting, and CAD
simulation
OpenHaptics Toolkit - Programmer’s Guide
i
PREFACE
• Assistive technology for the blind or visually impaired
•
Simple interaction techniques with the standard user interface such as
opening/closing windows, and interacting with menus
• Gaming
Audience
This guide assumes that the reader has an intermediate to advanced
background in software development, is familiar with the C programming
language, and is somewhat familiar with 3D graphics programming.
Although the core API is C based, some of the utility libraries and the source
code examples use C++. For additional information about haptics, see the
SensAble Developer Support Center.
Typographical Conventions
This guide uses the following typographical conventions:
Convention
Italics
Courier
Note, Warning,
Important
Description
Reference to another
document or file; first use of
a new term.
Identifies code.
Calls out important
additional information.
Identifies a variable such as
a file name or location.
Example
See the Programmer’s
Guide.
hdBeginFrame(hHD);
/OpenHaptics
Important Code snippets included in this document may contain soft or
hard line breaks for formatting purposes.
ii
OpenHaptics Toolkit - Programmer’s Guide