|
| 1 | +# Displacement-Based Metrics |
| 2 | + |
| 3 | +This document summarizes the ground-truth-comparison metrics that are written to the output bag by the open-loop evaluator. |
| 4 | + |
| 5 | +Target metric topics: |
| 6 | + |
| 7 | +- `ade` |
| 8 | +- `fde` |
| 9 | +- `ahe` |
| 10 | +- `fhe` |
| 11 | +- `lateral_deviation` |
| 12 | +- `longitudinal_deviation` |
| 13 | + |
| 14 | +These metrics are computed point-wise against ground truth over the predicted trajectory. They are saved as output bag topics for the full predicted trajectory, and they are also used to derive multi-horizon results for `full`, `1s`, `2s`, `4s`, and `8s`. |
| 15 | + |
| 16 | +## Common Setup |
| 17 | + |
| 18 | +Let the predicted trajectory contain points indexed by $i = 0, 1, \ldots, N$. |
| 19 | + |
| 20 | +For each point $i$: |
| 21 | + |
| 22 | +- $(x_i^{\mathrm{pred}}, y_i^{\mathrm{pred}})$: predicted position |
| 23 | +- $(x_i^{\mathrm{gt}}, y_i^{\mathrm{gt}})$: ground-truth position |
| 24 | +- $\psi_i^{\mathrm{pred}}$: predicted yaw |
| 25 | +- $\psi_i^{\mathrm{gt}}$: ground-truth yaw |
| 26 | +- $t_i$: relative timestamp of the predicted point |
| 27 | + |
| 28 | +In this project, $t_i$ means the `time_from_start` of the $i$-th predicted trajectory point. |
| 29 | + |
| 30 | +For a requested horizon `H`, the evaluator chooses: |
| 31 | + |
| 32 | +$$ |
| 33 | +k = \max \{ i \mid t_i \le H \} |
| 34 | +$$ |
| 35 | + |
| 36 | +and only reports that horizon if: |
| 37 | + |
| 38 | +$$ |
| 39 | +H - t_k \le 0.1 |
| 40 | +$$ |
| 41 | + |
| 42 | +This means horizon metrics are derived from the latest trajectory point whose `time_from_start` does not exceed the requested horizon, with a tolerance of `0.1s`. |
| 43 | + |
| 44 | +## ADE |
| 45 | + |
| 46 | +### Definition |
| 47 | + |
| 48 | +Average Displacement Error (ADE) is the average 2D position error between the predicted and ground-truth trajectories. |
| 49 | + |
| 50 | +### Official Equation |
| 51 | + |
| 52 | +$$ |
| 53 | +\mathrm{ADE} = \frac{1}{M} \sum_{i=1}^{M} \sqrt{(x_i^{gt} - x_i^{pred})^2 + (y_i^{gt} - y_i^{pred})^2} |
| 54 | +$$ |
| 55 | + |
| 56 | +### Implemented Equation in This Project |
| 57 | + |
| 58 | +First define the point-wise displacement error: |
| 59 | + |
| 60 | +$$ |
| 61 | +e_i = \sqrt{(x_i^{gt} - x_i^{pred})^2 + (y_i^{gt} - y_i^{pred})^2} |
| 62 | +$$ |
| 63 | + |
| 64 | +The saved `ade` topic stores the running ADE array: |
| 65 | + |
| 66 | +$$ |
| 67 | +\mathrm{ADE}_i = \frac{1}{i+1} \sum_{j=0}^{i} e_j |
| 68 | +$$ |
| 69 | + |
| 70 | +For a horizon `H`, the reported horizon ADE is: |
| 71 | + |
| 72 | +$$ |
| 73 | +\mathrm{ADE}(H) = \mathrm{ADE}_k = \frac{1}{k+1} \sum_{j=0}^{k} e_j |
| 74 | +$$ |
| 75 | + |
| 76 | +### Implementation Notes |
| 77 | + |
| 78 | +- The average starts from the first available predicted trajectory point, not from a separate global time origin. |
| 79 | +- If the first predicted point has `time_from_start = 0.1s`, then ADE starts from that point. |
| 80 | +- The output bag topic is a `Float64MultiArray` containing the running ADE over the full trajectory. |
| 81 | +- Multi-horizon ADE values are derived from this array using the horizon cutoff. |
| 82 | + |
| 83 | +## FDE |
| 84 | + |
| 85 | +### Definition |
| 86 | + |
| 87 | +Final Displacement Error (FDE) is the 2D position error at the final evaluation point. |
| 88 | + |
| 89 | +### Official Equation |
| 90 | + |
| 91 | +$$ |
| 92 | +\mathrm{FDE} = \sqrt{(x_M^{gt} - x_M^{pred})^2 + (y_M^{gt} - y_M^{pred})^2} |
| 93 | +$$ |
| 94 | + |
| 95 | +### Implemented Equation in This Project |
| 96 | + |
| 97 | +Using the same point-wise displacement error: |
| 98 | + |
| 99 | +$$ |
| 100 | +e_i = \sqrt{(x_i^{gt} - x_i^{pred})^2 + (y_i^{gt} - y_i^{pred})^2} |
| 101 | +$$ |
| 102 | + |
| 103 | +the horizon FDE is: |
| 104 | + |
| 105 | +$$ |
| 106 | +\mathrm{FDE}(H) = e_k |
| 107 | +$$ |
| 108 | + |
| 109 | +### Implementation Notes |
| 110 | + |
| 111 | +- The saved `fde` topic contains the point-wise displacement error array `e_i`, not a running FDE. |
| 112 | +- The horizon or full-trajectory FDE is obtained by taking the cutoff element from that array. |
| 113 | +- This is why the topic name is `fde` even though the bag message contains one value per trajectory point. |
| 114 | + |
| 115 | +## AHE |
| 116 | + |
| 117 | +### Definition |
| 118 | + |
| 119 | +Average Heading Error (AHE) is the average absolute heading difference between the predicted and ground-truth trajectories. |
| 120 | + |
| 121 | +### Official Equation |
| 122 | + |
| 123 | +$$ |
| 124 | +\mathrm{AHE} = \frac{1}{M} \sum_{i=1}^{M} \left| \mathrm{normalize}(\psi_i^{pred} - \psi_i^{gt}) \right| |
| 125 | +$$ |
| 126 | + |
| 127 | +### Implemented Equation in This Project |
| 128 | + |
| 129 | +Define the point-wise heading error: |
| 130 | + |
| 131 | +$$ |
| 132 | +h_i = \left| \mathrm{normalize}(\psi_i^{pred} - \psi_i^{gt}) \right| |
| 133 | +$$ |
| 134 | + |
| 135 | +The saved `ahe` topic stores the running average heading error array: |
| 136 | + |
| 137 | +$$ |
| 138 | +\mathrm{AHE}_i = \frac{1}{i+1} \sum_{j=0}^{i} h_j |
| 139 | +$$ |
| 140 | + |
| 141 | +For a horizon `H`, the reported horizon AHE is: |
| 142 | + |
| 143 | +$$ |
| 144 | +\mathrm{AHE}(H) = \mathrm{AHE}_k = \frac{1}{k+1} \sum_{j=0}^{k} h_j |
| 145 | +$$ |
| 146 | + |
| 147 | +### Implementation Notes |
| 148 | + |
| 149 | +- Heading error is stored in radians. |
| 150 | +- The absolute heading difference is normalized before taking the magnitude. |
| 151 | +- The output bag topic is a `Float64MultiArray` containing the running AHE over the full trajectory. |
| 152 | + |
| 153 | +## FHE |
| 154 | + |
| 155 | +### Definition |
| 156 | + |
| 157 | +Final Heading Error (FHE) is the absolute heading error at the final evaluation point. |
| 158 | + |
| 159 | +### Official Equation |
| 160 | + |
| 161 | +$$ |
| 162 | +\mathrm{FHE} = \left| \mathrm{normalize}(\psi_M^{pred} - \psi_M^{gt}) \right| |
| 163 | +$$ |
| 164 | + |
| 165 | +### Implemented Equation in This Project |
| 166 | + |
| 167 | +Using the point-wise heading error: |
| 168 | + |
| 169 | +$$ |
| 170 | +h_i = \left| \mathrm{normalize}(\psi_i^{pred} - \psi_i^{gt}) \right| |
| 171 | +$$ |
| 172 | + |
| 173 | +the horizon FHE is: |
| 174 | + |
| 175 | +$$ |
| 176 | +\mathrm{FHE}(H) = h_k |
| 177 | +$$ |
| 178 | + |
| 179 | +### Implementation Notes |
| 180 | + |
| 181 | +- The saved `fhe` topic contains the point-wise heading error array `h_i`, not a running FHE. |
| 182 | +- The horizon or full-trajectory FHE is obtained by taking the cutoff element from that array. |
| 183 | +- This mirrors how `fde` is handled for position error. |
| 184 | + |
| 185 | +## Lateral Deviation |
| 186 | + |
| 187 | +### Definition |
| 188 | + |
| 189 | +Lateral deviation is the signed lateral position error between prediction and ground truth, measured in the ground-truth vehicle frame. |
| 190 | + |
| 191 | +### Implemented Equation in This Project |
| 192 | + |
| 193 | +First compute the global position difference: |
| 194 | + |
| 195 | +$$ |
| 196 | +\Delta x_i = x_i^{pred} - x_i^{gt}, \quad \Delta y_i = y_i^{pred} - y_i^{gt} |
| 197 | +$$ |
| 198 | + |
| 199 | +Then rotate this difference by $-\psi_i^{\mathrm{gt}}$ into the ground-truth vehicle frame: |
| 200 | + |
| 201 | +$$ |
| 202 | +\begin{bmatrix} |
| 203 | +\Delta x_i^{veh} \\ |
| 204 | +\Delta y_i^{veh} |
| 205 | +\end{bmatrix} |
| 206 | += |
| 207 | +\begin{bmatrix} |
| 208 | +\cos(-\psi_i^{gt}) & -\sin(-\psi_i^{gt}) \\ |
| 209 | +\sin(-\psi_i^{gt}) & \cos(-\psi_i^{gt}) |
| 210 | +\end{bmatrix} |
| 211 | +\begin{bmatrix} |
| 212 | +\Delta x_i \\ |
| 213 | +\Delta y_i |
| 214 | +\end{bmatrix} |
| 215 | +$$ |
| 216 | + |
| 217 | +The implemented lateral deviation is: |
| 218 | + |
| 219 | +$$ |
| 220 | +\mathrm{LatDev}_i = \Delta y_i^{veh} |
| 221 | +$$ |
| 222 | + |
| 223 | +For a horizon `H`, the evaluator derives: |
| 224 | + |
| 225 | +$$ |
| 226 | +\mathrm{AverageLateralDeviation}(H) = \frac{1}{k+1} \sum_{j=0}^{k} |\mathrm{LatDev}_j| |
| 227 | +$$ |
| 228 | + |
| 229 | +$$ |
| 230 | +\mathrm{MaxLateralDeviation}(H) = \max_{0 \le j \le k} |\mathrm{LatDev}_j| |
| 231 | +$$ |
| 232 | + |
| 233 | +### Implementation Notes |
| 234 | + |
| 235 | +- The saved `lateral_deviation` topic contains the signed point-wise lateral deviation array. |
| 236 | +- The horizon metrics use absolute values when computing average and max aggregates. |
| 237 | +- This metric is different from route-centerline lateral deviation used by lane-keeping logic. |
| 238 | + |
| 239 | +## Longitudinal Deviation |
| 240 | + |
| 241 | +### Definition |
| 242 | + |
| 243 | +Longitudinal deviation is the signed longitudinal position error between prediction and ground truth, measured in the ground-truth vehicle frame. |
| 244 | + |
| 245 | +### Implemented Equation in This Project |
| 246 | + |
| 247 | +Using the same rotated vehicle-frame offset as above, the implemented longitudinal deviation is: |
| 248 | + |
| 249 | +$$ |
| 250 | +\mathrm{LonDev}_i = \Delta x_i^{veh} |
| 251 | +$$ |
| 252 | + |
| 253 | +For a horizon `H`, the evaluator derives: |
| 254 | + |
| 255 | +$$ |
| 256 | +\mathrm{AverageLongitudinalDeviation}(H) = \frac{1}{k+1} \sum_{j=0}^{k} |\mathrm{LonDev}_j| |
| 257 | +$$ |
| 258 | + |
| 259 | +$$ |
| 260 | +\mathrm{MaxLongitudinalDeviation}(H) = \max_{0 \le j \le k} |\mathrm{LonDev}_j| |
| 261 | +$$ |
| 262 | + |
| 263 | +### Implementation Notes |
| 264 | + |
| 265 | +- The saved `longitudinal_deviation` topic contains the signed point-wise longitudinal deviation array. |
| 266 | +- The horizon metrics use absolute values when computing average and max aggregates. |
| 267 | + |
| 268 | +## Output Bag Topics |
| 269 | + |
| 270 | +The following ground-truth-comparison metric topics are written to the output bag: |
| 271 | + |
| 272 | +- `ade` |
| 273 | +- `fde` |
| 274 | +- `ahe` |
| 275 | +- `fhe` |
| 276 | +- `lateral_deviation` |
| 277 | +- `longitudinal_deviation` |
| 278 | + |
| 279 | +All of the above are written as `std_msgs/msg/Float64MultiArray`. |
| 280 | + |
| 281 | +## Horizon-Derived Results |
| 282 | + |
| 283 | +The following multi-horizon results are derived from the arrays above for `full`, `1s`, `2s`, `4s`, and `8s`: |
| 284 | + |
| 285 | +- `ADE` |
| 286 | +- `FDE` |
| 287 | +- `AHE` |
| 288 | +- `FHE` |
| 289 | +- `average_lateral_deviation` |
| 290 | +- `max_lateral_deviation` |
| 291 | +- `average_longitudinal_deviation` |
| 292 | +- `max_longitudinal_deviation` |
| 293 | + |
| 294 | +These horizon results are stored in the structured result JSON written by the evaluator, rather than as separate per-horizon bag topics. |
0 commit comments