Merge remote-tracking branch 'origin/navigationd-service' into nav-desires

This commit is contained in:
discountchubbs
2025-10-21 05:54:42 -07:00
10 changed files with 85 additions and 72 deletions
+12 -13
View File
@@ -455,19 +455,18 @@ struct ModelDataV2SP @0xa1680744031fdb2d {
}
struct Navigationd @0xcb9fd56c7057593a {
timestamp @0 :UInt64;
upcomingTurn @1 :Text;
currentSpeedLimit @2 :UInt64;
bannerInstructions @3 :Text;
distanceToNextTurn @4 :Float64;
routeProgressPercent @5 :Float64;
distanceFromRoute @6 :Float64;
routePositionCumulative @7 :Float64;
distanceToEndOfStep @8 :Float64;
totalDistanceRemaining @9 :Float64;
totalTimeRemaining @10 :Float64;
allManeuvers @11 :List(Maneuver);
valid @12 :Bool;
upcomingTurn @0 :Text;
currentSpeedLimit @1 :UInt64;
bannerInstructions @2 :Text;
distanceToNextTurn @3 :Float64;
routeProgressPercent @4 :Float64;
distanceFromRoute @5 :Float64;
routePositionCumulative @6 :Float64;
distanceToEndOfStep @7 :Float64;
totalDistanceRemaining @8 :Float64;
totalTimeRemaining @9 :Float64;
allManeuvers @10 :List(Maneuver);
valid @11 :Bool;
struct Maneuver {
distance @0 :Float64;
+1
View File
@@ -154,6 +154,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
{"IntelligentCruiseButtonManagement", {PERSISTENT | BACKUP , BOOL}},
{"InteractivityTimeout", {PERSISTENT | BACKUP, INT, "0"}},
{"IsDevelopmentBranch", {CLEAR_ON_MANAGER_START, BOOL}},
{"IsReleaseSpBranch", {CLEAR_ON_MANAGER_START, BOOL}},
{"LastGPSPositionLLK", {PERSISTENT, STRING}},
{"LeadDepartAlert", {PERSISTENT | BACKUP, BOOL, "0"}},
{"MaxTimeOffroad", {PERSISTENT | BACKUP, INT, "1800"}},
+1 -1
View File
@@ -12,7 +12,7 @@ public:
explicit DeveloperPanel(SettingsWindow *parent);
void showEvent(QShowEvent *event) override;
private:
protected:
Params params;
ParamControl* adbToggle;
ParamControl* joystickToggle;
@@ -60,7 +60,7 @@ DeveloperPanelSP::DeveloperPanelSP(SettingsWindow *parent) : DeveloperPanel(pare
void DeveloperPanelSP::updateToggles(bool offroad) {
bool disable_updates = params.getBool("DisableUpdates");
bool is_release = params.getBool("IsReleaseBranch");
bool is_release = params.getBool("IsReleaseBranch") || params.getBool("IsReleaseSpBranch");
bool is_tested = params.getBool("IsTestedBranch");
bool is_development = params.getBool("IsDevelopmentBranch");
@@ -79,6 +79,9 @@ void DeveloperPanelSP::updateToggles(bool offroad) {
enableGithubRunner->setVisible(!is_release);
errorLogBtn->setVisible(!is_release);
showAdvancedControls->setEnabled(true);
joystickToggle->setVisible(!is_release);
longManeuverToggle->setVisible(!is_release);
}
void DeveloperPanelSP::showEvent(QShowEvent *event) {
@@ -13,7 +13,6 @@ class NavigationInstructions:
self._no_route = False
def get_route_progress(self, current_lat, current_lon) -> dict | None:
"""Get current position on route and progress information"""
route = self.get_current_route()
if not route or not route['geometry'] or not route['steps']:
return None
@@ -125,7 +124,8 @@ class NavigationInstructions:
return str(modifier)
return 'none'
def get_current_speed_limit_from_progress(self, progress, is_metric: bool) -> int:
@staticmethod
def get_current_speed_limit_from_progress(progress, is_metric: bool) -> int:
if progress and progress['current_maxspeed']:
speed, _ = progress['current_maxspeed']
if is_metric:
@@ -16,7 +16,7 @@ class TestMapbox:
if token:
cls.mapbox.params.put('MapboxToken', token)
# setup route
# route setup
cls.current_lon, cls.current_lat = -119.17557, 34.23305
cls.mapbox.params.put('MapboxRoute', '740 E Ventura Blvd. Camarillo, CA')
cls.postvars = {"place_name": cls.mapbox.params.get('MapboxRoute')}
@@ -64,7 +64,6 @@ class TestMapbox:
assert upcoming_close == expected_turn == 'right', "Should be a right turn upcoming"
def test_route_progress_tracking(self):
# Test route progress tracking
progress = self.nav.get_route_progress(self.current_lat, self.current_lon)
assert progress is not None
assert 'distance_from_route' in progress
@@ -80,7 +79,6 @@ class TestMapbox:
assert progress['total_time_remaining'] >= 0
assert isinstance(progress['all_maneuvers'], list)
# Test speed limit extraction
speed_limit_metric = self.nav.get_current_speed_limit_from_progress(progress, True)
speed_limit_imperial = self.nav.get_current_speed_limit_from_progress(progress, False)
assert isinstance(speed_limit_metric, int)
-2
View File
@@ -1,5 +1,4 @@
import math
import time
import cereal.messaging as messaging
from cereal import custom
@@ -92,7 +91,6 @@ class Navigationd:
def _build_navigation_message(self, banner_instructions, progress, nav_data):
msg = custom.Navigationd.new_message()
msg.timestamp = int(time.monotonic() * 1000)
msg.upcomingTurn = nav_data.get('upcoming_turn', 'none')
msg.currentSpeedLimit = nav_data.get('current_speed_limit', 0)
msg.bannerInstructions = banner_instructions
+53 -46
View File
@@ -1,58 +1,65 @@
import platform
import pytest
import cereal.messaging as messaging
from sunnypilot.navd.navigationd import Navigationd
from openpilot.sunnypilot.navd.helpers import Coordinate
def test_init():
nav = Navigationd()
assert nav.sm is not None
assert nav.pm is not None
assert nav.rk is not None
assert nav.route is None
assert nav.destination is None
assert nav.new_destination == ''
assert nav.frame == -1
assert nav.last_position is None
assert not nav.is_metric
assert not nav.valid
class TestNavigationd:
is_darwin = platform.system() == "Darwin"
def test_update_params():
nav = Navigationd()
nav.last_position = None
nav._update_params()
assert nav.frame == -1
nav.last_position = Coordinate(latitude=37.0, longitude=128.0)
nav._update_params()
assert nav.frame == 0 # frame only updates when last position is set
@pytest.fixture(autouse=True)
def setup_method(self, mocker):
if self.is_darwin:
mocker.patch('cereal.messaging.SubMaster')
mocker.patch('cereal.messaging.PubMaster')
def test_update_navigation_no_position():
nav = Navigationd()
nav.last_position = None
banner, progress, nav_data = nav._update_navigation()
assert banner == ''
assert progress is None
assert nav_data == {}
def test_update_params(self):
nav = Navigationd()
nav.last_position = None
nav._update_params()
assert nav.frame == -1
nav.last_position = Coordinate(latitude=37.0, longitude=128.0)
nav._update_params()
assert nav.frame == 0 # frame only updates when last position is set
def test_update_navigation():
nav = Navigationd()
nav.last_position = Coordinate(latitude=37.0, longitude=128.0)
nav.route = {'580 Winchester dr, oxnard, CA': True}
banner, progress, nav_data = nav._update_navigation()
assert isinstance(banner, str)
assert not progress # no route was actually set
assert isinstance(nav_data, dict)
def test_update_navigation_no_position(self):
nav = Navigationd()
nav.last_position = None
banner, progress, nav_data = nav._update_navigation()
assert banner == ''
assert progress is None
assert nav_data == {}
def test_build_navigation_message():
sm = messaging.SubMaster(['navigationd'])
nav = Navigationd()
msg = nav._build_navigation_message('', None, {})
def test_update_navigation(self):
nav = Navigationd()
nav.last_position = Coordinate(latitude=37.0, longitude=128.0)
nav.route = {'580 Winchester dr, oxnard, CA': True}
banner, progress, nav_data = nav._update_navigation()
assert isinstance(banner, str)
assert not progress # no route was actually set
assert isinstance(nav_data, dict)
nav.pm.send('navigationd', msg)
sm.update()
received_msg = sm['navigationd']
def test_build_navigation_message(self):
if self.is_darwin:
nav = Navigationd()
msg = nav._build_navigation_message('', None, {})
assert msg.bannerInstructions == ''
assert msg.totalDistanceRemaining == 0.0
assert msg.totalTimeRemaining == 0.0
assert msg.valid is False
else:
sm = messaging.SubMaster(['navigationd'])
nav = Navigationd()
msg = nav._build_navigation_message('', None, {})
assert received_msg.bannerInstructions == msg.bannerInstructions
assert received_msg.totalDistanceRemaining == msg.totalDistanceRemaining
assert received_msg.totalTimeRemaining == msg.totalTimeRemaining
assert received_msg.valid == msg.valid
nav.pm.send('navigationd', msg)
sm.update()
received_msg = sm['navigationd']
assert received_msg.bannerInstructions == msg.bannerInstructions
assert received_msg.totalDistanceRemaining == msg.totalDistanceRemaining
assert received_msg.totalTimeRemaining == msg.totalTimeRemaining
assert received_msg.valid == msg.valid
+1
View File
@@ -67,6 +67,7 @@ def manager_init() -> None:
params.put_bool("IsDevelopmentBranch", build_metadata.development_channel)
params.put_bool("IsTestedBranch", build_metadata.tested_channel)
params.put_bool("IsReleaseBranch", build_metadata.release_channel)
params.put_bool("IsReleaseSpBranch", build_metadata.release_sp_channel)
params.put("HardwareSerial", serial)
# set dongle id
+10 -4
View File
@@ -13,8 +13,8 @@ from openpilot.common.git import get_commit, get_origin, get_branch, get_short_b
RELEASE_SP_BRANCHES = ['release-c3', 'release']
TESTED_SP_BRANCHES = ['staging-c3', 'staging-c3-new', 'staging']
MASTER_SP_BRANCHES = ['master']
RELEASE_BRANCHES = ['release3-staging', 'release3', 'release-tici', 'nightly'] + RELEASE_SP_BRANCHES
TESTED_BRANCHES = RELEASE_BRANCHES + ['devel', 'devel-staging', 'nightly-dev'] + TESTED_SP_BRANCHES
RELEASE_BRANCHES = ['release3-staging', 'release3', 'release-tici', 'nightly']
TESTED_BRANCHES = RELEASE_BRANCHES + ['devel', 'devel-staging', 'nightly-dev'] + RELEASE_SP_BRANCHES + TESTED_SP_BRANCHES
SP_BRANCH_MIGRATIONS = {
("tici", "staging-c3-new"): "staging-tici",
@@ -96,7 +96,9 @@ class OpenpilotMetadata:
@property
def sunnypilot_remote(self) -> bool:
return self.git_normalized_origin in ("github.com/sunnypilot/sunnypilot",
"github.com/sunnypilot/openpilot")
"github.com/sunnypilot/openpilot",
"github.com/sunnyhaibin/sunnypilot",
"github.com/sunnyhaibin/openpilot")
@property
def git_normalized_origin(self) -> str:
@@ -120,6 +122,10 @@ class BuildMetadata:
def release_channel(self) -> bool:
return self.channel in RELEASE_BRANCHES
@property
def release_sp_channel(self) -> bool:
return self.channel in RELEASE_SP_BRANCHES
@property
def canonical(self) -> str:
return f"{self.openpilot.version}-{self.openpilot.git_commit}-{self.openpilot.build_style}"
@@ -146,7 +152,7 @@ class BuildMetadata:
return "staging"
elif self.master_channel:
return "master"
elif self.release_channel:
elif self.release_channel or self.release_sp_channel:
return "release"
else:
return "feature"