mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-07-08 06:22:03 +08:00
minor bug fixes in sim (#20286)
* order doensn't matter * order doensn't matter * minor fixes * minor fixes * not blocking ctrl-c * removing weather params * removing type ignore
This commit is contained in:
+18
-36
@@ -1,13 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
# type: ignore
|
||||
import carla # pylint: disable=import-error
|
||||
import time
|
||||
import math
|
||||
import atexit
|
||||
import numpy as np
|
||||
import threading
|
||||
import cereal.messaging as messaging
|
||||
import argparse
|
||||
import atexit
|
||||
import carla # pylint: disable=import-error
|
||||
import math
|
||||
import numpy as np
|
||||
import time
|
||||
import threading
|
||||
from typing import Any
|
||||
|
||||
import cereal.messaging as messaging
|
||||
from common.params import Params
|
||||
from common.realtime import Ratekeeper, DT_DMON
|
||||
from lib.can import can_function
|
||||
@@ -19,12 +20,6 @@ parser.add_argument('--joystick', action='store_true')
|
||||
parser.add_argument('--town', type=str, default='Town04')
|
||||
parser.add_argument('--spawn_point', dest='num_selected_spawn_point',
|
||||
type=int, default=16)
|
||||
parser.add_argument('--cloudiness', default=0.1, type=float)
|
||||
parser.add_argument('--precipitation', default=0.0, type=float)
|
||||
parser.add_argument('--precipitation_deposits', default=0.0, type=float)
|
||||
parser.add_argument('--wind_intensity', default=0.0, type=float)
|
||||
parser.add_argument('--sun_azimuth_angle', default=15.0, type=float)
|
||||
parser.add_argument('--sun_altitude_angle', default=75.0, type=float)
|
||||
args = parser.parse_args()
|
||||
|
||||
W, H = 1164, 874
|
||||
@@ -131,7 +126,7 @@ def can_function_runner(vs):
|
||||
i+=1
|
||||
|
||||
|
||||
def go(q):
|
||||
def bridge(q):
|
||||
|
||||
# setup CARLA
|
||||
client = carla.Client("127.0.0.1", 2000)
|
||||
@@ -170,15 +165,6 @@ def go(q):
|
||||
camera = world.spawn_actor(blueprint, transform, attach_to=vehicle)
|
||||
camera.listen(cam_callback)
|
||||
|
||||
world.set_weather(carla.WeatherParameters(
|
||||
cloudiness=args.cloudiness,
|
||||
precipitation=args.precipitation,
|
||||
precipitation_deposits=args.precipitation_deposits,
|
||||
wind_intensity=args.wind_intensity,
|
||||
sun_azimuth_angle=args.sun_azimuth_angle,
|
||||
sun_altitude_angle=args.sun_altitude_angle
|
||||
))
|
||||
|
||||
# reenable IMU
|
||||
imu_bp = blueprint_library.find('sensor.other.imu')
|
||||
imu = world.spawn_actor(imu_bp, transform, attach_to=vehicle)
|
||||
@@ -286,17 +272,6 @@ def go(q):
|
||||
steer_out = steer_rate_limit(old_steer, steer_out)
|
||||
old_steer = steer_out
|
||||
|
||||
# OP Exit conditions
|
||||
# if throttle_out > 0.3:
|
||||
# cruise_button = CruiseButtons.CANCEL
|
||||
# is_openpilot_engaged = False
|
||||
# if brake_out > 0.3:
|
||||
# cruise_button = CruiseButtons.CANCEL
|
||||
# is_openpilot_engaged = False
|
||||
# if steer_out > 0.3:
|
||||
# cruise_button = CruiseButtons.CANCEL
|
||||
# is_openpilot_engaged = False
|
||||
|
||||
else:
|
||||
if throttle_out==0 and old_throttle>0:
|
||||
if throttle_ease_out_counter>0:
|
||||
@@ -348,6 +323,13 @@ def go(q):
|
||||
|
||||
rk.keep_time()
|
||||
|
||||
def go(q: Any):
|
||||
while 1:
|
||||
try:
|
||||
bridge(q)
|
||||
except RuntimeError:
|
||||
print("Restarting bridge...")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# make sure params are in a good state
|
||||
set_params_enabled()
|
||||
@@ -357,7 +339,7 @@ if __name__ == "__main__":
|
||||
params.put("CalibrationParams", '{"calib_radians": [0,0,0], "valid_blocks": 20}')
|
||||
|
||||
from multiprocessing import Process, Queue
|
||||
q = Queue()
|
||||
q: Any = Queue()
|
||||
p = Process(target=go, args=(q,))
|
||||
p.daemon = True
|
||||
p.start()
|
||||
|
||||
@@ -2,7 +2,7 @@ import sys
|
||||
import termios
|
||||
import time
|
||||
from termios import (BRKINT, CS8, CSIZE, ECHO, ICANON, ICRNL, IEXTEN, INPCK,
|
||||
ISIG, ISTRIP, IXON, PARENB, VMIN, VTIME)
|
||||
ISTRIP, IXON, PARENB, VMIN, VTIME)
|
||||
from typing import Any
|
||||
|
||||
# Indexes for termios list.
|
||||
@@ -24,7 +24,7 @@ def getch():
|
||||
#mode[OFLAG] = mode[OFLAG] & ~(OPOST)
|
||||
mode[CFLAG] = mode[CFLAG] & ~(CSIZE | PARENB)
|
||||
mode[CFLAG] = mode[CFLAG] | CS8
|
||||
mode[LFLAG] = mode[LFLAG] & ~(ECHO | ICANON | IEXTEN | ISIG)
|
||||
mode[LFLAG] = mode[LFLAG] & ~(ECHO | ICANON | IEXTEN)
|
||||
mode[CC][VMIN] = 1
|
||||
mode[CC][VTIME] = 0
|
||||
termios.tcsetattr(fd, termios.TCSAFLUSH, mode)
|
||||
|
||||
Reference in New Issue
Block a user