mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-15 22:32:11 +08:00
openpilot v0.9.7 release
date: 2024-03-17T10:14:38 master commit: 7e9a909e0e57ecb31df4c87c5b9a06b1204fd034
This commit is contained in:
@@ -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 -3
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||
cd $DIR
|
||||
|
||||
# git clone --mirror
|
||||
SRC=/tmp/openpilot.git/
|
||||
OUT=/tmp/smallpilot/
|
||||
|
||||
echo "starting size $(du -hs .git/)"
|
||||
|
||||
rm -rf $OUT
|
||||
|
||||
cd $SRC
|
||||
git remote update
|
||||
|
||||
# copy contents
|
||||
#rsync -a --exclude='.git/' $DIR $OUT
|
||||
|
||||
cp -r $SRC $OUT
|
||||
|
||||
cd $OUT
|
||||
|
||||
# remove all tags
|
||||
git tag -l | xargs git tag -d
|
||||
|
||||
# remove non-master branches
|
||||
BRANCHES="release2 release3 devel master-ci nightly"
|
||||
for branch in $BRANCHES; do
|
||||
git branch -D $branch
|
||||
git branch -D ${branch}-staging || true
|
||||
done
|
||||
|
||||
#git gc
|
||||
git reflog expire --expire=now --all
|
||||
git gc --prune=now
|
||||
git gc --aggressive --prune=now
|
||||
echo "new one is $(du -hs .)"
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/bash
|
||||
nmcli connection modify --temporary esim ipv4.route-metric 1 ipv6.route-metric 1
|
||||
nmcli con up esim
|
||||
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
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]+')"
|
||||
BRANCH=tmp-pr${PR_NUM}
|
||||
|
||||
git branch -D -f $BRANCH || true
|
||||
git fetch -u -f origin pull/$PR_NUM/head:$BRANCH
|
||||
git switch $BRANCH
|
||||
git reset --hard FETCH_HEAD
|
||||
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import ast
|
||||
import stat
|
||||
import subprocess
|
||||
|
||||
fouts = {x.decode('utf-8') for x in subprocess.check_output(['git', 'ls-files']).strip().split()}
|
||||
|
||||
pyf = []
|
||||
for d in ["cereal", "common", "scripts", "selfdrive", "tools"]:
|
||||
for root, _, files in os.walk(d):
|
||||
for f in files:
|
||||
if f.endswith(".py"):
|
||||
pyf.append(os.path.join(root, f))
|
||||
|
||||
imps: set[str] = set()
|
||||
|
||||
class Analyzer(ast.NodeVisitor):
|
||||
def visit_Import(self, node):
|
||||
for alias in node.names:
|
||||
imps.add(alias.name)
|
||||
self.generic_visit(node)
|
||||
|
||||
def visit_ImportFrom(self, node):
|
||||
imps.add(node.module)
|
||||
self.generic_visit(node)
|
||||
|
||||
tlns = 0
|
||||
carlns = 0
|
||||
scriptlns = 0
|
||||
testlns = 0
|
||||
for f in sorted(pyf):
|
||||
if f not in fouts:
|
||||
continue
|
||||
xbit = bool(os.stat(f)[stat.ST_MODE] & stat.S_IXUSR)
|
||||
src = open(f).read()
|
||||
lns = len(src.split("\n"))
|
||||
tree = ast.parse(src)
|
||||
Analyzer().visit(tree)
|
||||
print("%5d %s %s" % (lns, f, xbit))
|
||||
if 'test' in f:
|
||||
testlns += lns
|
||||
elif f.startswith(('tools/', 'scripts/', 'selfdrive/debug')):
|
||||
scriptlns += lns
|
||||
elif f.startswith('selfdrive/car'):
|
||||
carlns += lns
|
||||
else:
|
||||
tlns += lns
|
||||
|
||||
print("%d lines of openpilot python" % tlns)
|
||||
print("%d lines of car ports" % carlns)
|
||||
print("%d lines of tools/scripts/debug" % scriptlns)
|
||||
print("%d lines of tests" % testlns)
|
||||
#print(sorted(list(imps)))
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
from collections import Counter
|
||||
from pprint import pprint
|
||||
|
||||
from openpilot.selfdrive.car.docs import get_all_car_docs
|
||||
|
||||
if __name__ == "__main__":
|
||||
cars = get_all_car_docs()
|
||||
make_count = Counter(l.make for l in cars)
|
||||
print("\n", "*" * 20, len(cars), "total", "*" * 20, "\n")
|
||||
pprint(make_count)
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
from openpilot.system.hardware import HARDWARE
|
||||
|
||||
if __name__ == "__main__":
|
||||
HARDWARE.set_power_save(False)
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||
|
||||
export FINGERPRINT="TOYOTA COROLLA TSS2 2019"
|
||||
export SKIP_FW_QUERY="1"
|
||||
$DIR/../launch_openpilot.sh
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from PyQt5.QtWidgets import QApplication, QLabel
|
||||
from openpilot.selfdrive.ui.qt.python_helpers import set_main_window
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication([])
|
||||
label = QLabel('Hello World!')
|
||||
|
||||
# Set full screen and rotate
|
||||
set_main_window(label)
|
||||
|
||||
app.exec_()
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
pip install --upgrade pyupgrade
|
||||
|
||||
git ls-files '*.py' | grep -v 'third_party/' | xargs pyupgrade --py311-plus
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
function fail {
|
||||
echo $1 >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
function retry {
|
||||
local n=1
|
||||
local max=3 # 3 retries before failure
|
||||
local delay=5 # delay between retries, 5 seconds
|
||||
while true; do
|
||||
echo "Running command '$@' with retry, attempt $n/$max"
|
||||
"$@" && break || {
|
||||
if [[ $n -lt $max ]]; then
|
||||
((n++))
|
||||
sleep $delay;
|
||||
else
|
||||
fail "The command has failed after $n attempts."
|
||||
fi
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
retry "$@"
|
||||
fi
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# Stop updater
|
||||
pkill -2 -f selfdrive.updated.updated
|
||||
|
||||
# Remove pending update
|
||||
rm -f /data/safe_staging/finalized/.overlay_consistent
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# Send SIGHUP to updater
|
||||
pkill -1 -f selfdrive.updated
|
||||
@@ -0,0 +1,89 @@
|
||||
// gcc -O2 waste.c -lpthread -owaste
|
||||
// gcc -O2 waste.c -lpthread -owaste -DMEM
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <sched.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <arm_neon.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include "../common/timing.h"
|
||||
|
||||
int get_nprocs(void);
|
||||
double *ttime, *oout;
|
||||
|
||||
void waste(int pid) {
|
||||
cpu_set_t my_set;
|
||||
CPU_ZERO(&my_set);
|
||||
CPU_SET(pid, &my_set);
|
||||
int ret = sched_setaffinity(0, sizeof(cpu_set_t), &my_set);
|
||||
printf("set affinity to %d: %d\n", pid, ret);
|
||||
|
||||
// 128 MB
|
||||
float32x4_t *tmp = (float32x4_t *)malloc(0x800000*sizeof(float32x4_t));
|
||||
|
||||
// comment out the memset for CPU only and not RAM
|
||||
// otherwise we need this to avoid the zero page
|
||||
#ifdef MEM
|
||||
memset(tmp, 0xaa, 0x800000*sizeof(float32x4_t));
|
||||
#endif
|
||||
|
||||
float32x4_t out;
|
||||
|
||||
double sec = seconds_since_boot();
|
||||
while (1) {
|
||||
for (int i = 0; i < 0x10; i++) {
|
||||
for (int j = 0; j < 0x800000; j+=0x20) {
|
||||
out = vmlaq_f32(out, tmp[j+0], tmp[j+1]);
|
||||
out = vmlaq_f32(out, tmp[j+2], tmp[j+3]);
|
||||
out = vmlaq_f32(out, tmp[j+4], tmp[j+5]);
|
||||
out = vmlaq_f32(out, tmp[j+6], tmp[j+7]);
|
||||
out = vmlaq_f32(out, tmp[j+8], tmp[j+9]);
|
||||
out = vmlaq_f32(out, tmp[j+10], tmp[j+11]);
|
||||
out = vmlaq_f32(out, tmp[j+12], tmp[j+13]);
|
||||
out = vmlaq_f32(out, tmp[j+14], tmp[j+15]);
|
||||
out = vmlaq_f32(out, tmp[j+16], tmp[j+17]);
|
||||
out = vmlaq_f32(out, tmp[j+18], tmp[j+19]);
|
||||
out = vmlaq_f32(out, tmp[j+20], tmp[j+21]);
|
||||
out = vmlaq_f32(out, tmp[j+22], tmp[j+23]);
|
||||
out = vmlaq_f32(out, tmp[j+24], tmp[j+25]);
|
||||
out = vmlaq_f32(out, tmp[j+26], tmp[j+27]);
|
||||
out = vmlaq_f32(out, tmp[j+28], tmp[j+29]);
|
||||
out = vmlaq_f32(out, tmp[j+30], tmp[j+31]);
|
||||
}
|
||||
}
|
||||
double nsec = seconds_since_boot();
|
||||
ttime[pid] = nsec-sec;
|
||||
oout[pid] = out[0] + out[1] + out[2] + out[3];
|
||||
sec = nsec;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
int CORES = get_nprocs();
|
||||
ttime = (double *)malloc(CORES*sizeof(double));
|
||||
oout = (double *)malloc(CORES*sizeof(double));
|
||||
|
||||
pthread_t waster[CORES];
|
||||
for (long i = 0; i < CORES; i++) {
|
||||
ttime[i] = NAN;
|
||||
pthread_create(&waster[i], NULL, (void *(*)(void *))waste, (void*)i);
|
||||
}
|
||||
while (1) {
|
||||
double avg = 0.0;
|
||||
double iavg = 0.0;
|
||||
for (int i = 0; i < CORES; i++) {
|
||||
avg += ttime[i];
|
||||
iavg += 1/ttime[i];
|
||||
printf("%4.2f ", ttime[i]);
|
||||
}
|
||||
double mb_per_sec = (16.*0x800000/(1024*1024))*sizeof(float32x4_t)*iavg;
|
||||
printf("-- %4.2f -- %.2f MB/s \n", avg/CORES, mb_per_sec);
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import time
|
||||
import numpy as np
|
||||
from multiprocessing import Process
|
||||
from setproctitle import setproctitle
|
||||
|
||||
def waste(core):
|
||||
os.sched_setaffinity(0, [core,])
|
||||
|
||||
m1 = np.zeros((200, 200)) + 0.8
|
||||
m2 = np.zeros((200, 200)) + 1.2
|
||||
|
||||
i = 1
|
||||
st = time.monotonic()
|
||||
j = 0
|
||||
while 1:
|
||||
if (i % 100) == 0:
|
||||
setproctitle("%3d: %8d" % (core, i))
|
||||
lt = time.monotonic()
|
||||
print("%3d: %8d %f %.2f" % (core, i, lt-st, j))
|
||||
st = lt
|
||||
i += 1
|
||||
j = np.sum(np.matmul(m1, m2))
|
||||
|
||||
def main(gctx=None):
|
||||
print("1-2 seconds is baseline")
|
||||
for i in range(os.cpu_count()):
|
||||
p = Process(target=waste, args=(i,))
|
||||
p.start()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user