Skip to content

Commit

Permalink
openpilot v0.6.4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Vehicle Researcher committed Sep 9, 2019
1 parent af4f9f1 commit 6122977
Show file tree
Hide file tree
Showing 112 changed files with 2,409 additions and 1,089 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ selfdrive/sensord/sensord

one
openpilot
notebooks
xx

124 changes: 63 additions & 61 deletions README.md

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Version 0.6.4 (2019-09-08)
========================
* Forward stock AEB for Honda Nidec
* Improve lane centering on banked roads
* Always-on forward collision warning
* Always-on driver monitoring, except for right hand drive countries
* Driver monitoring learns the user's normal driving position
* Honda Fit support thanks to energee!
* Lexus IS support

Version 0.6.3 (2019-08-12)
========================
* Alert sounds from EON: requires NEOS update
Expand Down
Binary file modified apk/ai.comma.plus.offroad.apk
Binary file not shown.
14 changes: 11 additions & 3 deletions common/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
from selfdrive.version import version

class Api(object):
def __init__(self, dongle_id, private_key):
def __init__(self, dongle_id):
self.dongle_id = dongle_id
self.private_key = private_key
with open('/persist/comma/id_rsa') as f:
self.private_key = f.read()

def get(self, *args, **kwargs):
return self.request('GET', *args, **kwargs)
Expand All @@ -19,7 +20,14 @@ def request(self, method, endpoint, timeout=None, access_token=None, **params):
return api_get(endpoint, method=method, timeout=timeout, access_token=access_token, **params)

def get_token(self):
return jwt.encode({'identity': self.dongle_id, 'exp': datetime.utcnow() + timedelta(hours=1)}, self.private_key, algorithm='RS256')
now = datetime.utcnow()
payload = {
'identity': self.dongle_id,
'nbf': now,
'iat': now,
'exp': now + timedelta(hours=1)
}
return jwt.encode(payload, self.private_key, algorithm='RS256')

def api_get(endpoint, method='GET', timeout=None, access_token=None, **params):
backend = "https://api.commadotai.com/"
Expand Down
17 changes: 4 additions & 13 deletions common/file_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,12 @@ def rm_tree_or_link(path):
shutil.rmtree(path)

def get_tmpdir_on_same_filesystem(path):
# TODO(mgraczyk): HACK, we should actually check for which filesystem.
normpath = os.path.normpath(path)
parts = normpath.split("/")
if len(parts) > 1:
if parts[1].startswith("raid") or parts[1].startswith("datasets"):
if len(parts) > 2 and parts[2] == "runner":
return "/{}/runner/tmp".format(parts[1])
elif len(parts) > 2 and parts[2] == "aws":
return "/{}/aws/tmp".format(parts[1])
else:
return "/{}/tmp".format(parts[1])
elif parts[1] == "aws":
return "/aws/tmp"
elif parts[1] == "scratch":
return "/scratch/tmp"
if len(parts) > 1 and parts[1] == "scratch":
return "/scratch/tmp"
elif len(parts) > 2 and parts[2] == "runner":
return "/{}/runner/tmp".format(parts[1])
return "/tmp"

class AutoMoveTempdir(object):
Expand Down
15 changes: 13 additions & 2 deletions common/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import shutil
import fcntl
import tempfile
import threading
from enum import Enum


Expand Down Expand Up @@ -63,10 +64,9 @@ class UnknownKeyName(Exception):
"GitCommit": [TxType.PERSISTENT],
"GitRemote": [TxType.PERSISTENT],
"HasAcceptedTerms": [TxType.PERSISTENT],
"IsDriverMonitoringEnabled": [TxType.PERSISTENT],
"IsFcwEnabled": [TxType.PERSISTENT],
"IsGeofenceEnabled": [TxType.PERSISTENT],
"IsMetric": [TxType.PERSISTENT],
"IsRHD": [TxType.PERSISTENT],
"IsUpdateAvailable": [TxType.PERSISTENT],
"IsUploadRawEnabled": [TxType.PERSISTENT],
"IsUploadVideoOverCellularEnabled": [TxType.PERSISTENT],
Expand Down Expand Up @@ -346,6 +346,17 @@ def put(self, key, dat):

write_db(self.db, key, dat)


def put_nonblocking(key, val):
def f(key, val):
params = Params()
params.put(key, val)

t = threading.Thread(target=f, args=(key, val))
t.start()
return t


if __name__ == "__main__":
params = Params()
if len(sys.argv) > 2:
Expand Down
73 changes: 73 additions & 0 deletions common/stat_live.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import numpy as np

class RunningStat():
# tracks realtime mean and standard deviation without storing any data
def __init__(self, priors=None, max_trackable=-1):
self.max_trackable = max_trackable
if priors is not None:
# initialize from history
self.M = priors[0]
self.S = priors[1]
self.n = priors[2]
self.M_last = self.M
self.S_last = self.S

else:
self.reset()

def reset(self):
self.M = 0.
self.S = 0.
self.M_last = 0.
self.S_last = 0.
self.n = 0

