sim: add ignition toggling (#24043)
parent
67e3a2c39a
commit
bb36a1c8b2
|
@ -48,6 +48,7 @@ class VehicleState:
|
|||
self.vel = carla.Vector3D()
|
||||
self.cruise_button = 0
|
||||
self.is_engaged = False
|
||||
self.ignition = True
|
||||
|
||||
|
||||
def steer_rate_limit(old, new):
|
||||
|
@ -126,13 +127,13 @@ def imu_callback(imu, vehicle_state):
|
|||
pm.send('sensorEvents', dat)
|
||||
|
||||
|
||||
def panda_state_function(exit_event: threading.Event):
|
||||
def panda_state_function(vs: VehicleState, exit_event: threading.Event):
|
||||
pm = messaging.PubMaster(['pandaStates'])
|
||||
while not exit_event.is_set():
|
||||
dat = messaging.new_message('pandaStates', 1)
|
||||
dat.valid = True
|
||||
dat.pandaStates[0] = {
|
||||
'ignitionLine': True,
|
||||
'ignitionLine': vs.ignition,
|
||||
'pandaType': "blackPanda",
|
||||
'controlsAllowed': True,
|
||||
'safetyModel': 'hondaNidec'
|
||||
|
@ -283,7 +284,7 @@ def bridge(q):
|
|||
# launch fake car threads
|
||||
threads = []
|
||||
exit_event = threading.Event()
|
||||
threads.append(threading.Thread(target=panda_state_function, args=(exit_event,)))
|
||||
threads.append(threading.Thread(target=panda_state_function, args=(vehicle_state, exit_event,)))
|
||||
threads.append(threading.Thread(target=peripheral_state_function, args=(exit_event,)))
|
||||
threads.append(threading.Thread(target=fake_driver_monitoring, args=(exit_event,)))
|
||||
threads.append(threading.Thread(target=can_function_runner, args=(vehicle_state, exit_event,)))
|
||||
|
@ -346,6 +347,8 @@ def bridge(q):
|
|||
elif m[1] == "cancel":
|
||||
cruise_button = CruiseButtons.CANCEL
|
||||
is_openpilot_engaged = False
|
||||
elif m[0] == "ignition":
|
||||
vehicle_state.ignition = not vehicle_state.ignition
|
||||
elif m[0] == "quit":
|
||||
break
|
||||
|
||||
|
|
|
@ -53,6 +53,8 @@ def keyboard_poll_thread(q: 'Queue[str]'):
|
|||
q.put("brake_%f" % 1.0)
|
||||
elif c == 'd':
|
||||
q.put("steer_%f" % -0.15)
|
||||
elif c == 'i':
|
||||
q.put("ignition")
|
||||
elif c == 'q':
|
||||
q.put("quit")
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue