auto-detect pigeon or quectel (#25991)

* auto-detect pigeon or quectel

* persistent

* fix sim

* fix process replay

* fix locationd unit tests

* fix that

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: 01d05f66fe
taco
Adeeb Shihadeh 3 years ago committed by GitHub
parent 1c7fa1d700
commit 3e2f436d4c
  1. 1
      common/params.cc
  2. 4
      common/params.h
  3. 6
      common/params_pyx.pyx
  4. 2
      selfdrive/locationd/laikad.py
  5. 6
      selfdrive/locationd/locationd.cc
  6. 1
      selfdrive/locationd/test/test_locationd.py
  7. 9
      selfdrive/sensord/pigeond.py
  8. 1
      selfdrive/test/process_replay/process_replay.py
  9. 7
      tools/sim/bridge.py

@ -166,6 +166,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"TermsVersion", PERSISTENT},
{"Timezone", PERSISTENT},
{"TrainingVersion", PERSISTENT},
{"UbloxAvailable", PERSISTENT},
{"UpdateAvailable", CLEAR_ON_MANAGER_START},
{"UpdateFailedCount", CLEAR_ON_MANAGER_START},
{"UpdaterState", CLEAR_ON_MANAGER_START},

@ -29,8 +29,8 @@ public:
// helpers for reading values
std::string get(const std::string &key, bool block = false);
inline bool getBool(const std::string &key) {
return get(key) == "1";
inline bool getBool(const std::string &key, bool block = false) {
return get(key, block) == "1";
}
std::map<std::string, std::string> readAll();

@ -16,7 +16,7 @@ cdef extern from "common/params.h":
cdef cppclass c_Params "Params":
c_Params(string) nogil
string get(string, bool) nogil
bool getBool(string) nogil
bool getBool(string, bool) nogil
int remove(string) nogil
int put(string, string) nogil
int putBool(string, bool) nogil
@ -68,11 +68,11 @@ cdef class Params:
return val if encoding is None else val.decode(encoding)
def get_bool(self, key):
def get_bool(self, key, bool block=False):
cdef string k = self.check_key(key)
cdef bool r
with nogil:
r = self.p.getBool(k)
r = self.p.getBool(k, block)
return r
def put(self, key, dat):

@ -328,7 +328,7 @@ class EphemerisSourceType(IntEnum):
def main(sm=None, pm=None):
use_qcom = os.path.isfile("/persist/comma/use-quectel-rawgps")
use_qcom = not Params().get_bool("UbloxAvailable", block=True)
if use_qcom:
raw_gnss_socket = "qcomGnss"
else:

@ -492,10 +492,10 @@ void Localizer::determine_gps_mode(double current_time) {
int Localizer::locationd_thread() {
const char* gps_location_socket;
if (util::file_exists("/persist/comma/use-quectel-rawgps")) {
gps_location_socket = "gpsLocation";
} else {
if (Params().getBool("UbloxAvailable", true)) {
gps_location_socket = "gpsLocationExternal";
} else {
gps_location_socket = "gpsLocation";
}
const std::initializer_list<const char *> service_list = {gps_location_socket,
"cameraOdometry", "liveCalibration", "carState", "carParams",

@ -22,6 +22,7 @@ class TestLocationdProc(unittest.TestCase):
self.pm = messaging.PubMaster(self.LLD_MSGS)
Params().put_bool("UbloxAvailable", True)
managed_processes['locationd'].prepare()
managed_processes['locationd'].start()

@ -116,7 +116,7 @@ class TTYPigeon():
time.sleep(0.001)
def initialize_pigeon(pigeon: TTYPigeon) -> None:
def initialize_pigeon(pigeon: TTYPigeon) -> bool:
# try initializing a few times
for _ in range(10):
try:
@ -198,6 +198,10 @@ def initialize_pigeon(pigeon: TTYPigeon) -> None:
break
except TimeoutError:
cloudlog.warning("Initialization failed, trying again!")
else:
cloudlog.warning("Failed to initialize pigeon")
return False
return True
def deinitialize_and_exit(pigeon: Optional[TTYPigeon]):
cloudlog.warning("Storing almanac in ublox flash")
@ -236,7 +240,8 @@ def main():
time.sleep(0.5)
pigeon = TTYPigeon()
initialize_pigeon(pigeon)
r = initialize_pigeon(pigeon)
Params().put_bool("UbloxAvailable", r)
# start receiving data
while True:

@ -417,6 +417,7 @@ def setup_env(simulation=False, CP=None, cfg=None, controlsState=None):
params.put_bool("DisengageOnAccelerator", True)
params.put_bool("WideCameraOnly", False)
params.put_bool("DisableLogging", False)
params.put_bool("UbloxAvailable", True)
os.environ["NO_RADAR_SLEEP"] = "1"
os.environ["REPLAY"] = "1"

@ -244,11 +244,13 @@ class CarlaBridge:
def __init__(self, arguments):
set_params_enabled()
self.params = Params()
msg = messaging.new_message('liveCalibration')
msg.liveCalibration.validBlocks = 20
msg.liveCalibration.rpyCalib = [0.0, 0.0, 0.0]
Params().put("CalibrationParams", msg.to_bytes())
Params().put_bool("WideCameraOnly", not arguments.dual_camera)
self.params.put("CalibrationParams", msg.to_bytes())
self.params.put_bool("WideCameraOnly", not arguments.dual_camera)
self._args = arguments
self._carla_objects = []
@ -363,6 +365,7 @@ class CarlaBridge:
gps_bp = blueprint_library.find('sensor.other.gnss')
gps = world.spawn_actor(gps_bp, transform, attach_to=vehicle)
gps.listen(lambda gps: gps_callback(gps, vehicle_state))
self.params.put_bool("UbloxAvailable", True)
self._carla_objects.extend([imu, gps])
# launch fake car threads

Loading…
Cancel
Save