Skip to content

Commit 53c6ca6

Browse files
dek3rrrbiasini
authored andcommitted
Move calibration values (#441)
* initial commit * moved constants
1 parent e4ed489 commit 53c6ca6

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

selfdrive/controls/controlsd.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,12 @@
2525
from selfdrive.controls.lib.alertmanager import AlertManager
2626
from selfdrive.controls.lib.vehicle_model import VehicleModel
2727
from selfdrive.controls.lib.driver_monitor import DriverStatus
28+
from selfdrive.locationd.calibration_values import Calibration, Filter
2829

2930
ThermalStatus = log.ThermalData.ThermalStatus
3031
State = log.Live100Data.ControlState
3132

3233

33-
class Calibration:
34-
UNCALIBRATED = 0
35-
CALIBRATED = 1
36-
INVALID = 2
37-
38-
3934
def isActive(state):
4035
"""Check if the actuators are enabled"""
4136
return state in [State.enabled, State.softDisabling]
@@ -293,7 +288,10 @@ def state_control(plan, CS, CP, state, events, v_cruise_kph, v_cruise_kph_last,
293288
extra_text_1, extra_text_2 = "", ""
294289
if e == "calibrationIncomplete":
295290
extra_text_1 = str(cal_perc) + "%"
296-
extra_text_2 = "35 kph" if is_metric else "15 mph"
291+
if is_metric:
292+
extra_text_2 = str(int(round(Filter.MIN_SPEED * CV.MS_TO_KPH))) + " kph"
293+
else:
294+
extra_text_2 = str(int(round(Filter.MIN_SPEED * CV.MS_TO_MPH))) + " mph"
297295
AM.add(str(e) + "Permanent", enabled, extra_text_1=extra_text_1, extra_text_2=extra_text_2)
298296

299297
AM.process_alerts(sec_since_boot())
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import math
2+
3+
class Filter:
4+
MIN_SPEED = 7 # m/s (~15.5mph)
5+
MAX_YAW_RATE = math.radians(3) # per second
6+
7+
class Calibration:
8+
UNCALIBRATED = 0
9+
CALIBRATED = 1
10+
INVALID = 2
11+

selfdrive/locationd/calibrationd.py

+3-11
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import zmq
44
import cv2
55
import copy
6-
import math
76
import json
87
import numpy as np
98
import selfdrive.messaging as messaging
9+
from selfdrive.locationd.calibration_values import Calibration, Filter
1010
from selfdrive.swaglog import cloudlog
1111
from selfdrive.services import service_list
1212
from common.params import Params
@@ -17,8 +17,6 @@
1717
eon_intrinsics, get_calib_from_vp, normalize, denormalize, H, W
1818

1919

20-
MIN_SPEED_FILTER = 7 # m/s (~15.5mph)
21-
MAX_YAW_RATE_FILTER = math.radians(3) # per second
2220
FRAMES_NEEDED = 120 # allow to update VP every so many frames
2321
VP_CYCLES_NEEDED = 2
2422
CALIBRATION_CYCLES_NEEDED = FRAMES_NEEDED * VP_CYCLES_NEEDED
@@ -42,12 +40,6 @@
4240
ffi, lib = ffi_wrap('get_vp', c_code, c_header)
4341

4442

45-
class Calibration:
46-
UNCALIBRATED = 0
47-
CALIBRATED = 1
48-
INVALID = 2
49-
50-
5143
def increment_grid_c(grid, lines, n):
5244
lib.increment_grid(ffi.cast("double *", grid.ctypes.data),
5345
ffi.cast("double *", lines.ctypes.data),
@@ -131,8 +123,8 @@ def rescale_grid(self):
131123

132124
def update(self, uvs, yaw_rate, speed):
133125
if len(uvs) < 10 or \
134-
abs(yaw_rate) > MAX_YAW_RATE_FILTER or \
135-
speed < MIN_SPEED_FILTER:
126+
abs(yaw_rate) > Filter.MAX_YAW_RATE or \
127+
speed < Filter.MIN_SPEED:
136128
return
137129
rot_speeds = np.array([0.,0.,-yaw_rate])
138130
uvs[:,1,:] = denormalize(correct_pts(normalize(uvs[:,1,:]), rot_speeds, self.dt))

0 commit comments

Comments
 (0)