diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 49457c52f8..f6b7de38c3 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -52,9 +52,10 @@ class Controls: self.sm = sm if self.sm is None: + ignore = ['ubloxRaw', 'frontFrame'] if SIMULATION else None self.sm = messaging.SubMaster(['thermal', 'health', 'model', 'liveCalibration', 'ubloxRaw', 'dMonitoringState', 'plan', 'pathPlan', 'liveLocationKalman', - 'frame', 'frontFrame']) + 'frame', 'frontFrame'], ignore_alive=ignore) self.can_sock = can_sock if can_sock is None: @@ -199,7 +200,7 @@ class Controls: if self.can_rcv_error or (not CS.canValid and self.sm.frame > 5 / DT_CTRL): self.events.add(EventName.canError) if (self.sm['health'].safetyModel != self.CP.safetyModel and self.sm.frame > 2 / DT_CTRL) or \ - self.mismatch_counter >= 200: + self.mismatch_counter >= 200: self.events.add(EventName.controlsMismatch) if not self.sm.alive['plan'] and self.sm.alive['pathPlan']: # only plan not being received: radar not communicating diff --git a/tools/sim/bridge.py b/tools/sim/bridge.py index cb823c9a18..3b3d8e9e40 100755 --- a/tools/sim/bridge.py +++ b/tools/sim/bridge.py @@ -61,7 +61,7 @@ def cam_callback(image): dat = messaging.new_message('frame') dat.frame = { - "frameId": frame_id, # TODO: can we get frame ID from the CARLA camera? + "frameId": image.frame, "image": img.tostring(), "transform": [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0] } @@ -89,7 +89,8 @@ def health_function(): dat.health = { 'ignitionLine': True, 'hwType': "blackPanda", - 'controlsAllowed': True + 'controlsAllowed': True, + 'safetyModel': 'hondaNidec' } pm.send('health', dat) time.sleep(0.5) diff --git a/tools/sim/lib/keyboard_ctrl.py b/tools/sim/lib/keyboard_ctrl.py index c66bf94e20..0ae11102a4 100644 --- a/tools/sim/lib/keyboard_ctrl.py +++ b/tools/sim/lib/keyboard_ctrl.py @@ -44,6 +44,14 @@ def keyboard_poll_thread(q): q.put(str("cruise_down")) if c == '3': q.put(str("cruise_cancel")) + if c == 'w': + q.put(str("throttle_%f" % 1.0)) + if c == 'a': + q.put(str("steer_%f" % 0.15)) + if c == 's': + q.put(str("brake_%f" % 1.0)) + if c == 'd': + q.put(str("steer_%f" % -0.15)) if c == 'q': exit(0) diff --git a/tools/sim/start_carla.sh b/tools/sim/start_carla.sh index 2be3d0cc38..b165e3935d 100755 --- a/tools/sim/start_carla.sh +++ b/tools/sim/start_carla.sh @@ -16,4 +16,19 @@ if ! $(apt list --installed | grep -q nvidia-container-toolkit); then fi docker pull carlasim/carla:0.9.7 -docker run -it --net=host --gpus all carlasim/carla:0.9.7 + +if [ -z "$WINDOW" ]; then + docker run -it --net=host --gpus all carlasim/carla:0.9.7 +else + docker run --name openpilot_carla \ + --privileged --rm \ + --net=host \ + -e SDL_VIDEODRIVER=x11 \ + -e DISPLAY=$DISPLAY \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -it \ + --gpus all \ + carlasim/carla:0.9.7 \ + ./CarlaUE4.sh -quality-level=Medium +fi +