Speed limit controller

Added toggle to control the cruise set speed according to speed limit supplied by OSM, NOO, or the vehicle itself.

Co-Authored-By: Jacob Pfeifer <jacob@pfeifer.dev>
Co-Authored-By: Efini <19368997+efini@users.noreply.github.com>
Co-Authored-By: Kumar <36933347+rav4kumar@users.noreply.github.com>
Co-Authored-By: Jason Wen <haibin.wen3@gmail.com>
This commit is contained in:
FrogAi
2024-02-27 16:34:47 -07:00
parent 6907410750
commit 3a926ddfbe
23 changed files with 703 additions and 29 deletions

View File

@@ -18,6 +18,8 @@ from openpilot.selfdrive.navd.helpers import (Coordinate, coordinate_from_param,
parse_banner_instructions)
from openpilot.common.swaglog import cloudlog
from openpilot.selfdrive.frogpilot.functions.speed_limit_controller import SpeedLimitController
REROUTE_DISTANCE = 25
MANEUVER_TRANSITION_THRESHOLD = 10
REROUTE_COUNTER_MIN = 3
@@ -263,6 +265,11 @@ class RouteEngine:
if self.step_idx is None:
msg.valid = False
SpeedLimitController.nav_speed_limit = 0
SpeedLimitController.write_nav_state()
if SpeedLimitController.desired_speed_limit != 0:
msg.navInstruction.speedLimit = SpeedLimitController.desired_speed_limit
self.pm.send('navInstruction', msg)
return
@@ -337,6 +344,14 @@ class RouteEngine:
if ('maxspeed' in closest.annotations) and self.localizer_valid:
msg.navInstruction.speedLimit = closest.annotations['maxspeed']
SpeedLimitController.nav_speed_limit = closest.annotations['maxspeed']
SpeedLimitController.write_nav_state()
if not self.localizer_valid or ('maxspeed' not in closest.annotations):
SpeedLimitController.nav_speed_limit = 0
SpeedLimitController.write_nav_state()
if SpeedLimitController.desired_speed_limit != 0:
msg.navInstruction.speedLimit = SpeedLimitController.desired_speed_limit
# Speed limit sign type
if 'speedLimitSign' in step: