Compare commits

...

3 Commits

Author SHA1 Message Date
Jason Wen 79c398db94 chore: update CHANGELOG for 2026.002.004 2026-11-29 17:03:09 -05:00
discountchubbs 55786bdfc4 bug: camera offset migration from old branches 2026-11-29 17:03:09 -05:00
Jason Wen b8c46b3f6e version: bump to 2026.002.004 2026-11-29 17:03:08 -05:00
5 changed files with 28 additions and 2 deletions
+5
View File
@@ -1,3 +1,8 @@
sunnypilot Version 2026.002.004 (2026-11-29)
========================
* What's Changed
* bug: camera offset migration from old branches by @Discountchubbs in https://github.com/sunnypilot/sunnypilot/pull/2127
sunnypilot Version 2026.002.003 (2026-11-19)
========================
* What's Changed
+1 -1
View File
@@ -1 +1 @@
#define SUNNYPILOT_VERSION "2026.002.003"
#define SUNNYPILOT_VERSION "2026.002.004"
@@ -8,6 +8,8 @@ import numpy as np
from openpilot.common.transformations.camera import DEVICE_CAMERAS
MAX_CAMERA_OFFSET = 0.35 # m, the settings' range
class CameraOffsetHelper:
def __init__(self):
@@ -26,6 +28,13 @@ class CameraOffsetHelper:
def set_offset(self, offset):
self.camera_offset = offset
def load_offset(self, params):
offset = params.get("CameraOffset", return_default=True)
if offset is None or not np.isfinite(offset) or abs(offset) > MAX_CAMERA_OFFSET + 1e-6: # older sunnypilot stored whole centimeters
offset = 0.0
params.put("CameraOffset", offset)
self.set_offset(offset)
def update(self, model_transform_main, model_transform_extra, sm, main_wide_camera):
self.actual_camera_offset = (0.9 * self.actual_camera_offset) + (0.1 * self.camera_offset)
dc = DEVICE_CAMERAS[(str(sm['deviceState'].deviceType), str(sm['roadCameraState'].sensor))]
+1 -1
View File
@@ -367,7 +367,7 @@ def main(demo=False):
if sm.frame % 60 == 0:
model.lat_delay = get_lat_delay(params, sm["liveDelay"].lateralDelay)
model.PLANPLUS_CONTROL = params.get("PlanplusControl", return_default=True)
camera_offset_helper.set_offset(params.get("CameraOffset", return_default=True))
camera_offset_helper.load_offset(params)
lat_delay = model.lat_delay + model.LAT_SMOOTH_SECONDS
if sm.updated["liveCalibration"] and sm.seen['roadCameraState'] and sm.seen['deviceState']:
device_from_calib_euler = np.array(sm["liveCalibration"].rpyCalib, dtype=np.float32)
@@ -25,6 +25,18 @@ class TestCameraOffset:
self.camera_offset = CameraOffsetHelper()
self.dc = DEVICE_CAMERAS[('mici', 'os04c10')]
def test_load_offset_resets_out_of_range(self):
class Params:
def __init__(self, v): self.v = v
def get(self, key, return_default=False): return self.v
def put(self, key, v): self.v = v
for stored, used in ((0.2, 0.2), (-0.35, -0.35), (4.0, 0.0), (-35.0, 0.0), (float('nan'), 0.0), (None, 0.0)):
params = Params(stored)
self.camera_offset.load_offset(params)
assert self.camera_offset.camera_offset == used
assert params.v == (stored if used == stored else 0.0)
def test_smoothing(self):
self.camera_offset.set_offset(0.2)