Skip to content

Commit

Permalink
Merge pull request commaai#202 from commaai/devel
Browse files Browse the repository at this point in the history
update devel to latest
  • Loading branch information
sshane committed Nov 9, 2019
2 parents 8d5c9d2 + d4eb5a6 commit 0bb87e0
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 9 deletions.
2 changes: 1 addition & 1 deletion selfdrive/can/process_dbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def main():
msgs = [(address, msg_name, msg_size, sorted(msg_sigs, key=lambda s: s.name not in ("COUNTER", "CHECKSUM"))) # process counter and checksums first
for address, ((msg_name, msg_size), msg_sigs) in sorted(can_dbc.msgs.items()) if msg_sigs]

def_vals = {a: set(b) for a,b in can_dbc.def_vals.items()} #remove duplicates
def_vals = {a: sorted(set(b)) for a, b in can_dbc.def_vals.items()} # remove duplicates
def_vals = sorted(def_vals.items())

if can_dbc.name.startswith(("honda_", "acura_")):
Expand Down
7 changes: 6 additions & 1 deletion selfdrive/car/toyota/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ class ECU:
# 2019 Taiwan Altis Hybrid
{
36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 765: 8, 800: 8, 810: 2, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 885: 8, 896: 8, 898: 8, 918: 7, 921: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 987: 8, 993: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1082: 8, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1172: 8, 1235: 8, 1237: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1745: 8, 1775: 8, 1779: 8
}],
},
# 2019 Chinese Levin Hybrid
{
36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 765: 8, 800: 8, 810: 2, 812: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 885: 8, 896: 8, 898: 8, 921: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 1002: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1172: 8, 1235: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1600: 8, 1649: 8, 1745: 8, 1775: 8, 1779: 8
}
],
CAR.LEXUS_ES_TSS2: [{
36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 765: 8, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 824: 8, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 889: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 987: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1575: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1696: 8, 1775: 8, 1777: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8
}],
Expand Down
89 changes: 89 additions & 0 deletions selfdrive/common/visionbuf_cl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#include "visionbuf.h"

#include <fcntl.h>
#include <assert.h>
#include <stdlib.h>

#ifdef __APPLE__
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif

VisionBuf visionbuf_allocate(size_t len) {
// const size_t alignment = 4096;
// void* addr = aligned_alloc(alignment, alignment * ((len - 1) / alignment + 1));
void* addr = calloc(1, len);

return (VisionBuf){
.len = len, .addr = addr, .handle = 1, .fd = -1,
};
}

cl_mem visionbuf_to_cl(const VisionBuf* buf, cl_device_id device_id, cl_context ctx) {
// HACK because this platform is just for convenience
VisionBuf *w_buf = (VisionBuf*)buf;
cl_mem ret;
*w_buf = visionbuf_allocate_cl(buf->len, device_id, ctx, &ret);
return ret;
}

VisionBuf visionbuf_allocate_cl(size_t len, cl_device_id device_id, cl_context ctx, cl_mem *out_mem) {
int err;
assert(out_mem);

#if __OPENCL_VERSION__ >= 200
void* host_ptr =
clSVMAlloc(ctx, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER, len, 0);
assert(host_ptr);
#else
void* host_ptr = calloc(1, len);

cl_command_queue q = clCreateCommandQueue(ctx, device_id, 0, &err);
assert(err == 0);
#endif

cl_mem mem = clCreateBuffer(ctx, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, len, host_ptr, &err);
assert(err == 0);

*out_mem = mem;

return (VisionBuf){
.len = len, .addr = host_ptr, .handle = 0, .fd = -1,
.device_id = device_id, .ctx = ctx, .buf_cl = mem,

#if __OPENCL_VERSION__ < 200
.copy_q = q,
#endif

};
}

void visionbuf_sync(const VisionBuf* buf, int dir) {
int err = 0;
if (!buf->buf_cl) return;

#if __OPENCL_VERSION__ < 200
if (dir == VISIONBUF_SYNC_FROM_DEVICE) {
err = clEnqueueReadBuffer(buf->copy_q, buf->buf_cl, CL_FALSE, 0, buf->len, buf->addr, 0, NULL, NULL);
} else {
err = clEnqueueWriteBuffer(buf->copy_q, buf->buf_cl, CL_FALSE, 0, buf->len, buf->addr, 0, NULL, NULL);
}
assert(err == 0);
clFinish(buf->copy_q);
#endif
}

void visionbuf_free(const VisionBuf* buf) {
if (buf->handle) {
free(buf->addr);
} else {
int err = clReleaseMemObject(buf->buf_cl);
assert(err == 0);
#if __OPENCL_VERSION__ >= 200
clSVMFree(buf->ctx, buf->addr);
#else
free(buf->addr);
#endif
}
}
6 changes: 3 additions & 3 deletions selfdrive/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ def manager_thread():
running_list = [" running %s %s" % (p, running[p]) for p in running]
cloudlog.debug('\n'.join(running_list))

# is this still needed?
if params.get("DoUninstall") == "1":
# Exit main loop when uninstall is needed
if params.get("DoUninstall", encoding='utf8') == "1":
break

def get_installed_apks():
Expand Down Expand Up @@ -555,7 +555,7 @@ def main():
finally:
cleanup_all_processes(None, None)

if params.get("DoUninstall") == "1":
if params.get("DoUninstall", encoding='utf8') == "1":
uninstall()

if __name__ == "__main__":
Expand Down
8 changes: 4 additions & 4 deletions selfdrive/visiond/build_from_src.mk
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ else

OPENCL_LIBS = -lOpenCL

TF_FLAGS = -I$(EXTERNAL)/tensorflow/include
TF_LIBS = -L$(EXTERNAL)/tensorflow/lib -ltensorflow \
-Wl,-rpath $(EXTERNAL)/tensorflow/lib
#TF_FLAGS = -I$(EXTERNAL)/tensorflow/include
#TF_LIBS = -L$(EXTERNAL)/tensorflow/lib -ltensorflow \
# -Wl,-rpath $(EXTERNAL)/tensorflow/lib

SNPE_FLAGS = -I$(PHONELIBS)/snpe/include/
SNPE_LIBS = -L$(PHONELIBS)/snpe/x86_64-linux-clang/ \
Expand All @@ -69,7 +69,7 @@ else
PLATFORM_OBJS = cameras/camera_frame_stream.o \
../common/visionbuf_cl.o \
../common/visionimg.o \
runners/tfmodel.o
# runners/tfmodel.o
endif

SSL_FLAGS = -I/usr/include/openssl/
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/visiond/cameras/camera_frame_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ typedef struct CameraState {
int fps;
float digital_gain;

float cur_gain_frac;

mat3 transform;
} CameraState;

Expand Down

0 comments on commit 0bb87e0

Please sign in to comment.