manager: start bridge and web joystick for notcars (#24212)

* manager: start bridge and web joystick for notcars

* fix that

* bump cereal

Co-authored-by: Comma Device <device@comma.ai>
pull/24276/head
Adeeb Shihadeh 3 years ago committed by GitHub
parent 28149eae4d
commit 76a8338197
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      cereal
  2. 5
      selfdrive/manager/manager.py
  3. 15
      selfdrive/manager/process.py
  4. 5
      selfdrive/manager/process_config.py
  5. 13
      tools/joystick/web.py

@ -1 +1 @@
Subproject commit 1b342ce4e00cacc0c87f3339cd7696e2ab0e62fe
Subproject commit 6eb3994daa0f64f57a36606a7bdd982ed2ac9d2d

@ -131,16 +131,15 @@ def manager_thread() -> None:
ensure_running(managed_processes.values(), started=False, not_run=ignore)
started_prev = False
sm = messaging.SubMaster(['deviceState'])
sm = messaging.SubMaster(['deviceState', 'carParams'], poll=['deviceState'])
pm = messaging.PubMaster(['managerState'])
while True:
sm.update()
not_run = ignore[:]
started = sm['deviceState'].started
driverview = params.get_bool("IsDriverViewEnabled")
ensure_running(managed_processes.values(), started, driverview, not_run)
ensure_running(managed_processes.values(), started=started, driverview=driverview, notcar=sm['carParams'].notCar, not_run=ignore)
# trigger an update after going offroad
if started_prev and not started and 'updated' in managed_processes:

@ -71,6 +71,7 @@ class ManagerProcess(ABC):
sigkill = False
persistent = False
driverview = False
notcar = False
proc: Optional[Process] = None
enabled = True
name = ""
@ -182,13 +183,14 @@ class ManagerProcess(ABC):
class NativeProcess(ManagerProcess):
def __init__(self, name, cwd, cmdline, enabled=True, persistent=False, driverview=False, unkillable=False, sigkill=False, watchdog_max_dt=None):
def __init__(self, name, cwd, cmdline, enabled=True, persistent=False, driverview=False, notcar=False, unkillable=False, sigkill=False, watchdog_max_dt=None):
self.name = name
self.cwd = cwd
self.cmdline = cmdline
self.enabled = enabled
self.persistent = persistent
self.driverview = driverview
self.notcar = notcar
self.unkillable = unkillable
self.sigkill = sigkill
self.watchdog_max_dt = watchdog_max_dt
@ -213,12 +215,13 @@ class NativeProcess(ManagerProcess):
class PythonProcess(ManagerProcess):
def __init__(self, name, module, enabled=True, persistent=False, driverview=False, unkillable=False, sigkill=False, watchdog_max_dt=None):
def __init__(self, name, module, enabled=True, persistent=False, driverview=False, notcar=False, unkillable=False, sigkill=False, watchdog_max_dt=None):
self.name = name
self.module = module
self.enabled = enabled
self.persistent = persistent
self.driverview = driverview
self.notcar = notcar
self.unkillable = unkillable
self.sigkill = sigkill
self.watchdog_max_dt = watchdog_max_dt
@ -284,7 +287,8 @@ class DaemonProcess(ManagerProcess):
pass
def ensure_running(procs: ValuesView[ManagerProcess], started: bool, driverview: bool=False, not_run: Optional[List[str]]=None) -> None:
def ensure_running(procs: ValuesView[ManagerProcess], started: bool, driverview: bool=False, notcar: bool=False,
not_run: Optional[List[str]]=None) -> None:
if not_run is None:
not_run = []
@ -297,6 +301,11 @@ def ensure_running(procs: ValuesView[ManagerProcess], started: bool, driverview:
p.start()
elif p.driverview and driverview:
p.start()
elif p.notcar:
if notcar:
p.start()
else:
p.stop(block=False)
elif started:
p.start()
else:

@ -14,7 +14,7 @@ procs = [
NativeProcess("logcatd", "selfdrive/logcatd", ["./logcatd"]),
NativeProcess("loggerd", "selfdrive/loggerd", ["./loggerd"]),
NativeProcess("modeld", "selfdrive/modeld", ["./modeld"]),
NativeProcess("navd", "selfdrive/ui/navd", ["./navd"], enabled=(PC or TICI), persistent=True),
NativeProcess("navd", "selfdrive/ui/navd", ["./navd"], persistent=True),
NativeProcess("proclogd", "selfdrive/proclogd", ["./proclogd"]),
NativeProcess("sensord", "selfdrive/sensord", ["./sensord"], enabled=not PC),
NativeProcess("ubloxd", "selfdrive/locationd", ["./ubloxd"], enabled=(not PC or WEBCAM)),
@ -38,6 +38,9 @@ procs = [
PythonProcess("uploader", "selfdrive.loggerd.uploader", persistent=True),
PythonProcess("statsd", "selfdrive.statsd", persistent=True),
NativeProcess("bridge", "cereal/messaging", ["./bridge"], notcar=True),
PythonProcess("webjoystick", "tools.joystick.web", notcar=True),
# Experimental
PythonProcess("rawgpsd", "selfdrive.sensord.rawgps.rawgpsd", enabled=os.path.isfile("/persist/comma/use-quectel-rawgps")),
]

@ -1,7 +1,8 @@
#!/usr/bin/env python3
from flask import Flask
import time
import threading
from flask import Flask
import cereal.messaging as messaging
app = Flask(__name__)
@ -31,7 +32,7 @@ setInterval(function(){
def hello_world():
return index
last_send_time = time.time()
last_send_time = time.monotonic()
@app.route("/control/<x>/<y>")
def control(x, y):
global last_send_time
@ -42,12 +43,12 @@ def control(x, y):
dat.testJoystick.axes = [y,x]
dat.testJoystick.buttons = [False]
pm.send('testJoystick', dat)
last_send_time = time.time()
last_send_time = time.monotonic()
return ""
def handle_timeout():
while 1:
this_time = time.time()
this_time = time.monotonic()
if (last_send_time+0.5) < this_time:
print("timeout, no web in %.2f s" % (this_time-last_send_time))
dat = messaging.new_message('testJoystick')
@ -56,7 +57,9 @@ def handle_timeout():
pm.send('testJoystick', dat)
time.sleep(0.1)
if __name__ == '__main__':
def main():
threading.Thread(target=handle_timeout, daemon=True).start()
app.run(host="0.0.0.0")
if __name__ == '__main__':
main()

Loading…
Cancel
Save