commit
cd10722753
188 changed files with 2766 additions and 1855 deletions
@ -1 +1 @@ |
||||
Subproject commit 032aca6ca38a342e26fb9cc986b7f72b91cd9b55 |
||||
Subproject commit c4a1c9fa00c5915fbdf7f6c29f5968dfc1be0630 |
@ -1,23 +0,0 @@ |
||||
import os |
||||
import sysconfig |
||||
from Cython.Distutils import build_ext |
||||
|
||||
def get_ext_filename_without_platform_suffix(filename): |
||||
name, ext = os.path.splitext(filename) |
||||
ext_suffix = sysconfig.get_config_var('EXT_SUFFIX') |
||||
|
||||
if ext_suffix == ext: |
||||
return filename |
||||
|
||||
ext_suffix = ext_suffix.replace(ext, '') |
||||
idx = name.find(ext_suffix) |
||||
|
||||
if idx == -1: |
||||
return filename |
||||
else: |
||||
return name[:idx] + ext |
||||
|
||||
class BuildExtWithoutPlatformSuffix(build_ext): |
||||
def get_ext_filename(self, ext_name): |
||||
filename = super().get_ext_filename(ext_name) |
||||
return get_ext_filename_without_platform_suffix(filename) |
@ -1,3 +1,3 @@ |
||||
version https://git-lfs.github.com/spec/v1 |
||||
oid sha256:9e2d3a3b513bf3d0ea4255fc41d57e84b141643fd3d47268c33862110387ea05 |
||||
size 56685051 |
||||
oid sha256:ebb75bbd4c19994752f038f181359dce358a2c95c4ad1760d2d1ee346a45503d |
||||
size 56684955 |
||||
|
@ -1,3 +1,3 @@ |
||||
version https://git-lfs.github.com/spec/v1 |
||||
oid sha256:43d362484b134fce8d05ff0cb0971c53ceee64d96a4d97c1b6d19cc849f40588 |
||||
size 56707084 |
||||
oid sha256:6e004a9ff90304fd3dfd661f3f52886affa677d486ff78c131d8a4887757b5f1 |
||||
size 57552499 |
||||
|
@ -1 +1 @@ |
||||
Subproject commit 76dc825ad8329bdc3fff97583ad88a7af81c7e2e |
||||
Subproject commit b0bc1b5197c63231c7af9e22929c8d41212631b6 |
@ -0,0 +1,16 @@ |
||||
#!/bin/bash |
||||
|
||||
set -e |
||||
|
||||
RED="\033[0;31m" |
||||
GREEN="\033[0;32m" |
||||
CLEAR="\033[0m" |
||||
|
||||
BRANCHES="devel dashcam dashcam3 release2 release3" |
||||
for b in $BRANCHES; do |
||||
if git diff --quiet origin/$b origin/$b-staging && [ "$(git rev-parse origin/$b)" = "$(git rev-parse origin/$b-staging)" ]; then |
||||
printf "%-10s $GREEN ok $CLEAR\n" "$b" |
||||
else |
||||
printf "%-10s $RED mismatch $CLEAR\n" "$b" |
||||
fi |
||||
done |
@ -0,0 +1,11 @@ |
||||
#!/bin/bash |
||||
|
||||
if [ $# -eq 0 ]; then |
||||
echo "usage: $0 <pull-request-number>" |
||||
exit 1 |
||||
fi |
||||
|
||||
BASE="https://github.com/commaai/openpilot/pull/" |
||||
PR_NUM="$(echo $1 | grep -o -E '[0-9]+')" |
||||
|
||||
curl -L $BASE/$PR_NUM.patch | git apply |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +1,3 @@ |
||||
boardd |
||||
boardd_api_impl.cpp |
||||
tests/test_boardd_usbprotocol |
||||
|
@ -1,6 +1,9 @@ |
||||
Import('env', 'envCython', 'common', 'cereal', 'messaging') |
||||
|
||||
env.Program('boardd', ['boardd.cc', 'panda.cc', 'pigeon.cc'], LIBS=['usb-1.0', common, cereal, messaging, 'pthread', 'zmq', 'capnp', 'kj']) |
||||
libs = ['usb-1.0', common, cereal, messaging, 'pthread', 'zmq', 'capnp', 'kj'] |
||||
env.Program('boardd', ['boardd.cc', 'panda.cc', 'pigeon.cc'], LIBS=libs) |
||||
env.Library('libcan_list_to_can_capnp', ['can_list_to_can_capnp.cc']) |
||||
|
||||
envCython.Program('boardd_api_impl.so', 'boardd_api_impl.pyx', LIBS=["can_list_to_can_capnp", 'capnp', 'kj'] + envCython["LIBS"]) |
||||
if GetOption('test'): |
||||
env.Program('tests/test_boardd_usbprotocol', ['tests/test_boardd_usbprotocol.cc', 'panda.cc'], LIBS=libs) |
||||
|
@ -0,0 +1,130 @@ |
||||
#define CATCH_CONFIG_MAIN |
||||
#define CATCH_CONFIG_ENABLE_BENCHMARKING |
||||
#include <random> |
||||
|
||||
#include "catch2/catch.hpp" |
||||
#include "cereal/messaging/messaging.h" |
||||
#include "selfdrive/boardd/panda.h" |
||||
|
||||
const unsigned char dlc_to_len[] = {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 12U, 16U, 20U, 24U, 32U, 48U, 64U}; |
||||
|
||||
int random_int(int min, int max) { |
||||
std::random_device dev; |
||||
std::mt19937 rng(dev()); |
||||
std::uniform_int_distribution<std::mt19937::result_type> dist(min, max); |
||||
return dist(rng); |
||||
} |
||||
|
||||
struct PandaTest : public Panda { |
||||
PandaTest(uint32_t bus_offset, int can_list_size, cereal::PandaState::PandaType hw_type); |
||||
void test_can_send(); |
||||
void test_can_recv(); |
||||
|
||||
std::map<int, std::string> test_data; |
||||
int can_list_size = 0; |
||||
int total_pakets_size = 0; |
||||
MessageBuilder msg; |
||||
capnp::List<cereal::CanData>::Reader can_data_list; |
||||
}; |
||||
|
||||
PandaTest::PandaTest(uint32_t bus_offset_, int can_list_size, cereal::PandaState::PandaType hw_type) : can_list_size(can_list_size), Panda(bus_offset_) { |
||||
this->hw_type = hw_type; |
||||
int data_limit = ((hw_type == cereal::PandaState::PandaType::RED_PANDA) ? std::size(dlc_to_len) : 8); |
||||
// prepare test data
|
||||
for (int i = 0; i < data_limit; ++i) { |
||||
std::random_device rd; |
||||
std::independent_bits_engine<std::default_random_engine, CHAR_BIT, unsigned char> rbe(rd()); |
||||
|
||||
int data_len = dlc_to_len[i]; |
||||
std::string bytes(data_len, '\0'); |
||||
std::generate(bytes.begin(), bytes.end(), std::ref(rbe)); |
||||
test_data[data_len] = bytes; |
||||
} |
||||
|
||||
// generate can messages for this panda
|
||||
auto can_list = msg.initEvent().initSendcan(can_list_size); |
||||
for (uint8_t i = 0; i < can_list_size; ++i) { |
||||
auto can = can_list[i]; |
||||
uint32_t id = random_int(0, std::size(dlc_to_len) - 1); |
||||
const std::string &dat = test_data[dlc_to_len[id]]; |
||||
can.setAddress(i); |
||||
can.setSrc(random_int(0, 3) + bus_offset); |
||||
can.setDat(kj::ArrayPtr((uint8_t *)dat.data(), dat.size())); |
||||
total_pakets_size += CANPACKET_HEAD_SIZE + dat.size(); |
||||
} |
||||
|
||||
can_data_list = can_list.asReader(); |
||||
INFO("test " << can_list_size << " packets, total size " << total_pakets_size); |
||||
} |
||||
|
||||
void PandaTest::test_can_send() { |
||||
std::vector<uint8_t> unpacked_data; |
||||
this->pack_can_buffer(can_data_list, [&](uint8_t *chunk, size_t size) { |
||||
int size_left = size; |
||||
for (int i = 0, counter = 0; i < size; i += USBPACKET_MAX_SIZE, counter++) { |
||||
REQUIRE(chunk[i] == counter); |
||||
|
||||
const int len = std::min(USBPACKET_MAX_SIZE, size_left); |
||||
unpacked_data.insert(unpacked_data.end(), &chunk[i + 1], &chunk[i + len]); |
||||
size_left -= len; |
||||
} |
||||
}); |
||||
REQUIRE(unpacked_data.size() == total_pakets_size); |
||||
|
||||
int cnt = 0; |
||||
INFO("test can message integrity"); |
||||
for (int pos = 0, pckt_len = 0; pos < unpacked_data.size(); pos += pckt_len) { |
||||
can_header header; |
||||
memcpy(&header, &unpacked_data[pos], CANPACKET_HEAD_SIZE); |
||||
const uint8_t data_len = dlc_to_len[header.data_len_code]; |
||||
pckt_len = CANPACKET_HEAD_SIZE + data_len; |
||||
|
||||
REQUIRE(header.addr == cnt); |
||||
REQUIRE(test_data.find(data_len) != test_data.end()); |
||||
const std::string &dat = test_data[data_len]; |
||||
REQUIRE(memcmp(dat.data(), &unpacked_data[pos + 5], dat.size()) == 0); |
||||
++cnt; |
||||
} |
||||
REQUIRE(cnt == can_list_size); |
||||
} |
||||
|
||||
void PandaTest::test_can_recv() { |
||||
std::vector<can_frame> frames; |
||||
this->pack_can_buffer(can_data_list, [&](uint8_t *data, size_t size) { |
||||
this->unpack_can_buffer(data, size, frames); |
||||
}); |
||||
|
||||
REQUIRE(frames.size() == can_list_size); |
||||
for (int i = 0; i < frames.size(); ++i) { |
||||
REQUIRE(frames[i].address == i); |
||||
REQUIRE(test_data.find(frames[i].dat.size()) != test_data.end()); |
||||
const std::string &dat = test_data[frames[i].dat.size()]; |
||||
REQUIRE(memcmp(dat.data(), frames[i].dat.data(), dat.size()) == 0); |
||||
} |
||||
} |
||||
|
||||
TEST_CASE("send/recv CAN 2.0 packets") { |
||||
auto bus_offset = GENERATE(0, 4); |
||||
auto can_list_size = GENERATE(1, 3, 5, 10, 30, 60, 100, 200); |
||||
PandaTest test(bus_offset, can_list_size, cereal::PandaState::PandaType::DOS); |
||||
|
||||
SECTION("can_send") { |
||||
test.test_can_send(); |
||||
} |
||||
SECTION("can_receive") { |
||||
test.test_can_recv(); |
||||
} |
||||
} |
||||
|
||||
TEST_CASE("send/recv CAN FD packets") { |
||||
auto bus_offset = GENERATE(0, 4); |
||||
auto can_list_size = GENERATE(1, 3, 5, 10, 30, 60, 100, 200); |
||||
PandaTest test(bus_offset, can_list_size, cereal::PandaState::PandaType::RED_PANDA); |
||||
|
||||
SECTION("can_send") { |
||||
test.test_can_send(); |
||||
} |
||||
SECTION("can_receive") { |
||||
test.test_can_recv(); |
||||
} |
||||
} |
@ -1,92 +0,0 @@ |
||||
#include "selfdrive/camerad/cameras/camera_frame_stream.h" |
||||
|
||||
#include <unistd.h> |
||||
#include <cassert> |
||||
|
||||
#include <capnp/dynamic.h> |
||||
|
||||
#include "cereal/messaging/messaging.h" |
||||
#include "selfdrive/common/util.h" |
||||
|
||||
#define FRAME_WIDTH 1164 |
||||
#define FRAME_HEIGHT 874 |
||||
|
||||
extern ExitHandler do_exit; |
||||
|
||||
namespace { |
||||
|
||||
// TODO: make this more generic
|
||||
CameraInfo cameras_supported[CAMERA_ID_MAX] = { |
||||
[CAMERA_ID_IMX298] = { |
||||
.frame_width = FRAME_WIDTH, |
||||
.frame_height = FRAME_HEIGHT, |
||||
.frame_stride = FRAME_WIDTH*3, |
||||
.bayer = false, |
||||
.bayer_flip = false, |
||||
}, |
||||
[CAMERA_ID_OV8865] = { |
||||
.frame_width = 1632, |
||||
.frame_height = 1224, |
||||
.frame_stride = 2040, // seems right
|
||||
.bayer = false, |
||||
.bayer_flip = 3, |
||||
.hdr = false |
||||
}, |
||||
}; |
||||
|
||||
void camera_init(VisionIpcServer * v, CameraState *s, int camera_id, unsigned int fps, cl_device_id device_id, cl_context ctx, VisionStreamType rgb_type, VisionStreamType yuv_type) { |
||||
assert(camera_id < std::size(cameras_supported)); |
||||
s->ci = cameras_supported[camera_id]; |
||||
assert(s->ci.frame_width != 0); |
||||
|
||||
s->camera_num = camera_id; |
||||
s->fps = fps; |
||||
s->buf.init(device_id, ctx, s, v, FRAME_BUF_COUNT, rgb_type, yuv_type); |
||||
} |
||||
|
||||
void run_frame_stream(CameraState &camera, const char* frame_pkt) { |
||||
SubMaster sm({frame_pkt}); |
||||
|
||||
size_t buf_idx = 0; |
||||
while (!do_exit) { |
||||
sm.update(1000); |
||||
if(sm.updated(frame_pkt)) { |
||||
auto msg = static_cast<capnp::DynamicStruct::Reader>(sm[frame_pkt]); |
||||
auto frame = msg.get(frame_pkt).as<capnp::DynamicStruct>(); |
||||
camera.buf.camera_bufs_metadata[buf_idx] = { |
||||
.frame_id = frame.get("frameId").as<uint32_t>(), |
||||
.timestamp_eof = frame.get("timestampEof").as<uint64_t>(), |
||||
.timestamp_sof = frame.get("timestampSof").as<uint64_t>(), |
||||
}; |
||||
|
||||
cl_command_queue q = camera.buf.camera_bufs[buf_idx].copy_q; |
||||
cl_mem yuv_cl = camera.buf.camera_bufs[buf_idx].buf_cl; |
||||
|
||||
auto image = frame.get("image").as<capnp::Data>(); |
||||
clEnqueueWriteBuffer(q, yuv_cl, CL_TRUE, 0, image.size(), image.begin(), 0, NULL, NULL); |
||||
camera.buf.queue(buf_idx); |
||||
buf_idx = (buf_idx + 1) % FRAME_BUF_COUNT; |
||||
} |
||||
} |
||||
} |
||||
|
||||
} // namespace
|
||||
|
||||
void cameras_init(VisionIpcServer *v, MultiCameraState *s, cl_device_id device_id, cl_context ctx) { |
||||
camera_init(v, &s->road_cam, CAMERA_ID_IMX298, 20, device_id, ctx, |
||||
VISION_STREAM_RGB_BACK, VISION_STREAM_YUV_BACK); |
||||
camera_init(v, &s->driver_cam, CAMERA_ID_OV8865, 10, device_id, ctx, |
||||
VISION_STREAM_RGB_FRONT, VISION_STREAM_YUV_FRONT); |
||||
} |
||||
|
||||
void cameras_open(MultiCameraState *s) {} |
||||
void cameras_close(MultiCameraState *s) {} |
||||
void camera_autoexposure(CameraState *s, float grey_frac) {} |
||||
void process_road_camera(MultiCameraState *s, CameraState *c, int cnt) {} |
||||
|
||||
void cameras_run(MultiCameraState *s) { |
||||
std::thread t = start_process_thread(s, &s->road_cam, process_road_camera); |
||||
set_thread_name("frame_streaming"); |
||||
run_frame_stream(s->road_cam, "roadCameraState"); |
||||
t.join(); |
||||
} |
@ -1,30 +0,0 @@ |
||||
#pragma once |
||||
|
||||
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS |
||||
#ifdef __APPLE__ |
||||
#include <OpenCL/cl.h> |
||||
#else |
||||
#include <CL/cl.h> |
||||
#endif |
||||
|
||||
#include "camera_common.h" |
||||
|
||||
#define FRAME_BUF_COUNT 16 |
||||
|
||||
typedef struct CameraState { |
||||
int camera_num; |
||||
CameraInfo ci; |
||||
|
||||
int fps; |
||||
float digital_gain; |
||||
|
||||
CameraBuf buf; |
||||
} CameraState; |
||||
|
||||
typedef struct MultiCameraState { |
||||
CameraState road_cam; |
||||
CameraState driver_cam; |
||||
|
||||
SubMaster *sm; |
||||
PubMaster *pm; |
||||
} MultiCameraState; |
@ -1 +1 @@ |
||||
#define COMMA_VERSION "0.8.11" |
||||
#define COMMA_VERSION "0.8.12" |
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue