DriveWorks SDK Reference
3.0.4260 Release
For Test and Development only

egomotion/docs/usecase2.md
Go to the documentation of this file.
1 # Copyright (c) 2019-2020 NVIDIA CORPORATION. All rights reserved.
2 
3 @page egomotion_usecase2 Global Egomotion Workflow
4 
5 @note SW Release Applicability: This tutorial is applicable to modules in both **NVIDIA DriveWorks** and **NVIDIA DRIVE Software** releases.
6 
7 ## Workflow
8 
9 ### Initialization
10 
11 To initialize the global egomotion module, certain configuration parameters can be set, for
12 example the position of the GNSS antenna in the rig coordinate system. Other parameters include
13 noise and drift characteristics, or the size of the internal history storing state estimates.
14 A typical initialization code sequence will look like this:
15 
16 ```{.cpp}
17  // read vehicle configuration
18  dwRigHandle_t rig;
19  dwRig_initializeFromFile(&rig, sdkContext, "path/to/rig.json");
20 
21  // initialize global egomotion parameters
22  dwGlobalEgomotionParameters params{};
23  dwGlobalEgomotion_initParamsFromRig(&params, rig, "gps_sensor_name");
24 
25  // other parameters left 0-initialized will be ignored and default values used instead
26  // see API documentation
27 
28  // initialize global egomotion module
29  dwGlobalEgomotion_initialize(&globalEgomotion, &params, sdkContext);
30 ```
31 
32 ### Run-time filter update and global position and orientation estimation
33 
34 At run-time the global egomotion filter has to be filled with measurements from the GNSS sensor,
35 as well as motion estimates from a relative egomotion module. The following example assumes that
36 such a relative egomotion module with handle `relativeEgomotion` has been initialized and is being
37 updated elsewhere; see @ref egomotion_usecase1 for more details.
38 
39 ```{.cpp}
40 while(true)
41 {
42  // read GPS measurements
43  if (hasGPSMeasurement())
44  {
45  dwGlobalEgomotion_addGPSMeasurement(getGPSMeasurement(), globalEgomotion);
46  }
47 
48  ...
49 
50  // update global egomotion module with latest relative egomotion estimates
51  {
52  dwEgomotionResult state;
53  dwEgomotionUncertainty uncertainty;
54 
55  if (dwEgomotion_getEstimation(&state, relativeEgomotion) == DW_SUCCESS &&
56  dwEgomotion_getUncertainty(&uncertainty, relativeEgomotion) == DW_SUCCESS)
57  {
58  dwGlobalEgomotion_addRelativeMotion(&state, &uncertainty, globalEgomotion);
59  }
60  }
61 
62  ...
63 
64  // get latest global state estimate
65  {
66  dwGlobalEgomotionResult result;
67  dwGlobalEgomotionUncertainty uncertainty;
68  dwGlobalEgomotion_getEstimate(&result, &uncertainty, globalEgomotion);
69 
70  // position estimate in WGS-84 as well as orientation relative to ENU coordinate system
71  // can now be accessed.
72  }
73 
74  ...
75 
76  // interpolate global state estimate to specific timestamp
77  // extrapolation is supported but limited to a short time interval, see API doc.
78  {
79  dwTime_t requestedTimestamp = ...;
80  dwGlobalEgomotionResult result;
81  dwGlobalEgomotionUncertainty uncertainty;
82 
83  dwGlobalEgomotion_computeEstimate(&result, &uncertainty, requestedTimestamp, globalEgomotion);
84 
85  // position estimate in WGS-84 as well as orientation relative to ENU coordinate system
86  // at `requestedTimestamp` can now be accessed.
87  }
88 }
89 ```
90 
91 Before using any state estimates, always verify their validity by inspecting the return codes of the
92 various APIs as well as the flags contained within the state and uncertainty structures.
93 
94 This workflow is demonstrated in the following sample: @ref dwx_egomotion_sample
95