DriveWorks SDK Reference
4.0.0 Release
For Test and Development only

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