mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-07-16 02:12:06 +08:00
d6c07a6b15
* get log * simplify two nonsense * not needed * libyuv is a joke * clean up * try small * fast but not bad * working * clean up driverview * simplified * thats mirrored * smol * tweak * ref is screen * w/ ee * update camera model * no if TICI * start * update pose thresh * less cpu more dsp * new libyuv * new snpe * add files * test * should be fast * update out len * trigger test * use master snpe * add cereal * update cereal * refactor parsing * missing ; * get * wrong type * test model * use driver data * 10829278-72fe-4283-a118-2cef959ce174/1550 * no pf * adapt driverview * ; * rhd learner * update libyuv buildi x64 * ad4337ea * remove blink slack * test * no * use toggle * b16 * fix for nv12 * 5b02cff5 both * update test * update cereal * update cereal * update cereal * v2 packets * revert libyuv * no / * update snpemodel * ; * memcpy * fix test * use toggle in driverview * update power * update replay * Revert "update replay" This reverts commit 1d0979ca59dbc89bc5890656e9501e83f0556d50. * update model ref * halve cpu * fake 8bit onnx runner * same thresh as report * cereal master Co-authored-by: Comma Device <device@comma.ai>
66 lines
1.8 KiB
C++
66 lines
1.8 KiB
C++
#include <sys/resource.h>
|
|
#include <limits.h>
|
|
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
|
|
#include "cereal/visionipc/visionipc_client.h"
|
|
#include "common/swaglog.h"
|
|
#include "common/util.h"
|
|
#include "selfdrive/modeld/models/dmonitoring.h"
|
|
|
|
ExitHandler do_exit;
|
|
|
|
void run_model(DMonitoringModelState &model, VisionIpcClient &vipc_client) {
|
|
PubMaster pm({"driverStateV2"});
|
|
SubMaster sm({"liveCalibration"});
|
|
float calib[CALIB_LEN] = {0};
|
|
double last = 0;
|
|
|
|
while (!do_exit) {
|
|
VisionIpcBufExtra extra = {};
|
|
VisionBuf *buf = vipc_client.recv(&extra);
|
|
if (buf == nullptr) continue;
|
|
|
|
sm.update(0);
|
|
if (sm.updated("liveCalibration")) {
|
|
auto calib_msg = sm["liveCalibration"].getLiveCalibration().getRpyCalib();
|
|
for (int i = 0; i < CALIB_LEN; i++) {
|
|
calib[i] = calib_msg[i];
|
|
}
|
|
}
|
|
|
|
double t1 = millis_since_boot();
|
|
DMonitoringModelResult model_res = dmonitoring_eval_frame(&model, buf->addr, buf->width, buf->height, buf->stride, buf->uv_offset, calib);
|
|
double t2 = millis_since_boot();
|
|
|
|
// send dm packet
|
|
dmonitoring_publish(pm, extra.frame_id, model_res, (t2 - t1) / 1000.0, model.output);
|
|
|
|
//printf("dmonitoring process: %.2fms, from last %.2fms\n", t2 - t1, t1 - last);
|
|
last = t1;
|
|
}
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
setpriority(PRIO_PROCESS, 0, -15);
|
|
|
|
// init the models
|
|
DMonitoringModelState model;
|
|
dmonitoring_init(&model);
|
|
|
|
VisionIpcClient vipc_client = VisionIpcClient("camerad", VISION_STREAM_DRIVER, true);
|
|
while (!do_exit && !vipc_client.connect(false)) {
|
|
util::sleep_for(100);
|
|
}
|
|
|
|
// run the models
|
|
if (vipc_client.connected) {
|
|
LOGW("connected with buffer size: %d", vipc_client.buffers[0].len);
|
|
run_model(model, vipc_client);
|
|
}
|
|
|
|
dmonitoring_free(&model);
|
|
return 0;
|
|
}
|