ConsDrive / utils /navigation_text.py
ZenoNing's picture
Upload ConsDrive v2 source (part 2)
314ecfb verified
Raw History Blame Contribute Delete
886 Bytes
"""Shared navigation-text formatting used by both training and evaluation.
The exact string must match between the dataset (`dataloader/dataset_base.py`)
and the Bench2Drive agent (`team_code/agent_drivevla.py`); keeping the
formatter in one place guarantees that.
"""
def format_target_waypoint_text(target_point, next_target_point) -> str:
"""Render the two ego-frame target points as command-suffix text.
One decimal (0.1 m) keeps the token count low while disambiguating
branches; coordinates follow the ego convention used everywhere else
(x forward, y right, metres).
"""
tp1_x, tp1_y = float(target_point[0]), float(target_point[1])
tp2_x, tp2_y = float(next_target_point[0]), float(next_target_point[1])
return (
f" Target waypoint: ({tp1_x:.1f}, {tp1_y:.1f}),"
f" then ({tp2_x:.1f}, {tp2_y:.1f})."
)