TeslasuitDocumentation
APIs

Mocap API

The Mocap module streams motion capture data from a TESLASUIT device, giving access to both raw IMU sensor readings and the processed, solved skeleton (bone poses and biomechanical joint angles).

Raw and solved data are each delivered as an opaque frame handle (TsMocapSensorSkeleton and TsMocapSkeleton respectively); dedicated getter functions are used to pull individual per-bone or per-joint values out of a frame.

To use the module, first register a callback for the kind of data you need with ts_mocap_set_sensor_skeleton_update_callback and/or ts_mocap_set_skeleton_update_callback, then start streaming with ts_mocap_start_streaming. From that point on, each new frame is delivered by invoking the registered callback, inside which the getter functions can be used to read out the values of interest. Call ts_mocap_stop_streaming when mocap data is no longer needed.

Functions#

ts_mocap_set_skeleton_update_callback#

TsStatusCode ts_mocap_set_skeleton_update_callback(TsDeviceHandle* dev, TsMocapSkeletonCallback callback, void* user_data);

Registers a callback for solved skeleton pose updates.

Parameters

dev: TsDeviceHandle*, in

handler to the attached device

callback: TsMocapSkeletonCallback, in

TsMocapSkeletonCallback to invoke with each new solved skeleton frame

user_data: void*, in

opaque pointer forwarded unchanged to the callback, useful for passing caller-owned context

Returns: TsStatusCode

TsStatusCode indicating whether the callback was registered


ts_mocap_set_sensor_skeleton_update_callback#

TsStatusCode ts_mocap_set_sensor_skeleton_update_callback(TsDeviceHandle* dev, TsMocapSensorSkeletonCallback callback, void* user_data);

Registers a callback for raw IMU sensor data updates.

Parameters

dev: TsDeviceHandle*, in

handler to the attached device

callback: TsMocapSensorSkeletonCallback, in

TsMocapSensorSkeletonCallback to invoke with each new raw sensor frame

user_data: void*, in

opaque pointer forwarded unchanged to the callback, useful for passing caller-owned context

Returns: TsStatusCode

TsStatusCode indicating whether the callback was registered


ts_mocap_start_streaming#

TsStatusCode ts_mocap_start_streaming(TsDeviceHandle* dev);

Starts the mocap data streaming pipeline for a device.

Parameters

dev: TsDeviceHandle*, in

handler to the attached device

Returns: TsStatusCode

TsStatusCode indicating whether streaming was started


ts_mocap_stop_streaming#

TsStatusCode ts_mocap_stop_streaming(TsDeviceHandle* dev);

Stops the mocap data streaming pipeline for a device.

Parameters

dev: TsDeviceHandle*, in

handler to the attached device

Returns: TsStatusCode

TsStatusCode indicating whether streaming was stopped


ts_mocap_skeleton_calibrate#

TsStatusCode ts_mocap_skeleton_calibrate(TsDeviceHandle* dev);

Triggers a calibration of the mocap skeleton model.

Parameters

dev: TsDeviceHandle*, in

handler to the attached device

Returns: TsStatusCode

TsStatusCode indicating whether calibration was triggered


ts_mocap_skeleton_get_bone#

TsStatusCode ts_mocap_skeleton_get_bone(const TsMocapSkeleton skeleton, TsBoneIndex index, TsMocapBone* bone);

Extracts the solved pose of a single bone from a skeleton frame.

Parameters

skeleton: const TsMocapSkeleton, in

opaque handle to the solved skeleton frame, as received in a TsMocapSkeletonCallback

index: TsBoneIndex, in

index of the bone whose pose should be extracted

bone: TsMocapBone*, out

destination structure filled with the bone's position and rotation

Returns: TsStatusCode

TsStatusCode indicating whether the bone data was retrieved

See also: TsBoneIndex


ts_mocap_sensor_skeleton_get_bone#

TsStatusCode ts_mocap_sensor_skeleton_get_bone(const TsMocapSensorSkeleton skeleton, TsBoneIndex index, TsMocapSensor* bone);

Extracts the raw IMU sensor reading of a single bone from a raw data frame.

Parameters

skeleton: const TsMocapSensorSkeleton, in

opaque handle to the raw sensor data frame, as received in a TsMocapSensorSkeletonCallback

index: TsBoneIndex, in

index of the bone whose sensor reading should be extracted

bone: TsMocapSensor*, out

destination structure filled with the bone's raw sensor data

Returns: TsStatusCode

TsStatusCode indicating whether the sensor data was retrieved

See also: TsBoneIndex


ts_mocap_skeleton_get_biomechanical_angle#

TsStatusCode ts_mocap_skeleton_get_biomechanical_angle(const TsMocapSkeleton skeleton, TsBiomechanicalIndex index, float* angle);

Extracts a single biomechanical joint angle from a skeleton frame.

Parameters

skeleton: const TsMocapSkeleton, in

opaque handle to the solved skeleton frame, as received in a TsMocapSkeletonCallback

index: TsBiomechanicalIndex, in

index of the biomechanical angle to extract

angle: float*, out

destination for the extracted angle value, in degrees

Returns: TsStatusCode

TsStatusCode indicating whether the angle was retrieved


ts_mocap_skeleton_get_foot_contacts#

TsStatusCode ts_mocap_skeleton_get_foot_contacts(const TsMocapSkeleton skeleton, int* left_foot, int* right_foot);

Extracts left and right foot ground contact state from a skeleton frame.

Parameters

skeleton: const TsMocapSkeleton, in

opaque handle to the solved skeleton frame, as received in a TsMocapSkeletonCallback

left_foot: int*, out

contact state of the left foot: 1 if contact is detected, 0 if not detected, -1 if the value is undefined (not available)

right_foot: int*, out

contact state of the right foot: 1 if contact is detected, 0 if not detected, -1 if the value is undefined (not available)

Returns: TsStatusCode

TsStatusCode indicating whether the contact data was retrieved

See also: TsMocapSkeletonContact