openpilot v0.4.5 release

old-commit-hash: 37285038d3
commatwo_master v0.4.5
Vehicle Researcher 7 years ago
parent aee7d818e8
commit 7c1e812922
  1. 10
      RELEASES.md
  2. 4
      apk/ai.comma.plus.frame.apk
  3. 4
      apk/ai.comma.plus.offroad.apk
  4. 2
      cereal/.gitignore
  5. 31
      cereal/Makefile
  6. 1
      cereal/__init__.py
  7. 5
      cereal/car.capnp
  8. 0
      cereal/include/c++.capnp
  9. 0
      cereal/include/java.capnp
  10. 14
      cereal/log.capnp
  11. 18
      cereal/mapd.capnp
  12. 4
      common/params.py
  13. 2
      common/transformations/coordinates.py
  14. 6
      selfdrive/boardd/boardd.cc
  15. 1
      selfdrive/can/parser.cc
  16. 2
      selfdrive/car/honda/interface.py
  17. 2
      selfdrive/common/version.h
  18. 94
      selfdrive/controls/lib/alertmanager.py
  19. 2
      selfdrive/loggerd/loggerd
  20. 10
      selfdrive/loggerd/uploader.py
  21. 24
      selfdrive/manager.py
  22. 98
      selfdrive/orbd/Makefile
  23. 118
      selfdrive/orbd/dsp/freethedsp.c
  24. 39
      selfdrive/orbd/dsp/gen/calculator.h
  25. 613
      selfdrive/orbd/dsp/gen/calculator_stub.c
  26. 37
      selfdrive/orbd/extractor.h
  27. 174
      selfdrive/orbd/orbd.cc
  28. 3
      selfdrive/registration.py
  29. 2
      selfdrive/sensord/gpsd
  30. 2
      selfdrive/sensord/sensord
  31. 3
      selfdrive/service_list.yaml
  32. 1
      selfdrive/test/plant/plant.py
  33. 8
      selfdrive/ui/ui.c
  34. 4
      selfdrive/version.py
  35. 4
      selfdrive/visiond/visiond

@ -1,3 +1,13 @@
Version 0.4.5 (2018-04-27)
==========================
* Release notes added to the update popup
* Improve auto shut-off logic to disallow empty battery
* Added onboarding instructions
* Include orbd, the first piece of new calibration algorithm
* Show remaining upload data instead of file numbers
* Fix UI bugs
* Fix memory leaks
Version 0.4.4 (2018-04-13) Version 0.4.4 (2018-04-13)
========================== ==========================
* EON are flipped! Flip your EON's mount! * EON are flipped! Flip your EON's mount!

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:70323271320417698bb8640f18bbed920199fb61553ae85ff8a44a08a39e34b5 oid sha256:f1542ec60d6c18b0bef02f0dff85989814e99b9b35f331ae8416b6c0367fe368
size 2108896 size 2116281

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:0ddd24ea3ab1349196d6413eed5432d5292d5912c641b6c3e76a46913b284080 oid sha256:8aa566ee67a720686f86bcde0eb4905d26735a6fa1d08459f254c8bddad95270
size 14337199 size 17455432

2
cereal/.gitignore vendored

@ -1 +1,3 @@
gen gen
node_modules
package-lock.json

@ -1,40 +1,48 @@
PWD := $(shell pwd) PWD := $(shell pwd)
SRCS := log.capnp car.capnp mapd.capnp SRCS := log.capnp car.capnp
GENS := gen/cpp/car.capnp.c++ gen/cpp/log.capnp.c++ gen/cpp/mapd.capnp.c++ 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) UNAME_M ?= $(shell uname -m)
# only generate C++ for docker tests # only generate C++ for docker tests
ifneq ($(OPTEST),1) ifneq ($(OPTEST),1)
GENS += gen/c/car.capnp.c gen/c/log.capnp.c gen/c/mapd.capnp.c gen/c/c++.capnp.h gen/c/java.capnp.h GENS += gen/c/car.capnp.c gen/c/log.capnp.c gen/c/include/c++.capnp.h gen/c/include/java.capnp.h
# Dont build java on the phone... ifeq ($(UNAME_M),x86_64)
ifeq ($(UNAME_M),x86_64) GENS += gen/java/Car.java gen/java/Log.java
GENS += gen/java/Car.java gen/java/Log.java endif
endif
endif endif
ifeq ($(UNAME_M),aarch64) ifeq ($(UNAME_M),aarch64)
CAPNPC=PATH=$(PWD)/../phonelibs/capnp-cpp/aarch64/bin/:$$PATH capnpc CAPNPC=PATH=$(PWD)/../phonelibs/capnp-cpp/aarch64/bin/:$$PATH capnpc
else else
CAPNPC=capnpc CAPNPC=capnpc
endif endif
.PHONY: all .PHONY: all
all: $(GENS) all: $(GENS)
js: $(JS)
.PHONY: clean .PHONY: clean
clean: clean:
rm -rf gen rm -rf gen
rm -rf node_modules
rm -rf package-lock.json
gen/c/%.capnp.c: %.capnp gen/c/%.capnp.c: %.capnp
@echo "[ CAPNPC C ] $@" @echo "[ CAPNPC C ] $@"
mkdir -p gen/c/ mkdir -p gen/c/
$(CAPNPC) '$<' -o c:gen/c/ $(CAPNPC) '$<' -o c:gen/c/
gen/js/%.capnp.js: %.capnp
@echo "[ CAPNPC JavaScript ] $@"
mkdir -p gen/js/
sh ./generate_javascript.sh
gen/cpp/%.capnp.c++: %.capnp gen/cpp/%.capnp.c++: %.capnp
@echo "[ CAPNPC C++ ] $@" @echo "[ CAPNPC C++ ] $@"
mkdir -p gen/cpp/ mkdir -p gen/cpp/
@ -46,7 +54,6 @@ gen/java/Car.java gen/java/Log.java: $(SRCS)
$(CAPNPC) $^ -o java:gen/java $(CAPNPC) $^ -o java:gen/java
# c-capnproto needs some empty headers # c-capnproto needs some empty headers
gen/c/c++.capnp.h gen/c/java.capnp.h: gen/c/include/c++.capnp.h gen/c/include/java.capnp.h:
mkdir -p gen/c/ mkdir -p gen/c/include
touch '$@' touch '$@'

@ -6,4 +6,3 @@ capnp.remove_import_hook()
log = capnp.load(os.path.join(CEREAL_PATH, "log.capnp")) log = capnp.load(os.path.join(CEREAL_PATH, "log.capnp"))
car = capnp.load(os.path.join(CEREAL_PATH, "car.capnp")) car = capnp.load(os.path.join(CEREAL_PATH, "car.capnp"))
mapd = capnp.load(os.path.join(CEREAL_PATH, "mapd.capnp"))

@ -1,7 +1,7 @@
using Cxx = import "c++.capnp"; using Cxx = import "./include/c++.capnp";
$Cxx.namespace("cereal"); $Cxx.namespace("cereal");
using Java = import "java.capnp"; using Java = import "./include/java.capnp";
$Java.package("ai.comma.openpilot.cereal"); $Java.package("ai.comma.openpilot.cereal");
$Java.outerClassname("Car"); $Java.outerClassname("Car");
@ -293,6 +293,7 @@ struct CarParams {
elm327 @3; elm327 @3;
gm @4; gm @4;
hondaBosch @5; hondaBosch @5;
ford @6;
} }
# things about the car in the manual # things about the car in the manual

@ -1,7 +1,7 @@
using Cxx = import "c++.capnp"; using Cxx = import "./include/c++.capnp";
$Cxx.namespace("cereal"); $Cxx.namespace("cereal");
using Java = import "java.capnp"; using Java = import "./include/java.capnp";
$Java.package("ai.comma.openpilot.cereal"); $Java.package("ai.comma.openpilot.cereal");
$Java.outerClassname("Log"); $Java.outerClassname("Log");
@ -1497,6 +1497,15 @@ struct OrbFeatures {
matches @6: List(Int16); matches @6: List(Int16);
} }
struct OrbFeaturesSummary {
timestampEof @0 :UInt64;
timestampLastEof @1 :UInt64;
featureCount @2 :UInt16;
matchCount @3 :UInt16;
computeNs @4 :UInt64;
}
struct OrbKeyFrame { struct OrbKeyFrame {
# this is a globally unique id for the KeyFrame # this is a globally unique id for the KeyFrame
id @0: UInt64; id @0: UInt64;
@ -1572,5 +1581,6 @@ struct Event {
applanixLocation @55 :LiveLocationData; applanixLocation @55 :LiveLocationData;
orbKeyFrame @56 :OrbKeyFrame; orbKeyFrame @56 :OrbKeyFrame;
uiLayoutState @57 :UiLayoutState; uiLayoutState @57 :UiLayoutState;
orbFeaturesSummary @58 :OrbFeaturesSummary;
} }
} }

