DriveWorks SDK Reference
5.8.83 Release
For Test and Development only

Relative Egomotion Workflow

Workflow

Initialization

To initialize motion model certain parameters, such as imu calibration or vehicle data, must be passed to the module. These parameters can be extracted from a dwRig module, see Rig Configuration Hence a typical initialization code sequence will look like this:

// read vehicle configuration
dwRig_initializeFromFile(&rig, sdkContext, "path/to/rig.json");
const dwVehicle *vehicle = nullptr;
dwRig_getVehicle(&vehicle, rig);
// get IMU sensor from the vehicle configuration
uint32_t imuIdx = 0;
dwRig_findSensorByName(&imuIdx, "imu.xsens", rig);
// setup motion model
params.vehicle = *vehicle;
params.automaticUpdate = true;
params.sensorParameters.imuSamplingRate = 100.f;
params.autoupdate = true; // automatically update as appropriate on new sensor event
dwRig_getSensorToRigTransformation(&params.imu2rig, imuIdx, rig);
// initialize egomotion module
dwEgomotion_initialize(&egomotion, &params, sdkContext);
dwMotionModel motionModel
Specifies the motion model to be used for pose estimation.
Definition: Egomotion.h:394
DW_API_PUBLIC dwStatus dwEgomotion_initialize(dwEgomotionHandle_t *obj, const dwEgomotionParameters *params, dwContextHandle_t ctx)
Initializes the egomotion module.
@ DW_EGOMOTION_IMU_ODOMETRY
Fuses odometry model with IMU measurements to estimate motion of the vehicle.
Definition: Egomotion.h:171
Holds initialization parameters for the Egomotion module.
Definition: Egomotion.h:375
DW_API_PUBLIC dwStatus dwRig_getSensorToRigTransformation(dwTransformation3f *const transformation, uint32_t const sensorId, dwConstRigHandle_t const obj)
Gets the sensor to rig transformation for a sensor.
DW_API_PUBLIC dwStatus dwRig_findSensorByName(uint32_t *const sensorId, char8_t const *const sensorName, dwConstRigHandle_t const obj)
Finds the sensor with the given name and returns its index.
DW_API_PUBLIC dwStatus dwRig_getVehicle(dwVehicle const **const vehicle, dwConstRigHandle_t const obj)
DEPRECATED: Gets the properties of a passenger car vehicle.
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.
DEPRECATED: Properties of a passenger car vehicle.
Definition: Vehicle.h:316

Run-time filter update and motion estimation

At runtime the estimator has to be filled with input measurements. The following shows the sequence in a typical application using the Egomotion module:

const dwSensorEvent* sensorEvent = nullptr;
dwVehicleIOSafetyState vehicleIOSafetyState{};
dwVehicleIONonSafetyState vehicleIONonSafetyState{};
dwVehicleIOActuationFeedback vehicleIOActuationFeedback{};
while(dwSensorManager_acquireNextEvent(&sensorEvent, 0, sensorManager) == DW_SUCCESS)
{
switch (sensorEvent->type)
{
dwVehicleIO_consumeCANFrame(sensorEvent->canFrame, 0, vehicleIO);
dwVehicleIO_getVehicleSafetyState(&vehicleIOSafetyState, vehicleIO)
dwVehicleIO_getVehicleNonSafetyState(&vehicleIONonSafetyState, vehicleIO)
dwVehicleIO_getVehicleActuationFeedback(&vehicleIOActuationFeedback, vehicleIO)
dwEgomotion_addVehicleIOState(&vehicleIOSafetyState, &vehicleIONonSafetyState, &vehicleIOActuationFeedback, egomotion);
break;
dwEgomotion_addIMUMeasurement(sensorEvent->imuFrame, egomotion);
break;
...
// query filter for a relative motion since last request
dwTransformation3f motionLastToNow{};
dwEgomotion_computeRelativeTransformation(&motionLastToNow, nullptr, getLastTime(), getCurrentTime(), egomotion);
...
// query filter for the latest known absolute estimation
dwEgomotionResult estimation{};
dwEgomotion_getEstimation(&estimation, motion);
}
DW_API_PUBLIC dwStatus dwVehicleIO_getVehicleActuationFeedback(dwVehicleIOActuationFeedback *const actuationFeedback, dwVehicleIOHandle_t const obj)
Retrieve current vehicle actuation feedback.
DW_API_PUBLIC dwStatus dwVehicleIO_getVehicleNonSafetyState(dwVehicleIONonSafetyState *const nonSafeState, dwVehicleIOHandle_t const obj)
Retrieve current vehicle non-safety state.
DW_API_PUBLIC dwStatus dwVehicleIO_getVehicleSafetyState(dwVehicleIOSafetyState *const safeState, dwVehicleIOHandle_t const obj)
Retrieve current vehicle safety state.
DW_API_PUBLIC dwStatus dwVehicleIO_consumeCANFrame(dwCANMessage const *const msg, uint32_t const sensorId, dwVehicleIOHandle_t const obj)
Parse a received event.
Non-safety critical RoV state.
Safety critical VIO state.
Specifies a 3D rigid transformation.
Definition: Types.h:536
DW_API_PUBLIC dwStatus dwEgomotion_getEstimation(dwEgomotionResult *result, dwEgomotionConstHandle_t obj)
Gets the latest state estimate.
DW_API_PUBLIC dwStatus dwEgomotion_addVehicleIOState(dwVehicleIOSafetyState const *safeState, dwVehicleIONonSafetyState const *nonSafeState, dwVehicleIOActuationFeedback const *actuationFeedback, dwEgomotionHandle_t obj)
Notifies the egomotion module of a changed vehicle state.
DW_API_PUBLIC dwStatus dwEgomotion_computeRelativeTransformation(dwTransformation3f *poseAtoB, dwEgomotionRelativeUncertainty *uncertainty, dwTime_t timestamp_a, dwTime_t timestamp_b, dwEgomotionConstHandle_t obj)
Computes the relative transformation between two timestamps and the uncertainty of this transform.
DW_API_PUBLIC dwStatus dwEgomotion_addIMUMeasurement(const dwIMUFrame *imu, dwEgomotionHandle_t obj)
Adds an IMU frame to the egomotion module.
Holds egomotion state estimate.
Definition: Egomotion.h:475
dwIMUFrame imuFrame
dwCANMessage canFrame
dwSensorType type
Type of sensor providing data for this event.
Definition: SensorManager.h:80
DW_API_PUBLIC dwStatus dwSensorManager_acquireNextEvent(const dwSensorEvent **ev, dwTime_t timeoutMicroSeconds, dwSensorManagerHandle_t sm)
Called by the application to consume the next available sensor event ready for consumption.
Structure for returning data upon any sensor event.
Definition: SensorManager.h:78
@ DW_SENSOR_CAN
Definition: Sensors.h:193
@ DW_SENSOR_IMU
Definition: Sensors.h:192

This workflow is demonstrated in the following sample: Egomotion Sample