def push_data(self, new_data):
# short term memory hack
if self.max_trackable < 0 or self.n < self.max_trackable:
self.n += 1
if self.n == 0:
self.M_last = new_data
self.M = self.M_last
self.S_last = 0.
else:
self.M = self.M_last + (new_data - self.M_last) / self.n
self.S = self.S_last + (new_data - self.M_last) * (new_data - self.M);
self.M_last = self.M
self.S_last = self.S

def mean(self):
return self.M

def variance(self):
if self.n >= 2:
return self.S / (self.n - 1.)
else:
return 0

def std(self):
return np.sqrt(self.variance())

def params_to_save(self):
return [self.M, self.S, self.n]

class RunningStatFilter():
def __init__(self, raw_priors=None, filtered_priors=None, max_trackable=-1):
self.raw_stat = RunningStat(raw_priors, max_trackable)
self.filtered_stat = RunningStat(filtered_priors, max_trackable)

def reset(self):
self.raw_stat.reset()
self.filtered_stat.reset()

def push_and_update(self, new_data):
_std_last = self.raw_stat.std()
self.raw_stat.push_data(new_data)
_delta_std = self.raw_stat.std() - _std_last
if _delta_std<=0:
self.filtered_stat.push_data(new_data)
else:
pass
# self.filtered_stat.push_data(self.filtered_stat.mean())

# class SequentialBayesian():
43 changes: 38 additions & 5 deletions common/transformations/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,40 @@ def rotate_img(img, eulers, crop=None, intrinsics=eon_intrinsics):
W_border: size[1] - W_border]


def get_camera_frame_from_calib_frame(camera_frame_from_road_frame):
camera_frame_from_ground = camera_frame_from_road_frame[:, (0, 1, 3)]
calib_frame_from_ground = np.dot(eon_intrinsics,
get_view_frame_from_road_frame(0, 0, 0, 1.22))[:, (0, 1, 3)]
ground_from_calib_frame = np.linalg.inv(calib_frame_from_ground)
camera_frame_from_calib_frame = np.dot(camera_frame_from_ground, ground_from_calib_frame)
return camera_frame_from_calib_frame


def pretransform_from_calib(calib):
roll, pitch, yaw, height = calib
view_frame_from_road_frame = get_view_frame_from_road_frame(roll, pitch, yaw, height)
camera_frame_from_road_frame = np.dot(eon_intrinsics, view_frame_from_road_frame)
camera_frame_from_calib_frame = get_camera_frame_from_calib_frame(camera_frame_from_road_frame)
return np.linalg.inv(camera_frame_from_calib_frame)


def transform_img(base_img,
augment_trans=np.array([0,0,0]),
augment_eulers=np.array([0,0,0]),
from_intr=eon_intrinsics,
to_intr=eon_intrinsics,
calib_rot_view=None,
output_size=None,
pretransform=None,
top_hacks=True):
top_hacks=False,
yuv=False,
alpha=1.0,
beta=0,
blur=0):
import cv2

if yuv:
base_img = cv2.cvtColor(base_img, cv2.COLOR_YUV2RGB_I420)

size = base_img.shape[:2]
if not output_size:
output_size = size[::-1]
Expand All @@ -180,8 +203,6 @@ def get_M(h=1.22):
h*np.ones(4),
h/quadrangle_norm[:,1]))
rot = orient.rot_from_euler(augment_eulers)
if calib_rot_view is not None:
rot = calib_rot_view.dot(rot)
to_extrinsics = np.hstack((rot.T, -augment_trans[:,None]))
to_KE = to_intr.dot(to_extrinsics)
warped_quadrangle_full = np.einsum('jk,ik->ij', to_KE, np.hstack((quadrangle_world, np.ones((4,1)))))
Expand All @@ -202,7 +223,19 @@ def get_M(h=1.22):
M = M.dot(pretransform)
augmented_rgb[:cyy] = cv2.warpPerspective(base_img, M, (output_size[0], cyy), borderMode=cv2.BORDER_REPLICATE)

return augmented_rgb
# brightness and contrast augment
augmented_rgb = np.clip((float(alpha)*augmented_rgb + beta), 0, 255).astype(np.uint8)

# gaussian blur
if blur > 0:
augmented_rgb = cv2.GaussianBlur(augmented_rgb,(blur*2+1,blur*2+1),cv2.BORDER_DEFAULT)

if yuv:
augmented_img = cv2.cvtColor(augmented_rgb, cv2.COLOR_RGB2YUV_I420)
else:
augmented_img = augmented_rgb
return augmented_img


def yuv_crop(frame, output_size, center=None):
# output_size in camera coordinates so u,v
Expand Down
6 changes: 3 additions & 3 deletions common/transformations/model.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np

from common.transformations.camera import eon_focal_length, \
vp_from_ke, get_view_frame_from_road_frame, \
FULL_FRAME_SIZE
from common.transformations.camera import (FULL_FRAME_SIZE, eon_focal_length,
get_view_frame_from_road_frame,
vp_from_ke)

# segnet

Expand Down
Binary file modified installer/updater/updater
Binary file not shown.
Loading

0 comments on commit 6122977

Please sign in to comment.