Skip to main content
Version: 21 Aug 2024

Time

APIs for the MLTime. More...

Functions

Name
MLResultMLTimeConvertMLTimeToSystemTime(MLTime ml_time, struct timespec * out_timespec_time)
Converts timestamps from MLTime to system time.
MLResultMLTimeConvertSystemTimeToMLTime(const struct timespec timespec_time, MLTime out_ml_time)
Converts timestamps from system time to MLTime.

Detailed Description

APIs for the MLTime.

timespec time_spec{};
clock_gettime(CLOCK_MONOTONIC, &time_spec);
MLTime converted_ml_time{};
if (MLResult_Ok != MLTimeConvertSystemTimeToMLTime(&time_spec, &converted_ml_time)) {
ML_LOG_ERROR("Failed to convert to MLTime timestamp");
}

Shared Object:

  • perception.magicleap*

Functions Documentation

MLTimeConvertMLTimeToSystemTime

MLResult MLTimeConvertMLTimeToSystemTime(
MLTime ml_time,
struct timespec * out_timespec_time
)

Converts timestamps from MLTime to system time.

Parameters

MLTimeml_timeTimestamp received from elsewhere in the ML system.
struct timespec *out_timespec_timePointer to a converted equivalent timestamp as if received from clock_gettime using CLOCK_MONOTONIC.

Returns

MLResultMLResult_OkSuccessfully converted timestamp.
MLResultMLResult_InvalidParamNULL passed for timespec_time.
MLResultMLResult_UnspecifiedFailureFailed to convert timestamp with unknown error.

Required Permissions:

  • None

See MLTime for more details. System time is equivalent to the systems monotonic clock. This can be used to calculate duration between two MLTime values by converting them both to a timespec and subtracting the subsequent values.

API Level:

  • 20

MLTimeConvertSystemTimeToMLTime

MLResult MLTimeConvertSystemTimeToMLTime(
const struct timespec * timespec_time,
MLTime * out_ml_time
)

Converts timestamps from system time to MLTime.

Parameters

const struct timespec *timespec_timeSystem clock timestamp as received from clock_gettime using CLOCK_MONOTONIC.
MLTime *out_ml_timePointer to system timestamp equivalent in MLTime.

Returns

MLResultMLResult_OkSuccessfully converted timestamp.
MLResultMLResult_InvalidParamNULL passed for ml_time.
MLResultMLResult_UnspecifiedFailureFailed to convert timespec with unknown error.

Required Permissions:

  • None

See MLTime for more details. System time is equivalent to the systems monotonic clock.

API Level:

  • 20