Force Feedback API
Force Feedback API is used to lock glove servo motors at a target angle and read back the resulting finger joint position from the glove's magnetic encoders.
It lets an application both resist the user's hand and finger movement (via ts_force_feedback_enable) and track how far the fingers actually moved against that resistance. To receive position, subscribe to data update using ts_force_feedback_set_position_update_callback, then start data streaming using ts_force_feedback_start_position_streaming. To stop streaming use ts_force_feedback_stop_position_streaming.
Functions#
ts_force_feedback_enable#
TsStatusCode ts_force_feedback_enable(TsDeviceHandle* dev, const TsForceFeedbackConfig* configs, uint64_t size);
Enables force feedback servos for one or more bones with the given configurations.
Preconditions
Parameters
dev: TsDeviceHandle*, in
Handle to the attached device whose force feedback servos should be enabled.
configs: const TsForceFeedbackConfig*, in
Array of force feedback configurations, one per servo to activate, each specifying the target bone, lock angle, hardness and lock direction.
size: uint64_t, in
Number of entries in the configs array.
Returns: TsStatusCode
TsStatusCode indicating whether the servos were successfully enabled.
See also: ts_force_feedback_disable
ts_force_feedback_disable#
TsStatusCode ts_force_feedback_disable(TsDeviceHandle* dev, const TsBoneIndex* bones, uint64_t size);
Disables force feedback servos for the specified bones.
Preconditions
ts_initialize or ts_initialize_with_path, ts_force_feedback_enable
Parameters
dev: TsDeviceHandle*, in
Handle to the attached glove whose force feedback servos should be disabled.
bones: const TsBoneIndex*, in
Array of bone indices identifying which servos to deactivate.
size: uint64_t, in
Number of entries in the bones array.
Returns: TsStatusCode
TsStatusCode indicating whether the servos were successfully disabled.
See also: ts_force_feedback_enable
ts_force_feedback_set_position_update_callback#
TsStatusCode ts_force_feedback_set_position_update_callback(TsDeviceHandle* dev, TsForceFeedbackPositionUpdatedCallback callback, void* user_data);
Registers a callback invoked whenever new magnetic encoder position data arrives.
Preconditions
Parameters
dev: TsDeviceHandle*, in
Handle to the attached device to subscribe for position updates.
callback: TsForceFeedbackPositionUpdatedCallback, in
TsForceFeedbackPositionUpdatedCallback to invoke on each position update.
user_data: void*, in
Opaque pointer passed back unchanged to the callback, for correlating updates with caller context.
Returns: TsStatusCode
TsStatusCode indicating whether the callback was successfully registered.
ts_force_feedback_start_position_streaming#
TsStatusCode ts_force_feedback_start_position_streaming(TsDeviceHandle* dev);
Starts streaming magnetic encoder finger position data from the device.
Preconditions
Returns: TsStatusCode
TsStatusCode indicating whether streaming was successfully started.
ts_force_feedback_stop_position_streaming#
TsStatusCode ts_force_feedback_stop_position_streaming(TsDeviceHandle* dev);
Stops streaming magnetic encoder finger position data from the device.
Preconditions
Returns: TsStatusCode
TsStatusCode indicating whether streaming was successfully stopped.
ts_force_feedback_get_flexion_angle#
TsStatusCode ts_force_feedback_get_flexion_angle(TsForceFeedbackPositionContainer container, TsBoneIndex index, float* angle);
Retrieves the flexion/extension angle for a bone from a position update.
Preconditions
ts_initialize or ts_initialize_with_path, ts_force_feedback_start_position_streaming
Parameters
container: TsForceFeedbackPositionContainer, in
Handle to the position container delivered by the position update callback.
index: TsBoneIndex, in
Bone index identifying which finger joint to read the flexion angle for.
angle: float*, out
Destination for the flexion angle, in degrees.
Returns: TsStatusCode
TsStatusCode indicating whether the angle was successfully retrieved.
See also: TsBoneIndex
ts_force_feedback_get_abduction_angle#
TsStatusCode ts_force_feedback_get_abduction_angle(TsForceFeedbackPositionContainer container, TsBoneIndex index, float* angle);
Retrieves the abduction/adduction angle for a bone from a position update.
Preconditions
ts_initialize or ts_initialize_with_path, ts_force_feedback_start_position_streaming
Parameters
container: TsForceFeedbackPositionContainer, in
Handle to the position container delivered by the position update callback.
index: TsBoneIndex, in
Bone index identifying which finger joint to read the abduction angle for.
angle: float*, out
Destination for the abduction angle, in degrees.
Returns: TsStatusCode
TsStatusCode indicating whether the angle was successfully retrieved.
See also: TsBoneIndex
