dmonitoringmodeld: initialize model first (#29080)

* hacky fix

* even better

* ordering

* clean up

* fix model replay

* add comment

* catch sigint
pull/29109/head
Shane Smiskol 2 years ago committed by GitHub
parent 34389acbbf
commit 12ed894362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      common/params.cc
  2. 3
      selfdrive/modeld/dmonitoringmodeld.cc
  3. 8
      selfdrive/modeld/navmodeld.cc
  4. 2
      selfdrive/test/process_replay/model_replay.py

@ -107,6 +107,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"DisablePowerDown", PERSISTENT},
{"DisableUpdates", PERSISTENT},
{"DisengageOnAccelerator", PERSISTENT},
{"DmModelInitialized", CLEAR_ON_ONROAD_TRANSITION},
{"DongleId", PERSISTENT},
{"DoReboot", CLEAR_ON_MANAGER_START},
{"DoShutdown", CLEAR_ON_MANAGER_START},

@ -5,6 +5,7 @@
#include <cstdlib>
#include "cereal/visionipc/visionipc_client.h"
#include "common/params.h"
#include "common/swaglog.h"
#include "common/util.h"
#include "selfdrive/modeld/models/dmonitoring.h"
@ -49,6 +50,8 @@ int main(int argc, char **argv) {
DMonitoringModelState model;
dmonitoring_init(&model);
Params().putBool("DmModelInitialized", true);
LOGW("connecting to driver stream");
VisionIpcClient vipc_client = VisionIpcClient("camerad", VISION_STREAM_DRIVER, true);
while (!do_exit && !vipc_client.connect(false)) {

@ -5,6 +5,7 @@
#include <cstdlib>
#include "cereal/visionipc/visionipc_client.h"
#include "common/params.h"
#include "common/swaglog.h"
#include "common/util.h"
#include "selfdrive/modeld/models/nav.h"
@ -41,6 +42,13 @@ void run_model(NavModelState &model, VisionIpcClient &vipc_client) {
int main(int argc, char **argv) {
setpriority(PRIO_PROCESS, 0, -15);
// there exists a race condition when two processes try to create a
// SNPE model runner at the same time, wait for dmonitoringmodeld to finish
LOGW("waiting for dmonitoringmodeld to initialize");
if (!Params().getBool("DmModelInitialized", true)) {
return 0;
}
// init the models
NavModelState model;
navmodel_init(&model);

@ -6,6 +6,7 @@ from collections import defaultdict
from typing import Any
import cereal.messaging as messaging
from common.params import Params
from common.spinner import Spinner
from system.hardware import PC
from selfdrive.manager.process_config import managed_processes
@ -62,6 +63,7 @@ def nav_model_replay(lr):
try:
assert "MAPBOX_TOKEN" in os.environ
os.environ['MAP_RENDER_TEST_MODE'] = '1'
Params().put_bool('DmModelInitialized', True)
managed_processes['mapsd'].start()
managed_processes['navmodeld'].start()

Loading…
Cancel
Save