|
| 1 | +# Trajectory Visualization # |
| 2 | + |
| 3 | +This is implemented as a class. It contains 4 functions: |
| 4 | +* `accel_and_curv_to_meters_trajectory` |
| 5 | +* `meters_to_pixels_trajectory` |
| 6 | +* `overlay_the_trajectory_with_map` |
| 7 | +* `render_trajectory_map_tile` |
| 8 | + |
| 9 | +## Complete function ## |
| 10 | + |
| 11 | +### `render_trajectory_map_tile` |
| 12 | + |
| 13 | +Integrates predicted trajectory into metric coordinates and |
| 14 | +draws them onto the raw BEV map tile. |
| 15 | + |
| 16 | +It takes four inputs: |
| 17 | +* `action_sequence`: (128, ) flattened (64, 2) $[acceleration, curvature]$ tensor. |
| 18 | +It is the exact format of the trajectory outputted by `model()` function. |
| 19 | +* `current_speed`: Scalar float from the egomotion history. |
| 20 | +This should be extracted from the egomotion history |
| 21 | +* `map_image`: A map tile, not normalized. |
| 22 | +Ideally, it should follow L2D format. |
| 23 | +If the dataset does not provide maps directly, but provides GPS history, |
| 24 | +please use already existing [map generation function](https://github.com/autowarefoundation/auto_e2e/tree/main/Model/data_parsing/map_rendering) |
| 25 | +to get a map tile. |
| 26 | +* `radius_m`: The metric boundary of the `map_image` in meters. |
| 27 | + |
| 28 | +Returns: |
| 29 | +* A new PIL Image with the trajectory drawn on it. |
| 30 | + |
| 31 | +## Helper functions ## |
| 32 | + |
| 33 | +### `accel_and_curv_to_meters_trajectory` |
| 34 | +Takes an action sequence containing pairs of acceleration ($m/s^2$) and curvature ($rad/m$), the ego vehicle's current speed, and a defined number of future timesteps. |
| 35 | +It integrates these values over time using a kinematic model to produce a tensor of metric $(X, Y)$ coordinates. The ego vehicle is positioned at the origin $(0.0, 0.0)$, with forward movement mapped to the positive $Y$-axis. |
| 36 | + |
| 37 | +### `meters_to_pixels_trajectory` |
| 38 | +Converts the metric trajectory tensor into 2D image pixel coordinates $(U, V)$. It scales the coordinates based on the pixel dimensions of the provided map image and the metric boundary `radius_m`. |
| 39 | + |
| 40 | +### `overlay_the_trajectory_with_map` |
| 41 | +Uses PIL's `ImageDraw` module to render the trajectory as a continuous green line directly onto a copy of the BEV map image. It also draws a red circle at the trajectory's origin to indicate the ego vehicle's current position. |
| 42 | + |
| 43 | +## Dependencies ## |
| 44 | + |
| 45 | +Core visualization logic only requires standard machine learning and image processing libraries: |
| 46 | + |
| 47 | +```text |
| 48 | +Pillow>=5.3.0 |
| 49 | +``` |
| 50 | + |
| 51 | +If you wish to run the live visualization script (`--live`) to test predictions using real dataset records, you will additionally need the [L2D dependencies](https://github.com/autowarefoundation/auto_e2e/tree/main/Model/data_parsing/l2d) |
| 52 | + |
| 53 | +## TODO ## |
| 54 | + |
| 55 | +A function to draw the trajectory on the camera view is yet to be added. |
0 commit comments