* use carla provided frame_number

* fix carla comm issues error

* add minimal W-A-S-D keyboard controls

* fix window from carla docker not showing

* carla 0.9.7 uses `frame`, not `frame_number`

* set safetyModel on health for simulator

* safetyModel check now works with simulator

* ignore ubloxRaw and frontFrame when running sim

* Update selfdrive/controls/controlsd.py

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* added WINDOW flag for optional show carla window

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
pull/19832/head
Marcos S 4 years ago committed by GitHub
parent a4098d7bb0
commit c03a95f7f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      selfdrive/controls/controlsd.py
  2. 5
      tools/sim/bridge.py
  3. 8
      tools/sim/lib/keyboard_ctrl.py
  4. 17
      tools/sim/start_carla.sh

@ -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

@ -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)

@ -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)

@ -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

Loading…
Cancel
Save