DriveWorks SDK Reference
5.10.90 Release
For Test and Development only

Global Egomotion Workflow

Workflow

Initialization

To initialize the global egomotion module, certain configuration parameters can be set, for example the position of the GNSS antenna in the rig coordinate system. Other parameters include noise and drift characteristics, or the size of the internal history storing state estimates. A typical initialization code sequence will look like this:

// read vehicle configuration
dwRig_initializeFromFile(&rig, sdkContext, "path/to/rig.json");
// initialize global egomotion parameters
dwGlobalEgomotion_initParamsFromRig(&params, rig, "gps_sensor_name");
// other parameters left 0-initialized will be ignored and default values used instead
// see API documentation
// initialize global egomotion module
dwGlobalEgomotion_initialize(&globalEgomotion, &params, sdkContext);
DW_API_PUBLIC dwStatus dwGlobalEgomotion_initParamsFromRig(dwGlobalEgomotionParameters *params, dwConstRigHandle_t rigConfiguration, const char *gpsSensorName)
Initialize global egomotion parameters from a provided RigConfiguration.
DW_API_PUBLIC dwStatus dwGlobalEgomotion_initialize(dwGlobalEgomotionHandle_t *handle, const dwGlobalEgomotionParameters *params, dwContextHandle_t ctx)
Initializes the global egomotion module.
Holds initialization parameters for the global egomotion module.
struct dwRigObject * dwRigHandle_t
Handle representing the Rig interface.
Definition: Rig.h:70
DW_API_PUBLIC dwStatus dwRig_initializeFromFile(dwRigHandle_t *const obj, dwContextHandle_t const ctx, char8_t const *const configurationFile)
Initializes the Rig Configuration module from a file.

Run-time filter update and global position and orientation estimation

At run-time the global egomotion filter has to be filled with measurements from the GNSS sensor, as well as motion estimates from a relative egomotion module. The following example assumes that such a relative egomotion module with handle relativeEgomotion has been initialized and is being updated elsewhere; see Relative Egomotion Workflow for more details.

while(true)
{
// read GPS measurements
if (hasGPSMeasurement())
{
dwGlobalEgomotion_addGPSMeasurement(getGPSMeasurement(), globalEgomotion);
}
...
// update global egomotion module with latest relative egomotion estimates
{
if (dwEgomotion_getEstimation(&state, relativeEgomotion) == DW_SUCCESS &&
dwEgomotion_getUncertainty(&uncertainty, relativeEgomotion) == DW_SUCCESS)
{
dwGlobalEgomotion_addRelativeMotion(&state, &uncertainty, globalEgomotion);
}
}
...
// get latest global state estimate
{
dwGlobalEgomotion_getEstimate(&result, &uncertainty, globalEgomotion);
// position estimate in WGS-84 as well as orientation relative to ENU coordinate system
// can now be accessed.
}
...
// interpolate global state estimate to specific timestamp
// extrapolation is supported but limited to a short time interval, see API doc.
{
dwTime_t requestedTimestamp = ...;
dwGlobalEgomotion_computeEstimate(&result, &uncertainty, requestedTimestamp, globalEgomotion);
// position estimate in WGS-84 as well as orientation relative to ENU coordinate system
// at `requestedTimestamp` can now be accessed.
}
}
int64_t dwTime_t
Specifies a timestamp unit, in microseconds.
Definition: BasicTypes.h:63
DW_API_PUBLIC dwStatus dwEgomotion_getEstimation(dwEgomotionResult *result, dwEgomotionConstHandle_t obj)
Gets the latest state estimate.
DW_API_PUBLIC dwStatus dwEgomotion_getUncertainty(dwEgomotionUncertainty *result, dwEgomotionConstHandle_t obj)
Gets the latest state estimate uncertainties.
Holds egomotion state estimate.
Definition: Egomotion.h:447
Holds egomotion uncertainty estimates.
Definition: Egomotion.h:481
DW_API_PUBLIC dwStatus dwGlobalEgomotion_getEstimate(dwGlobalEgomotionResult *result, dwGlobalEgomotionUncertainty *uncertainty, dwGlobalEgomotionConstHandle_t handle)
Get current filter state estimate.
DW_API_PUBLIC dwStatus dwGlobalEgomotion_addGPSMeasurement(const dwGPSFrame *measurement, dwGlobalEgomotionHandle_t handle)
Adds GPS measurement to the global egomotion module.
DW_API_PUBLIC dwStatus dwGlobalEgomotion_addRelativeMotion(const dwEgomotionResult *egomotionResult, const dwEgomotionUncertainty *egomotionUncertainty, dwGlobalEgomotionHandle_t handle)
Adds relative egomotion estimate to the global egomotion module.
DW_API_PUBLIC dwStatus dwGlobalEgomotion_computeEstimate(dwGlobalEgomotionResult *result, dwGlobalEgomotionUncertainty *uncertainty, dwTime_t timestamp, dwGlobalEgomotionConstHandle_t handle)
Computes global state estimate at given timestamp, if necessary by linear interpolation between avail...
Holds global egomotion state estimate.
Holds global egomotion uncertainty estimate.

Before using any state estimates, always verify their validity by inspecting the return codes of the various APIs as well as the flags contained within the state and uncertainty structures.

This workflow is demonstrated in the following sample: Egomotion Sample