Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Plugins/CollisionAvoidance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ def get_intersecting_vehicles(
sensitivity = settings.sensitivity
intersecting_vehicles = []
impacts = []
lookahead_time = float(settings.lookahead_time)
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lookahead_time = float(settings.lookahead_time) fixes the common "2.5" string case, but the underlying reason the setting can load as a string is that ETS2LASettings casts DB values using type(default) (not the annotation). In this plugin, lookahead_time: float = 3 uses an int default, so int("2.5") fails and the raw string is kept. Consider changing the defaults in Plugins/CollisionAvoidance/settings.py to real floats (e.g., 3.0) so values are consistently loaded as floats and you may not need defensive casting here long-term.

Suggested change
lookahead_time = float(settings.lookahead_time)
try:
lookahead_time = float(settings.lookahead_time)
except (TypeError, ValueError):
lookahead_time = 3.0

Copilot uses AI. Check for mistakes.
for vehicle in vehicles:
if not IsInFront(vehicle.position.tuple(), truck_rotation, truck_position):
continue # only consider vehicles in front of the truck

path: list[Position] = vehicle.get_path_for(settings.lookahead_time)
path: list[Position] = vehicle.get_path_for(lookahead_time)
if not path:
continue

Expand Down
Loading