Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move calibration values #441

Merged
merged 3 commits into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,12 @@
from selfdrive.controls.lib.alertmanager import AlertManager
from selfdrive.controls.lib.vehicle_model import VehicleModel
from selfdrive.controls.lib.driver_monitor import DriverStatus
from selfdrive.locationd.calibration_values import Calibration, Filter

ThermalStatus = log.ThermalData.ThermalStatus
State = log.Live100Data.ControlState


class Calibration:
UNCALIBRATED = 0
CALIBRATED = 1
INVALID = 2


def isActive(state):
"""Check if the actuators are enabled"""
return state in [State.enabled, State.softDisabling]
Expand Down Expand Up @@ -293,7 +288,10 @@ def state_control(plan, CS, CP, state, events, v_cruise_kph, v_cruise_kph_last,
extra_text_1, extra_text_2 = "", ""
if e == "calibrationIncomplete":
extra_text_1 = str(cal_perc) + "%"
extra_text_2 = "35 kph" if is_metric else "15 mph"
if is_metric:
extra_text_2 = str(int(round(Filter.MIN_SPEED * CV.MS_TO_KPH))) + " kph"
else:
extra_text_2 = str(int(round(Filter.MIN_SPEED * CV.MS_TO_MPH))) + " mph"
AM.add(str(e) + "Permanent", enabled, extra_text_1=extra_text_1, extra_text_2=extra_text_2)

AM.process_alerts(sec_since_boot())
Expand Down
11 changes: 11 additions & 0 deletions selfdrive/locationd/calibration_values.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import math

class Filter:
MIN_SPEED = 7 # m/s (~15.5mph)
MAX_YAW_RATE = math.radians(3) # per second

class Calibration:
UNCALIBRATED = 0
CALIBRATED = 1
INVALID = 2

14 changes: 3 additions & 11 deletions selfdrive/locationd/calibrationd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import zmq
import cv2
import copy
import math
import json
import numpy as np
import selfdrive.messaging as messaging
from selfdrive.locationd.calibration_values import Calibration, Filter
from selfdrive.swaglog import cloudlog
from selfdrive.services import service_list
from common.params import Params
Expand All @@ -17,8 +17,6 @@
eon_intrinsics, get_calib_from_vp, normalize, denormalize, H, W


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


class Calibration:
UNCALIBRATED = 0
CALIBRATED = 1
INVALID = 2


def increment_grid_c(grid, lines, n):
lib.increment_grid(ffi.cast("double *", grid.ctypes.data),
ffi.cast("double *", lines.ctypes.data),
Expand Down Expand Up @@ -131,8 +123,8 @@ def rescale_grid(self):

def update(self, uvs, yaw_rate, speed):
if len(uvs) < 10 or \
abs(yaw_rate) > MAX_YAW_RATE_FILTER or \
speed < MIN_SPEED_FILTER:
abs(yaw_rate) > Filter.MAX_YAW_RATE or \
speed < Filter.MIN_SPEED:
return
rot_speeds = np.array([0.,0.,-yaw_rate])
uvs[:,1,:] = denormalize(correct_pts(normalize(uvs[:,1,:]), rot_speeds, self.dt))
Expand Down