|
|
@ -8,13 +8,14 @@ import capnp |
|
|
|
import cereal.messaging as messaging |
|
|
|
import cereal.messaging as messaging |
|
|
|
from cereal.services import service_list |
|
|
|
from cereal.services import service_list |
|
|
|
from common.params import Params |
|
|
|
from common.params import Params |
|
|
|
|
|
|
|
from common.transformations.coordinates import ecef2geodetic |
|
|
|
|
|
|
|
|
|
|
|
from selfdrive.manager.process_config import managed_processes |
|
|
|
from selfdrive.manager.process_config import managed_processes |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestLocationdProc(unittest.TestCase): |
|
|
|
class TestLocationdProc(unittest.TestCase): |
|
|
|
MAX_WAITS = 1000 |
|
|
|
MAX_WAITS = 1000 |
|
|
|
LLD_MSGS = ['gpsLocationExternal', 'cameraOdometry', 'carState', 'liveCalibration', |
|
|
|
LLD_MSGS = ['gnssMeasurements', 'cameraOdometry', 'carState', 'liveCalibration', |
|
|
|
'accelerometer', 'gyroscope', 'magnetometer'] |
|
|
|
'accelerometer', 'gyroscope', 'magnetometer'] |
|
|
|
|
|
|
|
|
|
|
|
def setUp(self): |
|
|
|
def setUp(self): |
|
|
@ -45,16 +46,14 @@ class TestLocationdProc(unittest.TestCase): |
|
|
|
except capnp.lib.capnp.KjException: |
|
|
|
except capnp.lib.capnp.KjException: |
|
|
|
msg = messaging.new_message(name, 0) |
|
|
|
msg = messaging.new_message(name, 0) |
|
|
|
|
|
|
|
|
|
|
|
if name == "gpsLocationExternal": |
|
|
|
if name == "gnssMeasurements": |
|
|
|
msg.gpsLocationExternal.flags = 1 |
|
|
|
msg.gnssMeasurements.measTime = t |
|
|
|
msg.gpsLocationExternal.verticalAccuracy = 1.0 |
|
|
|
msg.gnssMeasurements.positionECEF.value = [self.x , self.y, self.z] |
|
|
|
msg.gpsLocationExternal.speedAccuracy = 1.0 |
|
|
|
msg.gnssMeasurements.positionECEF.std = [0,0,0] |
|
|
|
msg.gpsLocationExternal.bearingAccuracyDeg = 1.0 |
|
|
|
msg.gnssMeasurements.positionECEF.valid = True |
|
|
|
msg.gpsLocationExternal.vNED = [0.0, 0.0, 0.0] |
|
|
|
msg.gnssMeasurements.velocityECEF.value = [] |
|
|
|
msg.gpsLocationExternal.latitude = self.lat |
|
|
|
msg.gnssMeasurements.velocityECEF.std = [0,0,0] |
|
|
|
msg.gpsLocationExternal.longitude = self.lon |
|
|
|
msg.gnssMeasurements.velocityECEF.valid = True |
|
|
|
msg.gpsLocationExternal.unixTimestampMillis = t * 1e6 |
|
|
|
|
|
|
|
msg.gpsLocationExternal.altitude = self.alt |
|
|
|
|
|
|
|
elif name == 'cameraOdometry': |
|
|
|
elif name == 'cameraOdometry': |
|
|
|
msg.cameraOdometry.rot = [0.0, 0.0, 0.0] |
|
|
|
msg.cameraOdometry.rot = [0.0, 0.0, 0.0] |
|
|
|
msg.cameraOdometry.rotStd = [0.0, 0.0, 0.0] |
|
|
|
msg.cameraOdometry.rotStd = [0.0, 0.0, 0.0] |
|
|
@ -67,9 +66,11 @@ class TestLocationdProc(unittest.TestCase): |
|
|
|
# first reset params |
|
|
|
# first reset params |
|
|
|
Params().remove('LastGPSPosition') |
|
|
|
Params().remove('LastGPSPosition') |
|
|
|
|
|
|
|
|
|
|
|
self.lat = 30 + (random.random() * 10.0) |
|
|
|
self.x = -2710700 + (random.random() * 1e5) |
|
|
|
self.lon = -70 + (random.random() * 10.0) |
|
|
|
self.y = -4280600 + (random.random() * 1e5) |
|
|
|
self.alt = 5 + (random.random() * 10.0) |
|
|
|
self.z = 3850300 + (random.random() * 1e5) |
|
|
|
|
|
|
|
self.lat, self.lon, self.alt = ecef2geodetic([self.x, self.y, self.z]) |
|
|
|
|
|
|
|
|
|
|
|
self.fake_duration = 90 # secs |
|
|
|
self.fake_duration = 90 # secs |
|
|
|
# get fake messages at the correct frequency, listed in services.py |
|
|
|
# get fake messages at the correct frequency, listed in services.py |
|
|
|
fake_msgs = [] |
|
|
|
fake_msgs = [] |
|
|
@ -83,10 +84,9 @@ class TestLocationdProc(unittest.TestCase): |
|
|
|
time.sleep(1) # wait for async params write |
|
|
|
time.sleep(1) # wait for async params write |
|
|
|
|
|
|
|
|
|
|
|
lastGPS = json.loads(Params().get('LastGPSPosition')) |
|
|
|
lastGPS = json.loads(Params().get('LastGPSPosition')) |
|
|
|
|
|
|
|
self.assertAlmostEqual(lastGPS['latitude'], self.lat, places=4) |
|
|
|
self.assertAlmostEqual(lastGPS['latitude'], self.lat, places=3) |
|
|
|
self.assertAlmostEqual(lastGPS['longitude'], self.lon, places=4) |
|
|
|
self.assertAlmostEqual(lastGPS['longitude'], self.lon, places=3) |
|
|
|
self.assertAlmostEqual(lastGPS['altitude'], self.alt, places=4) |
|
|
|
self.assertAlmostEqual(lastGPS['altitude'], self.alt, places=3) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
if __name__ == "__main__": |
|
|
|