@ -1,18 +0,0 @@
using Cxx = import "c++.capnp";
$Cxx.namespace("cereal");
using Java = import "java.capnp";
$Java.package("ai.comma.openpilot.cereal");
$Java.outerClassname("Map");
using Log = import "log.capnp";
@0xe1a6ab330ea7205f;
struct MapdRequest {
pos @0 :Log.ECEFPoint;
}
struct MapdResponse {
kfs @0 :List(Log.OrbKeyFrame);
}

@ -46,10 +46,11 @@ class UnknownKeyName(Exception):
keys = { keys = {
# written: manager # written: manager
# read: loggerd, uploaderd, baseui # read: loggerd, uploaderd, offroad
"DongleId": TxType.PERSISTANT, "DongleId": TxType.PERSISTANT,
"AccessToken": TxType.PERSISTANT, "AccessToken": TxType.PERSISTANT,
"Version": TxType.PERSISTANT, "Version": TxType.PERSISTANT,
"TrainingVersion": TxType.PERSISTANT,
"GitCommit": TxType.PERSISTANT, "GitCommit": TxType.PERSISTANT,
"GitBranch": TxType.PERSISTANT, "GitBranch": TxType.PERSISTANT,
"GitRemote": TxType.PERSISTANT, "GitRemote": TxType.PERSISTANT,
@ -59,6 +60,7 @@ keys = {
"IsRearViewMirror": TxType.PERSISTANT, "IsRearViewMirror": TxType.PERSISTANT,
"IsFcwEnabled": TxType.PERSISTANT, "IsFcwEnabled": TxType.PERSISTANT,
"HasAcceptedTerms": TxType.PERSISTANT, "HasAcceptedTerms": TxType.PERSISTANT,
"CompletedTrainingVersion": TxType.PERSISTANT,
"IsUploadVideoOverCellularEnabled": TxType.PERSISTANT, "IsUploadVideoOverCellularEnabled": TxType.PERSISTANT,
# written: visiond # written: visiond
# read: visiond, controlsd # read: visiond, controlsd

@ -71,7 +71,7 @@ class LocalCoord(object):
""" """
def __init__(self, init_geodetic, init_ecef): def __init__(self, init_geodetic, init_ecef):
self.init_ecef = init_ecef self.init_ecef = init_ecef
lat, lon, _ = (np.pi/180)*init_geodetic lat, lon, _ = (np.pi/180)*np.array(init_geodetic)
self.ned2ecef_matrix = np.array([[-np.sin(lat)*np.cos(lon), -np.sin(lon), -np.cos(lat)*np.cos(lon)], self.ned2ecef_matrix = np.array([[-np.sin(lat)*np.cos(lon), -np.sin(lon), -np.cos(lat)*np.cos(lon)],
[-np.sin(lat)*np.sin(lon), np.cos(lon), -np.cos(lat)*np.sin(lon)], [-np.sin(lat)*np.sin(lon), np.cos(lon), -np.cos(lat)*np.sin(lon)],
[np.cos(lat), 0, -np.sin(lat)]]) [np.cos(lat), 0, -np.sin(lat)]])

@ -384,6 +384,8 @@ void *thermal_thread(void *crap) {
pthread_mutex_lock(&usb_lock); pthread_mutex_lock(&usb_lock);
libusb_control_transfer(dev_handle, 0xc0, 0xd3, target_fan_speed, 0, NULL, 0, TIMEOUT); libusb_control_transfer(dev_handle, 0xc0, 0xd3, target_fan_speed, 0, NULL, 0, TIMEOUT);
pthread_mutex_unlock(&usb_lock); pthread_mutex_unlock(&usb_lock);
zmq_msg_close(&msg);
} }
// turn the fan off when we exit // turn the fan off when we exit
@ -462,8 +464,8 @@ void _pigeon_send(const char *dat, int len) {
pthread_mutex_lock(&usb_lock); pthread_mutex_lock(&usb_lock);
err = libusb_bulk_transfer(dev_handle, 2, a, ll+1, &sent, TIMEOUT); err = libusb_bulk_transfer(dev_handle, 2, a, ll+1, &sent, TIMEOUT);
if (err < 0) { handle_usb_issue(err, __func__); } if (err < 0) { handle_usb_issue(err, __func__); }
assert(err == 0); /*assert(err == 0);
assert(sent == ll+1); assert(sent == ll+1);*/
//hexdump(a, ll+1); //hexdump(a, ll+1);
pthread_mutex_unlock(&usb_lock); pthread_mutex_unlock(&usb_lock);
} }

@ -294,6 +294,7 @@ class CANParser {
UpdateValid(sec); UpdateValid(sec);
zmq_msg_close(&msg);
} }
std::vector<SignalValue> query(uint64_t sec) { std::vector<SignalValue> query(uint64_t sec) {

@ -188,7 +188,7 @@ class CarInterface(object):
ret.centerToFront = ret.wheelbase * 0.37 ret.centerToFront = ret.wheelbase * 0.37
ret.steerRatio = 15.3 ret.steerRatio = 15.3
# Acura at comma has modified steering FW, so different tuning for the Neo in that car # Acura at comma has modified steering FW, so different tuning for the Neo in that car
is_fw_modified = os.getenv("DONGLE_ID") in ['85a6c74d4ad9c310'] is_fw_modified = os.getenv("DONGLE_ID") in ['ff83f397542ab647']
ret.steerKpV, ret.steerKiV = [[0.4], [0.12]] if is_fw_modified else [[0.8], [0.24]] ret.steerKpV, ret.steerKiV = [[0.4], [0.12]] if is_fw_modified else [[0.8], [0.24]]
ret.longitudinalKpBP = [0., 5., 35.] ret.longitudinalKpBP = [0., 5., 35.]

@ -1 +1 @@
#define COMMA_VERSION "0.4.4-release" #define COMMA_VERSION "0.4.5-release"

@ -72,31 +72,31 @@ class AlertManager(object):
"fcw": Alert( "fcw": Alert(
"Brake!", "Brake!",
"Risk of collision detected", "Risk of Collision",
AlertStatus.critical, AlertSize.full, AlertStatus.critical, AlertSize.full,
Priority.HIGH, "fcw", "chimeRepeated", 1., 2., 2.), Priority.HIGH, "fcw", "chimeRepeated", 1., 2., 2.),
"steerSaturated": Alert( "steerSaturated": Alert(
"TAKE CONTROL", "TAKE CONTROL",
"Turn exceeds steering limit", "Turn Exceeds Steering Limit",
AlertStatus.userPrompt, AlertSize.mid, AlertStatus.userPrompt, AlertSize.mid,
Priority.LOW, "steerRequired", "chimeSingle", 1., 2., 3.), Priority.LOW, "steerRequired", "chimeSingle", 1., 2., 3.),
"steerTempUnavailable": Alert( "steerTempUnavailable": Alert(
"TAKE CONTROL", "TAKE CONTROL",
"Steering temporarily unavailable", "Steering Temporarily Unavailable",
AlertStatus.userPrompt, AlertSize.mid, AlertStatus.userPrompt, AlertSize.mid,
Priority.LOW, "steerRequired", "chimeDouble", .4, 2., 3.), Priority.LOW, "steerRequired", "chimeDouble", .4, 2., 3.),
"preDriverDistracted": Alert( "preDriverDistracted": Alert(
"TAKE CONTROL", "TAKE CONTROL",
"User appears distracted", "User Appears Distracted",
AlertStatus.userPrompt, AlertSize.mid, AlertStatus.userPrompt, AlertSize.mid,
Priority.LOW, "steerRequired", None, 0., .1, .1), Priority.LOW, "steerRequired", None, 0., .1, .1),
"driverDistracted": Alert( "driverDistracted": Alert(
"TAKE CONTROL TO REGAIN SPEED", "TAKE CONTROL TO REGAIN SPEED",
"User appears distracted", "User Appears Distracted",
AlertStatus.critical, AlertSize.full, AlertStatus.critical, AlertSize.full,
Priority.MID, "steerRequired", "chimeRepeated", .1, .1, .1), Priority.MID, "steerRequired", "chimeRepeated", .1, .1, .1),
@ -113,62 +113,62 @@ class AlertManager(object):
Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 3.), Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 3.),
"steerTempUnavailableNoEntry": Alert( "steerTempUnavailableNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Steering temporarily unavailable", "Steering Temporarily Unavailable",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 0., 3.), Priority.LOW, None, "chimeDouble", .4, 0., 3.),
"manualRestart": Alert( "manualRestart": Alert(
"TAKE CONTROL", "TAKE CONTROL",
"Resume driving manually", "Resume Driving Manually",
AlertStatus.userPrompt, AlertSize.mid, AlertStatus.userPrompt, AlertSize.mid,
Priority.LOW, None, None, 0., 0., .2), Priority.LOW, None, None, 0., 0., .2),
# Non-entry only alerts # Non-entry only alerts
"wrongCarModeNoEntry": Alert( "wrongCarModeNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Main Switch Off", "Main Switch Off",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 0., 3.), Priority.LOW, None, "chimeDouble", .4, 0., 3.),
"dataNeededNoEntry": Alert( "dataNeededNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Data needed for calibration. Upload drive, try again", "Data Needed for Calibration. Upload Drive, Try Again",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 0., 3.), Priority.LOW, None, "chimeDouble", .4, 0., 3.),
"outOfSpaceNoEntry": Alert( "outOfSpaceNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Out of storage space", "Out of Storage Space",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 0., 3.), Priority.LOW, None, "chimeDouble", .4, 0., 3.),
"pedalPressedNoEntry": Alert( "pedalPressedNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Pedal pressed during attempt", "Pedal Pressed During Attempt",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, "brakePressed", "chimeDouble", .4, 2., 3.), Priority.LOW, "brakePressed", "chimeDouble", .4, 2., 3.),
"speedTooLowNoEntry": Alert( "speedTooLowNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Speed too low", "Speed Too Low",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"brakeHoldNoEntry": Alert( "brakeHoldNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Brake hold active", "Brake Hold Active",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"parkBrakeNoEntry": Alert( "parkBrakeNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Park brake engaged", "Park Brake Engaged",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"lowSpeedLockoutNoEntry": Alert( "lowSpeedLockoutNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Cruise Fault: Restart the Car", "Cruise Fault: Restart the Car",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
@ -249,7 +249,7 @@ class AlertManager(object):
"commIssue": Alert( "commIssue": Alert(
"TAKE CONTROL IMMEDIATELY", "TAKE CONTROL IMMEDIATELY",
"CAN Error: Restart the Car", "CAN Error: Check Connections",
AlertStatus.critical, AlertSize.full, AlertStatus.critical, AlertSize.full,
Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 4.), Priority.HIGH, "steerRequired", "chimeRepeated", 1., 3., 4.),
@ -291,128 +291,128 @@ class AlertManager(object):
# not loud cancellations (user is in control) # not loud cancellations (user is in control)
"noTarget": Alert( "noTarget": Alert(
"Comma Canceled", "openpilot Canceled",
"No close lead car", "No close lead car",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.HIGH, None, "chimeDouble", .4, 2., 3.), Priority.HIGH, None, "chimeDouble", .4, 2., 3.),
"speedTooLow": Alert( "speedTooLow": Alert(
"Comma Canceled", "openpilot Canceled",
"Speed too low", "Speed too low",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.HIGH, None, "chimeDouble", .4, 2., 3.), Priority.HIGH, None, "chimeDouble", .4, 2., 3.),
# Cancellation alerts causing non-entry # Cancellation alerts causing non-entry
"overheatNoEntry": Alert( "overheatNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"System overheated", "System overheated",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"wrongGearNoEntry": Alert( "wrongGearNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Gear not D", "Gear not D",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"calibrationInvalidNoEntry": Alert( "calibrationInvalidNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Calibration Invalid: Reposition EON and Recalibrate", "Calibration Invalid: Reposition EON and Recalibrate",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"calibrationInProgressNoEntry": Alert( "calibrationInProgressNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Calibration in Progress", "Calibration in Progress",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"doorOpenNoEntry": Alert( "doorOpenNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Door open", "Door open",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"seatbeltNotLatchedNoEntry": Alert( "seatbeltNotLatchedNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Seatbelt unlatched", "Seatbelt unlatched",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"espDisabledNoEntry": Alert( "espDisabledNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"ESP Off", "ESP Off",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"radarCommIssueNoEntry": Alert( "radarCommIssueNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Radar Error: Restart the Car", "Radar Error: Restart the Car",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"radarFaultNoEntry": Alert( "radarFaultNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Radar Error: Restart the Car", "Radar Error: Restart the Car",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"modelCommIssueNoEntry": Alert( "modelCommIssueNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Model Error: Restart the Car", "Model Error: Restart the Car",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"controlsFailedNoEntry": Alert( "controlsFailedNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Controls Failed", "Controls Failed",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"commIssueNoEntry": Alert( "commIssueNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"CAN Error: Restart the Car", "CAN Error: Check Connections",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"steerUnavailableNoEntry": Alert( "steerUnavailableNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Steer Fault: Restart the Car", "Steer Fault: Restart the Car",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"brakeUnavailableNoEntry": Alert( "brakeUnavailableNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Brake Fault: Restart the Car", "Brake Fault: Restart the Car",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"gasUnavailableNoEntry": Alert( "gasUnavailableNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Gas Error: Restart the Car", "Gas Error: Restart the Car",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"reverseGearNoEntry": Alert( "reverseGearNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Reverse Gear", "Reverse Gear",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"cruiseDisabledNoEntry": Alert( "cruiseDisabledNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Cruise is off", "Cruise is Off",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"noTargetNoEntry": Alert( "noTargetNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"No close lead car", "No Close Lead Car",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),
"plannerErrorNoEntry": Alert( "plannerErrorNoEntry": Alert(
"Comma Unavailable", "openpilot Unavailable",
"Planner Solution Error", "Planner Solution Error",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, None, "chimeDouble", .4, 2., 3.), Priority.LOW, None, "chimeDouble", .4, 2., 3.),

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:900915b281d311e13e98ca6c0dcb16966f1127af00d1523b38c8a0fc029c97c1 oid sha256:86a303c99ff57d29f0c3cc8656ae2cbd413a01894f89c718b5b9481c71b1ba4d
size 1416464 size 1416464

@ -70,7 +70,7 @@ def clear_locks(root):
def is_on_wifi(): def is_on_wifi():
# ConnectivityManager.getActiveNetworkInfo() # ConnectivityManager.getActiveNetworkInfo()
result = subprocess.check_output(["service", "call", "connectivity", "2"]).strip().split("\n") result = subprocess.check_output(["service", "call", "connectivity", "2"]).strip().split("\n")
data = ''.join(''.join(w.decode("hex")[::-1] for w in l[14:49].split()) for l in result[1:]) data = ''.join(''.join(w.decode("hex")[::-1] for w in l[14:49].split()) for l in result[1:])
return "\x00".join("WIFI") in data return "\x00".join("WIFI") in data
@ -126,15 +126,17 @@ class Uploader(object):
return (key, fn, 0) return (key, fn, 0)
if with_video: if with_video:
# then upload compressed camera file # then upload compressed rear and front camera files
for name, key, fn in self.gen_upload_files(): for name, key, fn in self.gen_upload_files():
if name in ["fcamera.hevc"]: if name == "fcamera.hevc":
return (key, fn, 1) return (key, fn, 1)
elif name == "dcamera.hevc":
return (key, fn, 2)
# then upload other files # then upload other files
for name, key, fn in self.gen_upload_files(): for name, key, fn in self.gen_upload_files():
if not name.endswith('.lock') and not name.endswith(".tmp"): if not name.endswith('.lock') and not name.endswith(".tmp"):
return (key, fn, 1) return (key, fn, 3)
return None return None

@ -62,7 +62,7 @@ from selfdrive.swaglog import cloudlog
import selfdrive.messaging as messaging import selfdrive.messaging as messaging
from selfdrive.thermal import read_thermal from selfdrive.thermal import read_thermal
from selfdrive.registration import register from selfdrive.registration import register
from selfdrive.version import version, dirty from selfdrive.version import version, dirty, training_version
import selfdrive.crash as crash import selfdrive.crash as crash
from selfdrive.loggerd.config import ROOT from selfdrive.loggerd.config import ROOT
@ -87,6 +87,7 @@ managed_processes = {
"visiond": ("selfdrive/visiond", ["./visiond"]), "visiond": ("selfdrive/visiond", ["./visiond"]),
"sensord": ("selfdrive/sensord", ["./sensord"]), "sensord": ("selfdrive/sensord", ["./sensord"]),
"gpsd": ("selfdrive/sensord", ["./gpsd"]), "gpsd": ("selfdrive/sensord", ["./gpsd"]),
"orbd": ("selfdrive/orbd", ["./orbd"]),
"updated": "selfdrive.updated", "updated": "selfdrive.updated",
#"gpsplanner": "selfdrive.controls.gps_plannerd", #"gpsplanner": "selfdrive.controls.gps_plannerd",
} }
@ -120,6 +121,7 @@ car_started_processes = [
'radard', 'radard',
'visiond', 'visiond',
'proclogd', 'proclogd',
'orbd',
# 'gpsplanner, # 'gpsplanner,
] ]
@ -393,11 +395,12 @@ def manager_thread():
passive_starter = LocationStarter() passive_starter = LocationStarter()
started_ts = None started_ts = None
off_ts = None
logger_dead = False logger_dead = False
count = 0 count = 0
fan_speed = 0 fan_speed = 0
ignition_seen = False ignition_seen = False
battery_was_high = False started_seen = False
panda_seen = False panda_seen = False
health_sock.RCVTIMEO = 1500 health_sock.RCVTIMEO = 1500
@ -460,6 +463,7 @@ def manager_thread():
do_uninstall = params.get("DoUninstall") == "1" do_uninstall = params.get("DoUninstall") == "1"
accepted_terms = params.get("HasAcceptedTerms") == "1" accepted_terms = params.get("HasAcceptedTerms") == "1"
completed_training = params.get("CompletedTrainingVersion") == training_version
should_start = ignition should_start = ignition
@ -477,7 +481,7 @@ def manager_thread():
# require usb power # require usb power
should_start = should_start and msg.thermal.usbOnline should_start = should_start and msg.thermal.usbOnline
should_start = should_start and accepted_terms and (not do_uninstall) should_start = should_start and accepted_terms and completed_training and (not do_uninstall)
# if any CPU gets above 107 or the battery gets above 63, kill all processes # if any CPU gets above 107 or the battery gets above 63, kill all processes
# controls will warn with CPU above 95 or battery above 60 # controls will warn with CPU above 95 or battery above 60
@ -486,9 +490,11 @@ def manager_thread():
should_start = False should_start = False
if should_start: if should_start:
if not started_ts: off_ts = None
if started_ts is None:
params.car_start() params.car_start()
started_ts = sec_since_boot() started_ts = sec_since_boot()
started_seen = True
for p in car_started_processes: for p in car_started_processes:
if p == "loggerd" and logger_dead: if p == "loggerd" and logger_dead:
kill_managed_process(p) kill_managed_process(p)
@ -496,15 +502,17 @@ def manager_thread():
start_managed_process(p) start_managed_process(p)
else: else:
started_ts = None started_ts = None
if off_ts is None:
off_ts = sec_since_boot()
logger_dead = False logger_dead = False
for p in car_started_processes: for p in car_started_processes:
kill_managed_process(p) kill_managed_process(p)
# shutdown if the battery gets lower than 5%, we aren't running, and we are discharging # shutdown if the battery gets lower than 3%, t's discharging, we aren't running for
if msg.thermal.batteryPercent < 5 and msg.thermal.batteryStatus == "Discharging" and battery_was_high: # more than a minute but we were running
if msg.thermal.batteryPercent < 3 and msg.thermal.batteryStatus == "Discharging" and \
started_seen and (sec_since_boot() - off_ts) > 60:
os.system('LD_LIBRARY_PATH="" svc power shutdown') os.system('LD_LIBRARY_PATH="" svc power shutdown')
if msg.thermal.batteryPercent > 10:
battery_was_high = True
# check the status of all processes, did any of them die? # check the status of all processes, did any of them die?
for p in running: for p in running:

@ -0,0 +1,98 @@
# CPU
CC = clang
CXX = clang++
JSON_FLAGS = -I$(PHONELIBS)/json/src
CFLAGS = -std=gnu11 -g -fPIC -O2 $(WARN_FLAGS) -Iinclude $(JSON_FLAGS) -I.
CXXFLAGS = -std=c++11 -g -fPIC -O2 $(WARN_FLAGS) -Iinclude $(JSON_FLAGS) -I.
LDFLAGS =
# profile
# CXXFLAGS += -DTURBOCV_PROFILE=1
PHONELIBS = ../../phonelibs
BASEDIR = ../..
EXTERNAL = ../../external
PYTHONLIBS =
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),x86_64)
# computer
ZMQ_FLAGS = -I$(PHONELIBS)/zmq/aarch64/include
ZMQ_LIBS = -L$(BASEDIR)/external/zmq/lib/ \
-l:libczmq.a -l:libzmq.a -lpthread
OPENCV_LIBS = -lopencv_core -lopencv_highgui -lopencv_features2d -lopencv_imgproc
CXXFLAGS += -fopenmp
LDFLAGS += -lomp
else
# phone
ZMQ_FLAGS = -I$(PHONELIBS)/zmq/aarch64/include
ZMQ_LIBS = -L$(PHONELIBS)/zmq/aarch64/lib \
-l:libczmq.a -l:libzmq.a \
-lgnustl_shared
OPENCV_FLAGS = -I$(PHONELIBS)/opencv/include
OPENCV_LIBS = -Wl,--enable-new-dtags -Wl,-rpath,/usr/local/lib/python2.7/site-packages -L/usr/local/lib/python2.7/site-packages -l:cv2.so
endif
.PHONY: all
all: orbd
include ../common/cereal.mk
DEP_OBJS = ../common/visionipc.o ../common/swaglog.o $(PHONELIBS)/json/src/json.o
orbd: orbd_dsp.o $(DEP_OBJS) calculator_stub.o freethedsp.o
@echo "[ LINK ] $@"
$(CXX) -fPIC -o '$@' $^ \
$(LDFLAGS) \
$(ZMQ_LIBS) \
$(CEREAL_LIBS) \
-L/usr/lib \
-L/system/vendor/lib64 \
-ladsprpc \
-lm -lz -llog
%.o: %.c
@echo "[ CC ] $@"
$(CC) $(CFLAGS) \
-I../ \
-I../../ \
-c -o '$@' '$<'
orbd_dsp.o: orbd.cc
@echo "[ CXX ] $@"
$(CXX) $(CXXFLAGS) \
$(CEREAL_CXXFLAGS) \
$(ZMQ_FLAGS) \
$(OPENCV_FLAGS) \
-DDSP \
-I../ \
-I../../ \
-I../../../ \
-I./include \
-c -o '$@' '$<'
freethedsp.o: dsp/freethedsp.c
@echo "[ CC ] $@"
$(CC) $(CFLAGS) \
-c -o '$@' '$<'
calculator_stub.o: dsp/gen/calculator_stub.c
@echo "[ CC ] $@"
$(CC) $(CFLAGS) -I./include -c -o '$@' '$<'
-include internal.mk
.PHONY: clean
clean:
rm -f *.o turbocv.so orbd test/turbocv_profile test/turbocv_test test/*.o *_lut.h

@ -0,0 +1,118 @@
// freethedsp by geohot
// (because the DSP should be free)
// released under MIT License
// usage instructions:
// 1. Compile an example from the Qualcomm Hexagon SDK
// 2. Try to run it on your phone
// 3. Be very sad when "adsprpc ... dlopen error: ... signature verify start failed for ..." appears in logcat
// ...here is where people would give up before freethedsp
// 4. Compile freethedsp with 'clang -shared freethedsp.c -o freethedsp.so' (or statically link it to your program)
// 5. Run your program with 'LD_PRELOAD=./freethedsp.so ./<your_prog>'
// 6. OMG THE DSP WORKS
// 7. Be happy.
// *** patch may have to change for your phone ***
// this is patching /dsp/fastrpc_shell_0
// correct if sha hash of fastrpc_shell_0 is "fbadc96848aefad99a95aa4edb560929dcdf78f8"
// patch to return 0xFFFFFFFF from is_test_enabled instead of 0
// your fastrpc_shell_0 may vary
#define PATCH_ADDR 0x5200c
#define PATCH_OLD "\x40\x3f\x20\x50"
#define PATCH_NEW "\x40\x3f\x00\x5a"
#define PATCH_LEN (sizeof(PATCH_OLD)-1)
// under 100 lines of code begins now
#include <stdio.h>
#include <dlfcn.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
// ioctl stuff
#define IOC_OUT 0x40000000 /* copy out parameters */
#define IOC_IN 0x80000000 /* copy in parameters */
#define IOC_INOUT (IOC_IN|IOC_OUT)
#define IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */
#define _IOC(inout,group,num,len) \
(inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))
#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t))
// ion ioctls
#include <linux/ion.h>
#define ION_IOC_MSM_MAGIC 'M'
#define ION_IOC_CLEAN_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 2, \
struct ion_flush_data)
struct ion_flush_data {
ion_user_handle_t handle;
int fd;
void *vaddr;
unsigned int offset;
unsigned int length;
};
// fastrpc ioctls
#define FASTRPC_IOCTL_INIT _IOWR('R', 6, struct fastrpc_ioctl_init)
struct fastrpc_ioctl_init {
uint32_t flags; /* one of FASTRPC_INIT_* macros */
uintptr_t __user file; /* pointer to elf file */
int32_t filelen; /* elf file length */
int32_t filefd; /* ION fd for the file */
uintptr_t __user mem; /* mem for the PD */
int32_t memlen; /* mem length */
int32_t memfd; /* ION fd for the mem */
};
int ioctl(int fd, unsigned long request, void *arg) {
static void *handle = NULL;
static int (*orig_ioctl)(int, int, void*);
if (handle == NULL) {
handle = dlopen("/system/lib64/libc.so", RTLD_LAZY);
assert(handle != NULL);
orig_ioctl = dlsym(handle, "ioctl");
}
int ret = orig_ioctl(fd, request, arg);
// carefully modify this one
if (request == FASTRPC_IOCTL_INIT) {
struct fastrpc_ioctl_init *init = (struct fastrpc_ioctl_init *)arg;
// confirm patch is correct and do the patch
assert(memcmp((void*)(init->mem+PATCH_ADDR), PATCH_OLD, 4) == 0);
memcpy((void*)(init->mem+PATCH_ADDR), PATCH_NEW, 4);
// flush cache
int ionfd = open("/dev/ion", O_RDONLY);
assert(ionfd > 0);
struct ion_fd_data fd_data;
fd_data.fd = init->memfd;
int ret = ioctl(ionfd, ION_IOC_IMPORT, &fd_data);
assert(ret == 0);
struct ion_flush_data flush_data;
flush_data.handle = fd_data.handle;
flush_data.vaddr = (void*)init->mem;
flush_data.offset = PATCH_ADDR;
flush_data.length = PATCH_LEN;
ret = ioctl(ionfd, ION_IOC_CLEAN_INV_CACHES, &flush_data);
assert(ret == 0);
struct ion_handle_data handle_data;
handle_data.handle = fd_data.handle;
ret = ioctl(ionfd, ION_IOC_FREE, &handle_data);
assert(ret == 0);
// cleanup
close(ionfd);
}
return ret;
}

@ -0,0 +1,39 @@
#ifndef _CALCULATOR_H
#define _CALCULATOR_H
#include <stdint.h>
typedef uint8_t uint8;
typedef uint32_t uint32;
#ifndef __QAIC_HEADER
#define __QAIC_HEADER(ff) ff
#endif //__QAIC_HEADER
#ifndef __QAIC_HEADER_EXPORT
#define __QAIC_HEADER_EXPORT
#endif // __QAIC_HEADER_EXPORT
#ifndef __QAIC_HEADER_ATTRIBUTE
#define __QAIC_HEADER_ATTRIBUTE
#endif // __QAIC_HEADER_ATTRIBUTE
#ifndef __QAIC_IMPL
#define __QAIC_IMPL(ff) ff
#endif //__QAIC_IMPL
#ifndef __QAIC_IMPL_EXPORT
#define __QAIC_IMPL_EXPORT
#endif // __QAIC_IMPL_EXPORT
#ifndef __QAIC_IMPL_ATTRIBUTE
#define __QAIC_IMPL_ATTRIBUTE
#endif // __QAIC_IMPL_ATTRIBUTE
#ifdef __cplusplus
extern "C" {
#endif
__QAIC_HEADER_EXPORT int __QAIC_HEADER(calculator_init)(uint32* leet) __QAIC_HEADER_ATTRIBUTE;
__QAIC_HEADER_EXPORT int __QAIC_HEADER(calculator_extract_and_match)(const uint8* img, int imgLen, uint8* features, int featuresLen) __QAIC_HEADER_ATTRIBUTE;
#ifdef __cplusplus
}
#endif
#endif //_CALCULATOR_H

@ -0,0 +1,613 @@
#ifndef _CALCULATOR_STUB_H
#define _CALCULATOR_STUB_H
#include "calculator.h"
// remote.h
#include <stdint.h>
#include <sys/types.h>
typedef uint32_t remote_handle;
typedef uint64_t remote_handle64;
typedef struct {
void *pv;
size_t nLen;
} remote_buf;
typedef struct {
int32_t fd;
uint32_t offset;
} remote_dma_handle;
typedef union {
remote_buf buf;
remote_handle h;
remote_handle64 h64;
remote_dma_handle dma;
} remote_arg;
int remote_handle_open(const char* name, remote_handle *ph);
int remote_handle_invoke(remote_handle h, uint32_t dwScalars, remote_arg *pra);
int remote_handle_close(remote_handle h);
#define REMOTE_SCALARS_MAKEX(nAttr,nMethod,nIn,nOut,noIn,noOut) \
((((uint32_t) (nAttr) & 0x7) << 29) | \
(((uint32_t) (nMethod) & 0x1f) << 24) | \
(((uint32_t) (nIn) & 0xff) << 16) | \
(((uint32_t) (nOut) & 0xff) << 8) | \
(((uint32_t) (noIn) & 0x0f) << 4) | \
((uint32_t) (noOut) & 0x0f))
#ifndef _QAIC_ENV_H
#define _QAIC_ENV_H
#ifdef __GNUC__
#ifdef __clang__
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#else
#pragma GCC diagnostic ignored "-Wpragmas"
#endif
#pragma GCC diagnostic ignored "-Wuninitialized"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
#ifndef _ATTRIBUTE_UNUSED
#ifdef _WIN32
#define _ATTRIBUTE_UNUSED
#else
#define _ATTRIBUTE_UNUSED __attribute__ ((unused))
#endif
#endif // _ATTRIBUTE_UNUSED
#ifndef __QAIC_REMOTE
#define __QAIC_REMOTE(ff) ff
#endif //__QAIC_REMOTE
#ifndef __QAIC_HEADER
#define __QAIC_HEADER(ff) ff
#endif //__QAIC_HEADER
#ifndef __QAIC_HEADER_EXPORT
#define __QAIC_HEADER_EXPORT
#endif // __QAIC_HEADER_EXPORT
#ifndef __QAIC_HEADER_ATTRIBUTE
#define __QAIC_HEADER_ATTRIBUTE
#endif // __QAIC_HEADER_ATTRIBUTE
#ifndef __QAIC_IMPL
#define __QAIC_IMPL(ff) ff
#endif //__QAIC_IMPL
#ifndef __QAIC_IMPL_EXPORT
#define __QAIC_IMPL_EXPORT
#endif // __QAIC_IMPL_EXPORT
#ifndef __QAIC_IMPL_ATTRIBUTE
#define __QAIC_IMPL_ATTRIBUTE
#endif // __QAIC_IMPL_ATTRIBUTE
#ifndef __QAIC_STUB
#define __QAIC_STUB(ff) ff
#endif //__QAIC_STUB
#ifndef __QAIC_STUB_EXPORT
#define __QAIC_STUB_EXPORT
#endif // __QAIC_STUB_EXPORT
#ifndef __QAIC_STUB_ATTRIBUTE
#define __QAIC_STUB_ATTRIBUTE
#endif // __QAIC_STUB_ATTRIBUTE
#ifndef __QAIC_SKEL
#define __QAIC_SKEL(ff) ff
#endif //__QAIC_SKEL__
#ifndef __QAIC_SKEL_EXPORT
#define __QAIC_SKEL_EXPORT
#endif // __QAIC_SKEL_EXPORT
#ifndef __QAIC_SKEL_ATTRIBUTE
#define __QAIC_SKEL_ATTRIBUTE
#endif // __QAIC_SKEL_ATTRIBUTE
#ifdef __QAIC_DEBUG__
#ifndef __QAIC_DBG_PRINTF__
#include <stdio.h>
#define __QAIC_DBG_PRINTF__( ee ) do { printf ee ; } while(0)
#endif
#else
#define __QAIC_DBG_PRINTF__( ee ) (void)0
#endif
#define _OFFSET(src, sof) ((void*)(((char*)(src)) + (sof)))
#define _COPY(dst, dof, src, sof, sz) \
do {\
struct __copy { \
char ar[sz]; \
};\
*(struct __copy*)_OFFSET(dst, dof) = *(struct __copy*)_OFFSET(src, sof);\
} while (0)
#define _COPYIF(dst, dof, src, sof, sz) \
do {\
if(_OFFSET(dst, dof) != _OFFSET(src, sof)) {\
_COPY(dst, dof, src, sof, sz); \
} \
} while (0)
_ATTRIBUTE_UNUSED
static __inline void _qaic_memmove(void* dst, void* src, int size) {
int i;
for(i = 0; i < size; ++i) {
((char*)dst)[i] = ((char*)src)[i];
}
}
#define _MEMMOVEIF(dst, src, sz) \
do {\
if(dst != src) {\
_qaic_memmove(dst, src, sz);\
} \
} while (0)
#define _ASSIGN(dst, src, sof) \
do {\
dst = OFFSET(src, sof); \
} while (0)
#define _STD_STRLEN_IF(str) (str == 0 ? 0 : strlen(str))
#define AEE_SUCCESS 0
#define AEE_EOFFSET 0x80000400
#define AEE_EBADPARM (AEE_EOFFSET + 0x00E)
#define _TRY(ee, func) \
do { \
if (AEE_SUCCESS != ((ee) = func)) {\
__QAIC_DBG_PRINTF__((__FILE__ ":%d:error:%d:%s\n", __LINE__, (int)(ee),#func));\
goto ee##bail;\
} \
} while (0)
#define _CATCH(exception) exception##bail: if (exception != AEE_SUCCESS)
#define _ASSERT(nErr, ff) _TRY(nErr, 0 == (ff) ? AEE_EBADPARM : AEE_SUCCESS)
#ifdef __QAIC_DEBUG__
#define _ALLOCATE(nErr, pal, size, alignment, pv) _TRY(nErr, _allocator_alloc(pal, __FILE_LINE__, size, alignment, (void**)&pv))
#else
#define _ALLOCATE(nErr, pal, size, alignment, pv) _TRY(nErr, _allocator_alloc(pal, 0, size, alignment, (void**)&pv))
#endif
#endif // _QAIC_ENV_H
#ifndef _ALLOCATOR_H
#define _ALLOCATOR_H
#include <stdlib.h>
#include <stdint.h>
typedef struct _heap _heap;
struct _heap {
_heap* pPrev;
const char* loc;
uint64_t buf;
};
typedef struct _allocator {
_heap* pheap;
uint8_t* stack;
uint8_t* stackEnd;
int nSize;
} _allocator;
_ATTRIBUTE_UNUSED
static __inline int _heap_alloc(_heap** ppa, const char* loc, int size, void** ppbuf) {
_heap* pn = 0;
pn = malloc(size + sizeof(_heap) - sizeof(uint64_t));
if(pn != 0) {
pn->pPrev = *ppa;
pn->loc = loc;
*ppa = pn;
*ppbuf = (void*)&(pn->buf);
return 0;
} else {
return -1;
}
}
#define _ALIGN_SIZE(x, y) (((x) + (y-1)) & ~(y-1))
_ATTRIBUTE_UNUSED
static __inline int _allocator_alloc(_allocator* me,
const char* loc,
int size,
unsigned int al,
void** ppbuf) {
if(size < 0) {
return -1;
} else if (size == 0) {
*ppbuf = 0;
return 0;
}
if((_ALIGN_SIZE((uintptr_t)me->stackEnd, al) + size) < (uintptr_t)me->stack + me->nSize) {
*ppbuf = (uint8_t*)_ALIGN_SIZE((uintptr_t)me->stackEnd, al);
me->stackEnd = (uint8_t*)_ALIGN_SIZE((uintptr_t)me->stackEnd, al) + size;
return 0;
} else {
return _heap_alloc(&me->pheap, loc, size, ppbuf);
}
}
_ATTRIBUTE_UNUSED
static __inline void _allocator_deinit(_allocator* me) {
_heap* pa = me->pheap;
while(pa != 0) {
_heap* pn = pa;
const char* loc = pn->loc;
(void)loc;
pa = pn->pPrev;
free(pn);
}
}
_ATTRIBUTE_UNUSED
static __inline void _allocator_init(_allocator* me, uint8_t* stack, int stackSize) {
me->stack = stack;
me->stackEnd = stack + stackSize;
me->nSize = stackSize;
me->pheap = 0;
}
#endif // _ALLOCATOR_H
#ifndef SLIM_H
#define SLIM_H
#include <stdint.h>
//a C data structure for the idl types that can be used to implement
//static and dynamic language bindings fairly efficiently.
//
//the goal is to have a minimal ROM and RAM footprint and without
//doing too many allocations. A good way to package these things seemed
//like the module boundary, so all the idls within one module can share
//all the type references.
#define PARAMETER_IN 0x0
#define PARAMETER_OUT 0x1
#define PARAMETER_INOUT 0x2
#define PARAMETER_ROUT 0x3
#define PARAMETER_INROUT 0x4
//the types that we get from idl
#define TYPE_OBJECT 0x0
#define TYPE_INTERFACE 0x1
#define TYPE_PRIMITIVE 0x2
#define TYPE_ENUM 0x3
#define TYPE_STRING 0x4
#define TYPE_WSTRING 0x5
#define TYPE_STRUCTURE 0x6
#define TYPE_UNION 0x7
#define TYPE_ARRAY 0x8
#define TYPE_SEQUENCE 0x9
//these require the pack/unpack to recurse
//so it's a hint to those languages that can optimize in cases where
//recursion isn't necessary.
#define TYPE_COMPLEX_STRUCTURE (0x10 | TYPE_STRUCTURE)
#define TYPE_COMPLEX_UNION (0x10 | TYPE_UNION)
#define TYPE_COMPLEX_ARRAY (0x10 | TYPE_ARRAY)
#define TYPE_COMPLEX_SEQUENCE (0x10 | TYPE_SEQUENCE)
typedef struct Type Type;
#define INHERIT_TYPE\
int32_t nativeSize; /*in the simple case its the same as wire size and alignment*/\
union {\
struct {\
const uintptr_t p1;\
const uintptr_t p2;\
} _cast;\
struct {\
uint32_t iid;\
uint32_t bNotNil;\
} object;\
struct {\
const Type *arrayType;\
int32_t nItems;\
} array;\
struct {\
const Type *seqType;\
int32_t nMaxLen;\
} seqSimple; \
struct {\
uint32_t bFloating;\
uint32_t bSigned;\
} prim; \
const SequenceType* seqComplex;\
const UnionType *unionType;\
const StructType *structType;\
int32_t stringMaxLen;\
uint8_t bInterfaceNotNil;\
} param;\
uint8_t type;\
uint8_t nativeAlignment\
typedef struct UnionType UnionType;
typedef struct StructType StructType;
typedef struct SequenceType SequenceType;
struct Type {
INHERIT_TYPE;
};
struct SequenceType {
const Type * seqType;
uint32_t nMaxLen;
uint32_t inSize;
uint32_t routSizePrimIn;
uint32_t routSizePrimROut;
};
//byte offset from the start of the case values for
//this unions case value array. it MUST be aligned
//at the alignment requrements for the descriptor
//
//if negative it means that the unions cases are
//simple enumerators, so the value read from the descriptor
//can be used directly to find the correct case
typedef union CaseValuePtr CaseValuePtr;
union CaseValuePtr {
const uint8_t* value8s;
const uint16_t* value16s;
const uint32_t* value32s;
const uint64_t* value64s;
};
//these are only used in complex cases
//so I pulled them out of the type definition as references to make
//the type smaller
struct UnionType {
const Type *descriptor;
uint32_t nCases;
const CaseValuePtr caseValues;
const Type * const *cases;
int32_t inSize;
int32_t routSizePrimIn;
int32_t routSizePrimROut;
uint8_t inAlignment;
uint8_t routAlignmentPrimIn;
uint8_t routAlignmentPrimROut;
uint8_t inCaseAlignment;
uint8_t routCaseAlignmentPrimIn;
uint8_t routCaseAlignmentPrimROut;
uint8_t nativeCaseAlignment;
uint8_t bDefaultCase;
};
struct StructType {
uint32_t nMembers;
const Type * const *members;
int32_t inSize;
int32_t routSizePrimIn;
int32_t routSizePrimROut;
uint8_t inAlignment;
uint8_t routAlignmentPrimIn;
uint8_t routAlignmentPrimROut;
};
typedef struct Parameter Parameter;
struct Parameter {
INHERIT_TYPE;
uint8_t mode;
uint8_t bNotNil;
};
#define SLIM_IFPTR32(is32,is64) (sizeof(uintptr_t) == 4 ? (is32) : (is64))
#define SLIM_SCALARS_IS_DYNAMIC(u) (((u) & 0x00ffffff) == 0x00ffffff)
typedef struct Method Method;
struct Method {
uint32_t uScalars; //no method index
int32_t primInSize;
int32_t primROutSize;
int maxArgs;
int numParams;
const Parameter * const *params;
uint8_t primInAlignment;
uint8_t primROutAlignment;
};
typedef struct Interface Interface;
struct Interface {
int nMethods;
const Method * const *methodArray;
int nIIds;
const uint32_t *iids;
const uint16_t* methodStringArray;
const uint16_t* methodStrings;
const char* strings;
};
#endif //SLIM_H
#ifndef _CALCULATOR_SLIM_H
#define _CALCULATOR_SLIM_H
// remote.h
#include <stdint.h>
#ifndef __QAIC_SLIM
#define __QAIC_SLIM(ff) ff
#endif
#ifndef __QAIC_SLIM_EXPORT
#define __QAIC_SLIM_EXPORT
#endif
static const Type types[1];
static const Type types[1] = {{0x1,{{(const uintptr_t)0,(const uintptr_t)0}}, 2,0x1}};
static const Parameter parameters[3] = {{0x4,{{(const uintptr_t)0,(const uintptr_t)0}}, 2,0x4,3,0},{SLIM_IFPTR32(0x8,0x10),{{(const uintptr_t)&(types[0]),(const uintptr_t)0x0}}, 9,SLIM_IFPTR32(0x4,0x8),0,0},{SLIM_IFPTR32(0x8,0x10),{{(const uintptr_t)&(types[0]),(const uintptr_t)0x0}}, 9,SLIM_IFPTR32(0x4,0x8),3,0}};
static const Parameter* const parameterArrays[3] = {(&(parameters[1])),(&(parameters[2])),(&(parameters[0]))};
static const Method methods[2] = {{REMOTE_SCALARS_MAKEX(0,0,0x0,0x1,0x0,0x0),0x0,0x4,1,1,(&(parameterArrays[2])),0x1,0x4},{REMOTE_SCALARS_MAKEX(0,0,0x2,0x1,0x0,0x0),0x8,0x0,5,2,(&(parameterArrays[0])),0x4,0x1}};
static const Method* const methodArrays[2] = {&(methods[0]),&(methods[1])};
static const char strings[41] = "extract_and_match\0features\0leet\0init\0img\0";
static const uint16_t methodStrings[5] = {0,37,18,32,27};
static const uint16_t methodStringsArrays[2] = {3,0};
__QAIC_SLIM_EXPORT const Interface __QAIC_SLIM(calculator_slim) = {2,&(methodArrays[0]),0,0,&(methodStringsArrays [0]),methodStrings,strings};
#endif //_CALCULATOR_SLIM_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _const_calculator_handle
#define _const_calculator_handle ((remote_handle)-1)
#endif //_const_calculator_handle
static void _calculator_pls_dtor(void* data) {
remote_handle* ph = (remote_handle*)data;
if(_const_calculator_handle != *ph) {
(void)__QAIC_REMOTE(remote_handle_close)(*ph);
*ph = _const_calculator_handle;
}
}
static int _calculator_pls_ctor(void* ctx, void* data) {
remote_handle* ph = (remote_handle*)data;
*ph = _const_calculator_handle;
if(*ph == (remote_handle)-1) {
return __QAIC_REMOTE(remote_handle_open)((const char*)ctx, ph);
}
return 0;
}
#if (defined __qdsp6__) || (defined __hexagon__)
#pragma weak adsp_pls_add_lookup
extern int adsp_pls_add_lookup(uint32_t type, uint32_t key, int size, int (*ctor)(void* ctx, void* data), void* ctx, void (*dtor)(void* ctx), void** ppo);
#pragma weak HAP_pls_add_lookup
extern int HAP_pls_add_lookup(uint32_t type, uint32_t key, int size, int (*ctor)(void* ctx, void* data), void* ctx, void (*dtor)(void* ctx), void** ppo);
__QAIC_STUB_EXPORT remote_handle _calculator_handle(void) {
remote_handle* ph;
if(adsp_pls_add_lookup) {
if(0 == adsp_pls_add_lookup((uint32_t)_calculator_handle, 0, sizeof(*ph), _calculator_pls_ctor, "calculator", _calculator_pls_dtor, (void**)&ph)) {
return *ph;
}
return (remote_handle)-1;
} else if(HAP_pls_add_lookup) {
if(0 == HAP_pls_add_lookup((uint32_t)_calculator_handle, 0, sizeof(*ph), _calculator_pls_ctor, "calculator", _calculator_pls_dtor, (void**)&ph)) {
return *ph;
}
return (remote_handle)-1;
}
return(remote_handle)-1;
}
#else //__qdsp6__ || __hexagon__
uint32_t _calculator_atomic_CompareAndExchange(uint32_t * volatile puDest, uint32_t uExchange, uint32_t uCompare);
#ifdef _WIN32
#include "Windows.h"
uint32_t _calculator_atomic_CompareAndExchange(uint32_t * volatile puDest, uint32_t uExchange, uint32_t uCompare) {
return (uint32_t)InterlockedCompareExchange((volatile LONG*)puDest, (LONG)uExchange, (LONG)uCompare);
}
#elif __GNUC__
uint32_t _calculator_atomic_CompareAndExchange(uint32_t * volatile puDest, uint32_t uExchange, uint32_t uCompare) {
return __sync_val_compare_and_swap(puDest, uCompare, uExchange);
}
#endif //_WIN32
__QAIC_STUB_EXPORT remote_handle _calculator_handle(void) {
static remote_handle handle = _const_calculator_handle;
if((remote_handle)-1 != handle) {
return handle;
} else {
remote_handle tmp;
int nErr = _calculator_pls_ctor("calculator", (void*)&tmp);
if(nErr) {
return (remote_handle)-1;
}
if(((remote_handle)-1 != handle) || ((remote_handle)-1 != (remote_handle)_calculator_atomic_CompareAndExchange((uint32_t*)&handle, (uint32_t)tmp, (uint32_t)-1))) {
_calculator_pls_dtor(&tmp);
}
return handle;
}
}
#endif //__qdsp6__
__QAIC_STUB_EXPORT int __QAIC_STUB(calculator_skel_invoke)(uint32_t _sc, remote_arg* _pra) __QAIC_STUB_ATTRIBUTE {
return __QAIC_REMOTE(remote_handle_invoke)(_calculator_handle(), _sc, _pra);
}
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern int remote_register_dma_handle(int, uint32_t);
static __inline int _stub_method(remote_handle _handle, uint32_t _mid, uint32_t _rout0[1]) {
int _numIn[1];
remote_arg _pra[1];
uint32_t _primROut[1];
int _nErr = 0;
_numIn[0] = 0;
_pra[(_numIn[0] + 0)].buf.pv = (void*)_primROut;
_pra[(_numIn[0] + 0)].buf.nLen = sizeof(_primROut);
_TRY(_nErr, __QAIC_REMOTE(remote_handle_invoke)(_handle, REMOTE_SCALARS_MAKEX(0, _mid, 0, 1, 0, 0), _pra));
_COPY(_rout0, 0, _primROut, 0, 4);
_CATCH(_nErr) {}
return _nErr;
}
__QAIC_STUB_EXPORT int __QAIC_STUB(calculator_init)(uint32* leet) __QAIC_STUB_ATTRIBUTE {
uint32_t _mid = 0;
return _stub_method(_calculator_handle(), _mid, (uint32_t*)leet);
}
static __inline int _stub_method_1(remote_handle _handle, uint32_t _mid, char* _in0[1], uint32_t _in0Len[1], char* _rout1[1], uint32_t _rout1Len[1]) {
int _numIn[1];
remote_arg _pra[3];
uint32_t _primIn[2];
remote_arg* _praIn;
remote_arg* _praROut;
int _nErr = 0;
_numIn[0] = 1;
_pra[0].buf.pv = (void*)_primIn;
_pra[0].buf.nLen = sizeof(_primIn);
_COPY(_primIn, 0, _in0Len, 0, 4);
_praIn = (_pra + 1);
_praIn[0].buf.pv = _in0[0];
_praIn[0].buf.nLen = (1 * _in0Len[0]);
_COPY(_primIn, 4, _rout1Len, 0, 4);
_praROut = (_praIn + _numIn[0] + 0);
_praROut[0].buf.pv = _rout1[0];
_praROut[0].buf.nLen = (1 * _rout1Len[0]);
_TRY(_nErr, __QAIC_REMOTE(remote_handle_invoke)(_handle, REMOTE_SCALARS_MAKEX(0, _mid, 2, 1, 0, 0), _pra));
_CATCH(_nErr) {}
return _nErr;
}
__QAIC_STUB_EXPORT int __QAIC_STUB(calculator_extract_and_match)(const uint8* img, int imgLen, uint8* features, int featuresLen) __QAIC_STUB_ATTRIBUTE {
uint32_t _mid = 1;
return _stub_method_1(_calculator_handle(), _mid, (char**)&img, (uint32_t*)&imgLen, (char**)&features, (uint32_t*)&featuresLen);
}
#ifdef __cplusplus
}
#endif
#endif //_CALCULATOR_STUB_H

@ -0,0 +1,37 @@
#ifndef EXTRACTOR_H
#define EXTRACTOR_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#define ORBD_KEYPOINTS 3000
#define ORBD_DESCRIPTOR_LENGTH 32
#define ORBD_HEIGHT 874
#define ORBD_WIDTH 1164
// matches OrbFeatures from log.capnp
struct orb_features {
// align this
uint16_t n_corners;
uint16_t xy[ORBD_KEYPOINTS][2];
uint8_t octave[ORBD_KEYPOINTS];
uint8_t des[ORBD_KEYPOINTS][ORBD_DESCRIPTOR_LENGTH];
int16_t matches[ORBD_KEYPOINTS];
};
// forward declare this
struct pyramid;
// manage the pyramids in extractor.c
void init_gpyrs();
int extract_and_match_gpyrs(const uint8_t *img, struct orb_features *);
int extract_and_match(const uint8_t *img, struct pyramid *pyrs, struct pyramid *prev_pyrs, struct orb_features *);
#ifdef __cplusplus
}
#endif
#endif // EXTRACTOR_H

@ -0,0 +1,174 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <stdint.h>
#include <assert.h>
#include "common/visionipc.h"
#include "common/swaglog.h"
#include "extractor.h"
#ifdef DSP
#include "dsp/gen/calculator.h"
#else
#include "turbocv.h"
#endif
#include <zmq.h>
#include <capnp/serialize.h>
#include "cereal/gen/cpp/log.capnp.h"
#ifndef PATH_MAX
#include <linux/limits.h>
#endif
volatile int do_exit = 0;
static void set_do_exit(int sig) {
do_exit = 1;
}
int main(int argc, char *argv[]) {
int err;
printf("starting orbd\n");
#ifdef DSP
char my_path[PATH_MAX+1];
readlink("/proc/self/exe", my_path, PATH_MAX);
my_path[strlen(my_path)-4] = '\0';
LOGW("running from %s", my_path);
char adsp_path[PATH_MAX+1];
snprintf(adsp_path, PATH_MAX, "ADSP_LIBRARY_PATH=%s/dsp/gen;/dsp;/system/lib/rfsa/adsp;/system/vendor/lib/rfsa/adsp", my_path);
putenv(adsp_path);
uint32_t test_leet = 0;
assert(calculator_init(&test_leet) == 0);
assert(test_leet == 0x1337);
#else
init_gpyrs();
#endif
signal(SIGINT, (sighandler_t) set_do_exit);
signal(SIGTERM, (sighandler_t) set_do_exit);
void *ctx = zmq_ctx_new();
void *orb_features_sock = zmq_socket(ctx, ZMQ_PUB);
assert(orb_features_sock);
zmq_bind(orb_features_sock, "tcp://*:8058");
void *orb_features_summary_sock = zmq_socket(ctx, ZMQ_PUB);
assert(orb_features_summary_sock);
zmq_bind(orb_features_summary_sock, "tcp://*:8062");
struct orb_features *features = (struct orb_features *)malloc(sizeof(struct orb_features));
int last_frame_id = 0;
VisionStream stream;
while (!do_exit) {
VisionStreamBufs buf_info;
err = visionstream_init(&stream, VISION_STREAM_YUV, true, &buf_info);
if (err) {
printf("visionstream connect fail\n");
usleep(100000);
continue;
}
uint64_t timestamp_last_eof = 0;
while (!do_exit) {
VIPCBuf *buf;
VIPCBufExtra extra;
buf = visionstream_get(&stream, &extra);
if (buf == NULL) {
printf("visionstream get failed\n");
break;
}
uint64_t start = nanos_since_boot();
#ifdef DSP
int ret = calculator_extract_and_match((uint8_t *)buf->addr, ORBD_HEIGHT*ORBD_WIDTH, (uint8_t *)features, sizeof(struct orb_features));
#else
int ret = extract_and_match_gpyrs((uint8_t *) buf->addr, features);
#endif
uint64_t end = nanos_since_boot();
LOGD("total(%d): %6.2f ms to get %4d features on %d", ret, (end-start)/1000000.0, features->n_corners, extra.frame_id);
if (last_frame_id+1 != extra.frame_id) {
LOGW("dropped frame!");
}
last_frame_id = extra.frame_id;
if (timestamp_last_eof == 0) {
timestamp_last_eof = extra.timestamp_eof;
continue;
}
int match_count = 0;
// *** send OrbFeatures ***
{
// create capnp message
capnp::MallocMessageBuilder msg;
cereal::Event::Builder event = msg.initRoot<cereal::Event>();
event.setLogMonoTime(nanos_since_boot());
auto orb_features = event.initOrbFeatures();
// set timestamps
orb_features.setTimestampEof(extra.timestamp_eof);
orb_features.setTimestampLastEof(timestamp_last_eof);
// init descriptors for send
kj::ArrayPtr<capnp::byte> descriptorsPtr = kj::arrayPtr((uint8_t *)features->des, ORBD_DESCRIPTOR_LENGTH * features->n_corners);
orb_features.setDescriptors(descriptorsPtr);
auto xs = orb_features.initXs(features->n_corners);
auto ys = orb_features.initYs(features->n_corners);
auto octaves = orb_features.initOctaves(features->n_corners);
auto matches = orb_features.initMatches(features->n_corners);
// copy out normalized keypoints
for (int i = 0; i < features->n_corners; i++) {
xs.set(i, features->xy[i][0] * 1.0f / ORBD_WIDTH - 0.5f);
ys.set(i, features->xy[i][1] * 1.0f / ORBD_HEIGHT - 0.5f);
octaves.set(i, features->octave[i]);
matches.set(i, features->matches[i]);
match_count += features->matches[i] != -1;
}
auto words = capnp::messageToFlatArray(msg);
auto bytes = words.asBytes();
zmq_send(orb_features_sock, bytes.begin(), bytes.size(), 0);
}
// *** send OrbFeaturesSummary ***
{
// create capnp message
capnp::MallocMessageBuilder msg;
cereal::Event::Builder event = msg.initRoot<cereal::Event>();
event.setLogMonoTime(nanos_since_boot());
auto orb_features_summary = event.initOrbFeaturesSummary();
orb_features_summary.setTimestampEof(extra.timestamp_eof);
orb_features_summary.setTimestampLastEof(timestamp_last_eof);
orb_features_summary.setFeatureCount(features->n_corners);
orb_features_summary.setMatchCount(match_count);
orb_features_summary.setComputeNs(end-start);
auto words = capnp::messageToFlatArray(msg);
auto bytes = words.asBytes();
zmq_send(orb_features_summary_sock, bytes.begin(), bytes.size(), 0);
}
timestamp_last_eof = extra.timestamp_eof;
}
}
visionstream_destroy(&stream);
return 0;
}

@ -2,7 +2,7 @@ import json
import subprocess import subprocess
from selfdrive.swaglog import cloudlog from selfdrive.swaglog import cloudlog
from selfdrive.version import version from selfdrive.version import version, training_version
from common.api import api_get from common.api import api_get
from common.params import Params from common.params import Params
@ -24,6 +24,7 @@ def get_git_remote():
def register(): def register():
params = Params() params = Params()
params.put("Version", version) params.put("Version", version)
params.put("TrainingVersion", training_version)
params.put("GitCommit", get_git_commit()) params.put("GitCommit", get_git_commit())
params.put("GitBranch", get_git_branch()) params.put("GitBranch", get_git_branch())
params.put("GitRemote", get_git_remote()) params.put("GitRemote", get_git_remote())

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:536c91fab8a36e7cdb06ade1599cad406a206c1b681bb1873fdb7c39e6213a58 oid sha256:e694582549cfe8d1ed27d2e6e34b3f8dc1c01bf2a257c30251bd1af65229bf5d
size 981400 size 981400

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:da501e3c27b8e736b6c99dac2b7c27ffb38aa43febe56b8134668250eeebb4aa oid sha256:2cc5877fcc3d8ba9bc1ac50b4effcf62b3a865081d5c18b56528cfbef42eda4c
size 972296 size 972296

@ -64,10 +64,11 @@ applanixLocation: [8053, true]
liveLocationKalman: [8054, true] liveLocationKalman: [8054, true]
uiNavigationEvent: [8055, true] uiNavigationEvent: [8055, true]
orbOdometry: [8057, true] orbOdometry: [8057, true]
orbFeatures: [8058, true] orbFeatures: [8058, false]
orbKeyFrame: [8059, true] orbKeyFrame: [8059, true]
uiLayoutState: [8060, true] uiLayoutState: [8060, true]
frontEncodeIdx: [8061, true] frontEncodeIdx: [8061, true]
orbFeaturesSummary: [8062, true]
testModel: [8040, false] testModel: [8040, false]
testLiveLocation: [8045, false] testLiveLocation: [8045, false]

@ -211,6 +211,7 @@ class Plant(object):
print "%6.2f m %6.2f m/s %6.2f m/s2 %.2f ang gas: %.2f brake: %.2f steer: %5.2f lead_rel: %6.2f m %6.2f m/s" % (distance, speed, acceleration, self.angle_steer, gas, brake, steer_torque, d_rel, v_rel) print "%6.2f m %6.2f m/s %6.2f m/s2 %.2f ang gas: %.2f brake: %.2f steer: %5.2f lead_rel: %6.2f m %6.2f m/s" % (distance, speed, acceleration, self.angle_steer, gas, brake, steer_torque, d_rel, v_rel)
# ******** publish the car ******** # ******** publish the car ********
# TODO: the order is this list should not matter, but currently everytime we change carstate we break this test. Fix it!
vls = [self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed), vls = [self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed),
self.angle_steer, self.angle_steer_rate, 0, self.angle_steer, self.angle_steer_rate, 0,
0, 0, 0, 0, # Doors 0, 0, 0, 0, # Doors

@ -1465,10 +1465,10 @@ static void ui_update(UIState *s) {
assert(glGetError() == GL_NO_ERROR); assert(glGetError() == GL_NO_ERROR);
// Default UI Measurements (Assumes sidebar visible) // Default UI Measurements (Assumes sidebar collapsed)
s->scene.ui_viz_rx = box_x; s->scene.ui_viz_rx = (box_x-sbr_w+bdr_s*2);
s->scene.ui_viz_rw = box_w; s->scene.ui_viz_rw = (box_w+sbr_w-(bdr_s*2));
s->scene.ui_viz_ro = -(sbr_w - 4*bdr_s); s->scene.ui_viz_ro = 0;
s->vision_connect_firstrun = false; s->vision_connect_firstrun = false;
} }

@ -16,3 +16,7 @@ try:
dirty = True dirty = True
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
dirty = True dirty = True
# put this here
training_version = "0.1.0"

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:120cc9f11d56e4b67a2b9600b04500601ad597f8f4516e1c22cf32330a891442 oid sha256:53701cb3f9469c23d4e48e8bb417c307f1b41a3de3172fe3031d85613d8b31c1
size 13386048 size 13386064

Loading…
Cancel
Save