Skip to content

Commit

Permalink
Merge pull request #100 from icmma/cherrypick
Browse files Browse the repository at this point in the history
Cherrypick
  • Loading branch information
icmma authored Feb 18, 2019
2 parents 8e1701c + 7af1a0d commit d83ea54
Show file tree
Hide file tree
Showing 588 changed files with 113,137 additions and 2,470 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

Our software is open source so you can solve your own problems without needing help from others. And if you solve a problem and are so kind, you can upstream it for the rest of the world to use.

Most open source development activity is coordinated through our [slack](https://slack.comma.ai). A lot of documentation is available on our [medium](https://medium.com/@comma_ai/)
Most open source development activity is coordinated through our [Discord](https://discord.comma.ai). A lot of documentation is available on our [medium](https://medium.com/@comma_ai/)

## Getting Started

* Join our slack [slack.comma.ai](https://slack.comma.ai)
* Join our [Discord](https://discord.comma.ai)
* Make sure you have a [GitHub account](https://github.com/signup/free)
* Fork [our repositories](https://github.com/commaai) on GitHub

Expand Down
21 changes: 20 additions & 1 deletion Dockerfile.openpilot
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
FROM ubuntu:16.04
ENV PYTHONUNBUFFERED 1

RUN apt-get update && apt-get install -y build-essential clang vim screen wget bzip2 git libglib2.0-0 python-pip capnproto libcapnp-dev libzmq5-dev libffi-dev libusb-1.0-0
RUN apt-get update && apt-get install -y \
build-essential \
clang \
vim \
screen \
wget \
bzip2 \
git \
libglib2.0-0 \
python-pip \
capnproto \
libcapnp-dev \
libzmq5-dev \
libffi-dev \
libusb-1.0-0 \
libssl-dev \
ocl-icd-libopencl1 \
ocl-icd-opencl-dev \
opencl-headers

RUN pip install numpy==1.11.2 scipy==0.18.1 matplotlib==2.1.2

COPY requirements_openpilot.txt /tmp/
Expand Down
121 changes: 61 additions & 60 deletions README.md

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
Version 0.5.8 (2019-01-17)
========================
* Open sourced visiond
* Auto-slowdown for upcoming turns
* Chrysler/Jeep/Fiat support thanks to adhintz!
* Honda Civic 2019 support thanks to csouers!
* Improved use of car display in Toyota thanks to arne182!
* No data upload when connected to Android or iOS hotspots and "Enable Upload Over Cellular" setting is off
* EON stops charging when 12V battery drops below 11.8V

Version 0.5.7 (2018-12-06)
========================
* Speed limit from OpenStreetMap added to UI
* Highlight speed limit when speed exceeds road speed limit plus a delta
* Option to limit openpilot max speed to road speed limit plus a delta
* Cadillac ATS support thanks to vntarasov!
* GMC Acadia support thanks to CryptoKylan!
* Decrease GPU power consumption
* NEOSv8 autoupdate

Version 0.5.6 (2018-11-16)
========================
* Refresh settings layout and add feature descriptions
Expand All @@ -7,6 +27,7 @@ Version 0.5.6 (2018-11-16)
* More tuning to Honda positive accelerations
* Reduce brake pump use on Hondas
* Chevrolet Malibu support thanks to tylergets!
* Holden Astra support thanks to AlexHill!

Version 0.5.5 (2018-10-20)
========================
Expand Down
Binary file modified apk/ai.comma.plus.frame.apk
Binary file not shown.
Binary file modified apk/ai.comma.plus.offroad.apk
Binary file not shown.
7 changes: 5 additions & 2 deletions cereal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ GENS := gen/cpp/car.capnp.c++ gen/cpp/log.capnp.c++
JS := gen/js/car.capnp.js gen/js/log.capnp.js

UNAME_M ?= $(shell uname -m)

# only generate C++ for docker tests
ifneq ($(OPTEST),1)
GENS += gen/c/car.capnp.c gen/c/log.capnp.c gen/c/include/c++.capnp.h gen/c/include/java.capnp.h

ifeq ($(UNAME_M),x86_64)
GENS += gen/java/Car.java gen/java/Log.java
ifneq (, $(shell which capnpc-java))
GENS += gen/java/Car.java gen/java/Log.java
else
$(warning capnpc-java not found, skipping java build)
endif
endif

endif
Expand Down
3 changes: 3 additions & 0 deletions cereal/car.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ struct CarControl {
leadVisible @3: Bool;
visualAlert @4: VisualAlert;
audibleAlert @5: AudibleAlert;
rightLaneVisible @6: Bool;
leftLaneVisible @7: Bool;

enum VisualAlert {
# these are the choices from the Honda
Expand Down Expand Up @@ -355,6 +357,7 @@ struct CarParams {
radarOffCan @47 :Bool; # True when radar objects aren't visible on CAN

steerActuatorDelay @48 :Float32; # Steering wheel actuator delay in seconds
openpilotLongitudinalControl @50 :Bool; # is openpilot doing the longitudinal control?

enum SteerControlType {
torque @0;
Expand Down
44 changes: 38 additions & 6 deletions cereal/log.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ struct SensorEventData {
iOS @1;
fiber @2;
velodyne @3; # Velodyne IMU
# c3 sensors below
bno055 @4;
lsm6ds3 @5;
bmp280 @6;
bno055 @4; # Bosch accelerometer
lsm6ds3 @5; # accelerometer (c2)
bmp280 @6; # barometer (c2)
mmc3416x @7; # magnetometer (c2)
}
}

Expand Down Expand Up @@ -276,7 +276,8 @@ struct ThermalData {
startedTs @13 :UInt64;

thermalStatus @14 :ThermalStatus;
chargerDisabled @17 :Bool;
chargingError @17 :Bool;
chargingDisabled @18 :Bool;

enum ThermalStatus {
green @0; # all processes run
Expand Down Expand Up @@ -344,6 +345,7 @@ struct LiveCalibrationData {
warpMatrix @0 :List(Float32);
# camera_frame_from_model_frame
warpMatrix2 @5 :List(Float32);
warpMatrixBig @6 :List(Float32);
calStatus @1 :Int8;
calCycle @2 :Int32;
calPerc @3 :Int8;
Expand Down Expand Up @@ -397,6 +399,8 @@ struct Live100Data {
curvature @37 :Float32; # path curvature from vehicle model
hudLeadDEPRECATED @14 :Int32;
cumLagMs @15 :Float32;
startMonoTime @48 :UInt64;
mapValid @49 :Bool;

enabled @19 :Bool;
active @36 :Bool;
Expand All @@ -418,6 +422,10 @@ struct Live100Data {
engageable @41 :Bool; # can OP be engaged?
driverMonitoringOn @43 :Bool;

# maps
vCurvature @46 :Float32;
decelForTurn @47 :Bool;

enum ControlState {
disabled @0;
preEnabled @1;
Expand Down Expand Up @@ -554,6 +562,8 @@ struct Plan {
aTarget @18 :Float32;
jerkFactor @6 :Float32;
hasLead @7 :Bool;
hasLeftLane @23 :Bool;
hasRightLane @24 :Bool;
fcw @8 :Bool;
longitudinalPlanSource @15 :LongitudinalPlanSource;

Expand All @@ -562,6 +572,11 @@ struct Plan {

gpsPlannerActive @19 :Bool;

# maps
vCurvature @21 :Float32;
decelForTurn @22 :Bool;
mapValid @25 :Bool;

struct GpsTrajectory {
x @0 :List(Float32);
y @1 :List(Float32);
Expand Down Expand Up @@ -1567,10 +1582,26 @@ struct LiveParametersData {
}

struct LiveMapData {
valid @0 :Bool;
speedLimitValid @0 :Bool;
speedLimit @1 :Float32;
curvatureValid @2 :Bool;
curvature @3 :Float32;
wayId @4 :UInt64;
roadX @5 :List(Float32);
roadY @6 :List(Float32);
lastGps @7: GpsLocationData;
roadCurvatureX @8 :List(Float32);
roadCurvature @9 :List(Float32);
distToTurn @10 :Float32;
mapValid @11 :Bool;
}

struct CameraOdometry {
trans @0 :List(Float32); # m/s in device frame
rot @1 :List(Float32); # rad/s in device frame
transStd @2 :List(Float32); # std m/s in device frame
rotStd @3 :List(Float32); # std rad/s in device frame
}

struct Event {
# in nanoseconds?
Expand Down Expand Up @@ -1639,5 +1670,6 @@ struct Event {
boot @60 :Boot;
liveParameters @61 :LiveParametersData;
liveMapData @62 :LiveMapData;
cameraOdometry @63 :CameraOdometry;
}
}
3 changes: 3 additions & 0 deletions common/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class UnknownKeyName(Exception):
"IsUploadVideoOverCellularEnabled": TxType.PERSISTENT,
"IsDriverMonitoringEnabled": TxType.PERSISTENT,
"IsGeofenceEnabled": TxType.PERSISTENT,
"SpeedLimitOffset": TxType.PERSISTENT,
# written: visiond
# read: visiond, controlsd
"CalibrationParams": TxType.PERSISTENT,
Expand All @@ -74,6 +75,8 @@ class UnknownKeyName(Exception):
"DoUninstall": TxType.CLEAR_ON_MANAGER_START,
"ShouldDoUpdate": TxType.CLEAR_ON_MANAGER_START,
"IsUpdateAvailable": TxType.PERSISTENT,
"LongitudinalControl": TxType.PERSISTENT,
"LimitSetSpeed": TxType.PERSISTENT,

"RecordFront": TxType.PERSISTENT,
}
Expand Down
41 changes: 37 additions & 4 deletions common/transformations/camera.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import common.transformations.orientation as orient
import cv2

FULL_FRAME_SIZE = (1164, 874)
W, H = FULL_FRAME_SIZE[0], FULL_FRAME_SIZE[1]
Expand Down Expand Up @@ -62,31 +63,35 @@ def roll_from_ke(m):
return np.arctan2(-(m[1, 0] - m[1, 1] * m[2, 0] / m[2, 1]),
-(m[0, 0] - m[0, 1] * m[2, 0] / m[2, 1]))

def normalize(img_pts):

def normalize(img_pts, intrinsics=eon_intrinsics):
# normalizes image coordinates
# accepts single pt or array of pts
intrinsics_inv = np.linalg.inv(intrinsics)
img_pts = np.array(img_pts)
input_shape = img_pts.shape
img_pts = np.atleast_2d(img_pts)
img_pts = np.hstack((img_pts, np.ones((img_pts.shape[0],1))))
img_pts_normalized = eon_intrinsics_inv.dot(img_pts.T).T
img_pts_normalized = intrinsics_inv.dot(img_pts.T).T
img_pts_normalized[(img_pts < 0).any(axis=1)] = np.nan
return img_pts_normalized[:,:2].reshape(input_shape)

def denormalize(img_pts):

def denormalize(img_pts, intrinsics=eon_intrinsics):
# denormalizes image coordinates
# accepts single pt or array of pts
img_pts = np.array(img_pts)
input_shape = img_pts.shape
img_pts = np.atleast_2d(img_pts)
img_pts = np.hstack((img_pts, np.ones((img_pts.shape[0],1))))
img_pts_denormalized = eon_intrinsics.dot(img_pts.T).T
img_pts_denormalized = intrinsics.dot(img_pts.T).T
img_pts_denormalized[img_pts_denormalized[:,0] > W] = np.nan
img_pts_denormalized[img_pts_denormalized[:,0] < 0] = np.nan
img_pts_denormalized[img_pts_denormalized[:,1] > H] = np.nan
img_pts_denormalized[img_pts_denormalized[:,1] < 0] = np.nan
return img_pts_denormalized[:,:2].reshape(input_shape)


def device_from_ecef(pos_ecef, orientation_ecef, pt_ecef):
# device from ecef frame
# device frame is x -> forward, y-> right, z -> down
Expand All @@ -99,6 +104,7 @@ def device_from_ecef(pos_ecef, orientation_ecef, pt_ecef):
pt_device = np.einsum('jk,ik->ij', device_from_ecef_rot, pt_ecef_rel)
return pt_device.reshape(input_shape)


def img_from_device(pt_device):
# img coordinates from pts in device frame
# first transforms to view frame, then to img coords
Expand All @@ -113,3 +119,30 @@ def img_from_device(pt_device):
pt_img = pt_view/pt_view[:,2:3]
return pt_img.reshape(input_shape)[:,:2]


def rotate_img(img, eulers, crop=None, intrinsics=eon_intrinsics):
size = img.shape[:2]
rot = orient.rot_from_euler(eulers)
quadrangle = np.array([[0, 0],
[size[1]-1, 0],
[0, size[0]-1],
[size[1]-1, size[0]-1]], dtype=np.float32)
quadrangle_norm = np.hstack((normalize(quadrangle, intrinsics=intrinsics), np.ones((4,1))))
warped_quadrangle_full = np.einsum('ij, kj->ki', intrinsics.dot(rot), quadrangle_norm)
warped_quadrangle = np.column_stack((warped_quadrangle_full[:,0]/warped_quadrangle_full[:,2],
warped_quadrangle_full[:,1]/warped_quadrangle_full[:,2])).astype(np.float32)
if crop:
W_border = (size[1] - crop[0])/2
H_border = (size[0] - crop[1])/2
outside_crop = (((warped_quadrangle[:,0] < W_border) |
(warped_quadrangle[:,0] >= size[1] - W_border)) &
((warped_quadrangle[:,1] < H_border) |
(warped_quadrangle[:,1] >= size[0] - H_border)))
if not outside_crop.all():
raise ValueError("warped image not contained inside crop")
else:
H_border, W_border = 0, 0
M = cv2.getPerspectiveTransform(quadrangle, warped_quadrangle)
img_warped = cv2.warpPerspective(img, M, size[::-1])
return img_warped[H_border: size[0] - H_border,
W_border: size[1] - W_border]
2 changes: 1 addition & 1 deletion common/transformations/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def get_model_height_transform(camera_frame_from_road_frame, height):

# camera_frame_from_model_frame aka 'warp matrix'
# was: calibration.h/CalibrationTransform
def get_camera_frame_from_model_frame(camera_frame_from_road_frame, height):
def get_camera_frame_from_model_frame(camera_frame_from_road_frame, height=model_height):
vp = vp_from_ke(camera_frame_from_road_frame)

model_camera_from_model_frame = np.array([
Expand Down
2 changes: 2 additions & 0 deletions common/transformations/orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ def ned_euler_from_ecef(ned_ecef_init, ecef_poses):
ecef_poses = array(ecef_poses)
output_shape = ecef_poses.shape
ned_ecef_init = np.atleast_2d(ned_ecef_init)
if ned_ecef_init.shape[0] == 1:
ned_ecef_init = np.tile(ned_ecef_init[0], (output_shape[0], 1))
ecef_poses = np.atleast_2d(ecef_poses)

ned_poses = np.zeros(ecef_poses.shape)
Expand Down
Binary file modified installer/updater/updater
Binary file not shown.
Binary file added models/driving_model.dlc
Binary file not shown.
Binary file added models/monitoring_model.dlc
Binary file not shown.
Loading

0 comments on commit d83ea54

Please sign in to comment.