Tuesday, April 19, 2005

Callbacks and the Scheduler -- From a HDAPI viewpoint

The Scheduler is the thread controlling the haptic device. This is the main interface and runs at 1000Hz. Queries such as position or state must be accessed by calls to the scheduler. The scheduler allows get and set operations to many hardware variables, i.e. position or force.

The HD requires creating CallBacks to be run on the scheduler. Some Events are predefined, but the custom functions can also be passed to the scheduler. The CallBacks can be sent to run every frame, scheduled by the programmer, or triggered by predefined events.

  • Asynchronous -- "return immediately after being scheduled" represent haptic effects
  • Synchronous -- "only return after they are completed, ...application thread waits for a synchronous call before continuing." Use to get snapshot of state/variables

[1] OpenHaptics Toolkit - Programmer's Guide 5-5 37/118

CallBacks have two return types.

  • HD_CALLBACK_CONTINUE -- The CallBack will be rescheduled to run on next tick
  • HD_CALLBACK_DONE -- Will not be rescheduled

Examples

hdScheduleSynchronous(DeviceStateCallback, &state, HD_MIN_SCHEDULER_PRIORITY);
hdScheduleAsynchronous(AForceSettingCallback, (void*)0, HD_DEFAULT_SCHEDULER_PRIORITY
);

0 Comments:

Post a Comment

<< Home


Counters