This commit is contained in:
discountchubbs
2025-10-29 20:03:19 -07:00
parent 8dbfc267ac
commit befc73c53e
3 changed files with 16 additions and 3 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ See the LICENSE.md file in the root directory for more details.
class NAV_CV:
""" These distances are expected in meters format and convert to desired format """
SHORT_DISTANCE_METERS = 200.0
QUARTER_MILE = 402.0
POINT_ONE_MILE = 160.9344
METERS_TO_KILO = 1000 # divide m by this
METERS_TO_MILE = 1609.344 # divide m by this
METERS_TO_FEET = 3.280839895 # multiply m by this
+5 -2
View File
@@ -28,8 +28,11 @@ class EventBuilder:
dist = f'{int(m.distance)}m,'
else:
dist = f'{m.distance / NAV_CV.METERS_TO_MILE:.1f} mi,'
if m.distance < NAV_CV.QUARTER_MILE:
dist = f'{int(m.distance * NAV_CV.METERS_TO_FEET)}ft,'
if m.distance < NAV_CV.POINT_ONE_MILE:
if m.distance * NAV_CV.METERS_TO_FEET < 250.0:
dist = f'{round((m.distance * NAV_CV.METERS_TO_FEET) / 50) * 50}ft,'
else:
dist = f'{round((m.distance * NAV_CV.METERS_TO_FEET) / 100) * 100}ft,'
if m.type == 'arrive' or m.type == 'depart':
base_msg = banner
@@ -61,6 +61,16 @@ class TestEventBuilder:
}]
assert events == expected
def test_distance_condition_imperial(self):
nav_msg = self.create_nav_msg()
nav_msg.allManeuvers[1] = custom.Navigationd.Maneuver.new_message(distance=160.0, type='continue', modifier='straight', instruction='1234 Apple Way')
events = EventBuilder.build_navigation_events(MockSM(nav_msg), False)
expected = [{
'name': custom.OnroadEventSP.EventName.navigationBanner,
'message': 'For 500ft, Continue on 1234 Apple Way',
}]
assert events == expected
def test_upcoming_turn_override(self):
nav_msg = self.create_nav_msg(upcoming_turn='left')
events = EventBuilder.build_navigation_events(MockSM(nav_msg))