#include "selfdrive/modeld/models/nav.h" #include #include #include "common/mat.h" #include "common/modeldata.h" #include "common/timing.h" void navmodel_init(NavModelState* s) { #ifdef USE_ONNX_MODEL s->m = new ONNXModel("models/navmodel.onnx", &s->output[0], NAV_NET_OUTPUT_SIZE, USE_DSP_RUNTIME, true); #else s->m = new SNPEModel("models/navmodel_q.dlc", &s->output[0], NAV_NET_OUTPUT_SIZE, USE_DSP_RUNTIME, true); #endif s->m->addInput("map", NULL, 0); } NavModelResult* navmodel_eval_frame(NavModelState* s, VisionBuf* buf) { memcpy(s->net_input_buf, buf->addr, NAV_INPUT_SIZE); double t1 = millis_since_boot(); s->m->setInputBuffer("map", (float*)s->net_input_buf, NAV_INPUT_SIZE/sizeof(float)); s->m->execute(); double t2 = millis_since_boot(); NavModelResult *model_res = (NavModelResult*)&s->output; model_res->dsp_execution_time = (t2 - t1) / 1000.; return model_res; } void fill_plan(cereal::NavModelData::Builder &framed, const NavModelOutputPlan &plan) { std::array pos_x, pos_y; std::array pos_x_std, pos_y_std; for (int i=0; im; }