mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 17:43:54 +08:00
* Revert "put cereal on master"
This reverts commit 4646c132bae7358079c9b2867725f8382906c1e5.
* Revert "Revert fullframe DM model (#24812)"
This reverts commit 59e8af4c3101785cead69a9880cc03e0a18081e1.
* revert revert cereal
* clip6
* 0.8 is fair
* Fiction compensation should be based on error
* Update refs
* Add deadzone
* not that
* good mg
* ref
* ref
* ee8f
* minor tweak
* ref
* recompile
* ref
* cereal
* match driverstatus
* new ref
* new ref
* pass token through jenkins credentials
* quote
* fix snpe dead weights
* final ref
Co-authored-by: Harald Schafer <harald.the.engineer@gmail.com>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
old-commit-hash: 1f2f9ea9c9
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;
|
|
}
|