-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from ucla-mobility/feature/unitest_kf_ekf
Feature/unitest kf ekf
- Loading branch information
Showing
14 changed files
with
346 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
matplotlib==3.4.2 | ||
networkx==2.5.1 | ||
numpy | ||
pillow==8.2.0 | ||
pyparsing==2.4.7 | ||
six==1.16.0 | ||
open3d | ||
opencv-python==4.5.2.52 | ||
pandas | ||
pygame | ||
scikit-learn==0.24.2 | ||
scipy==1.6.3 | ||
seaborn | ||
--find-links https://download.pytorch.org/whl/torch_stable.html | ||
torch==1.9.0+cpu | ||
torchvision==0.10.0+cpu | ||
tqdm>=4.41.0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Unit test for | ||
""" | ||
# Author: Runsheng Xu <rxx3386@ucla.edu> | ||
# License: MIT | ||
|
||
import os | ||
import sys | ||
import unittest | ||
|
||
import numpy as np | ||
|
||
# temporary solution for relative imports in case opencda is not installed | ||
# if opencda is installed, no need to use the following line | ||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | ||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '.'))) | ||
|
||
import mocked_carla as mcarla | ||
|
||
from opencda.core.plan.drive_profile_plotting import * | ||
|
||
|
||
class TestDriveProfile(unittest.TestCase): | ||
def setUp(self): | ||
self.mock_list = [[23, 25, 25, 44, 66], [44, 55, 25, 22, 33]] | ||
|
||
def test_sub_plot(self): | ||
assert draw_sub_plot(self.mock_list, self.mock_list, self.mock_list, self.mock_list, self.mock_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Unit test for Extented Kalman Filter. | ||
""" | ||
# Author: Runsheng Xu <rxx3386@ucla.edu> | ||
# License: MIT | ||
|
||
import os | ||
import sys | ||
import unittest | ||
|
||
import numpy as np | ||
|
||
# temporary solution for relative imports in case opencda is not installed | ||
# if opencda is installed, no need to use the following line | ||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | ||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '.'))) | ||
|
||
import mocked_carla as mcarla | ||
from opencda.core.sensing.localization.extented_kalman_filter import ExtentedKalmanFilter | ||
|
||
|
||
class testKalmanFilter(unittest.TestCase): | ||
def setUp(self): | ||
self.dt = 0.25 | ||
self.kf = ExtentedKalmanFilter(self.dt) | ||
self.kf.run_step_init(10, 10, 90, 20) | ||
|
||
def test_parameters(self): | ||
assert (hasattr(self.kf, 'Q') and | ||
self.kf.Q.shape == (4, 4)) | ||
assert (hasattr(self.kf, 'R') and | ||
self.kf.R.shape == (3, 3)) | ||
assert (hasattr(self.kf, 'time_step') and | ||
self.kf.time_step == self.dt) | ||
assert (hasattr(self.kf, 'xEst') and | ||
self.kf.xEst.shape == (4, 1)) | ||
assert (hasattr(self.kf, 'PEst') and | ||
self.kf.PEst.shape == (4, 4)) | ||
|
||
def test_run_step(self): | ||
assert isinstance(self.kf.run_step(10, 10, 10, 10, 3)[0], float) | ||
assert isinstance(self.kf.run_step(10, 10, 10, 10, 3)[1], float) | ||
assert isinstance(self.kf.run_step(10, 10, 10, 10, 3)[2], float) | ||
assert isinstance(self.kf.run_step(10, 10, 10, 10, 3)[3], float) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Unit test for Kalman Filter | ||
""" | ||
# Author: Runsheng Xu <rxx3386@ucla.edu> | ||
# License: MIT | ||
|
||
import os | ||
import sys | ||
import unittest | ||
|
||
import numpy as np | ||
|
||
# temporary solution for relative imports in case opencda is not installed | ||
# if opencda is installed, no need to use the following line | ||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | ||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '.'))) | ||
|
||
import mocked_carla as mcarla | ||
from opencda.core.sensing.localization.kalman_filter import KalmanFilter | ||
from opencda.core.sensing.localization.coordinate_transform import geo_to_transform | ||
|
||
|
||
class testKalmanFilter(unittest.TestCase): | ||
def setUp(self): | ||
self.dt = 0.25 | ||
self.kf = KalmanFilter(self.dt) | ||
self.kf.run_step_init(10, 10, 90, 20) | ||
|
||
def test_parameters(self): | ||
assert (hasattr(self.kf, 'Q') and | ||
self.kf.Q.shape == (4, 4)) | ||
assert (hasattr(self.kf, 'R') and | ||
self.kf.R.shape == (3, 3)) | ||
assert (hasattr(self.kf, 'time_step') and | ||
self.kf.time_step == self.dt) | ||
assert (hasattr(self.kf, 'xEst') and | ||
self.kf.xEst.shape == (4, 1)) | ||
assert (hasattr(self.kf, 'PEst') and | ||
self.kf.PEst.shape == (4, 4)) | ||
|
||
def test_run_step(self): | ||
assert isinstance(self.kf.run_step(10, 10, 10, 10, 3)[0], float) | ||
assert isinstance(self.kf.run_step(10, 10, 10, 10, 3)[1], float) | ||
assert isinstance(self.kf.run_step(10, 10, 10, 10, 3)[2], float) | ||
assert isinstance(self.kf.run_step(10, 10, 10, 10, 3)[3], float) | ||
|
||
def test_geo_to_transform(self): | ||
assert isinstance(geo_to_transform(100, 70, 10, 10, 10, 10)[0], float) | ||
assert isinstance(geo_to_transform(100, 70, 10, 10, 10, 10)[1], float) | ||
assert isinstance(geo_to_transform(100, 70, 10.0, 10, 10, 10.0)[2], float) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Unit test for Localization DebugHelper. | ||
""" | ||
# Author: Runsheng Xu <rxx3386@ucla.edu> | ||
# License: MIT | ||
|
||
import os | ||
import sys | ||
import unittest | ||
|
||
import numpy as np | ||
|
||
# temporary solution for relative imports in case opencda is not installed | ||
# if opencda is installed, no need to use the following line | ||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | ||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '.'))) | ||
|
||
import mocked_carla as mcarla | ||
from opencda.core.sensing.localization.localization_debug_helper import LocDebugHelper | ||
|
||
|
||
class TestLocDebugHelper(unittest.TestCase): | ||
def setUp(self): | ||
config_yaml = {'show_animation': True, | ||
'x_scale': 10.0, | ||
'y_scale': 10.0} | ||
self.actor_id = 10 | ||
self.debug_heloer = LocDebugHelper(config_yaml=config_yaml, actor_id=self.actor_id) | ||
|
||
def test_parameters(self): | ||
assert isinstance(self.debug_heloer.show_animation, bool) | ||
assert isinstance(self.debug_heloer.x_scale, float) | ||
assert isinstance(self.debug_heloer.y_scale, float) | ||
|
||
assert isinstance(self.debug_heloer.gnss_x, list) | ||
assert isinstance(self.debug_heloer.gnss_y, list) | ||
assert isinstance(self.debug_heloer.gnss_yaw, list) | ||
assert isinstance(self.debug_heloer.gnss_spd, list) | ||
|
||
assert isinstance(self.debug_heloer.filter_x, list) | ||
assert isinstance(self.debug_heloer.filter_y, list) | ||
assert isinstance(self.debug_heloer.filter_yaw, list) | ||
assert isinstance(self.debug_heloer.filter_spd, list) | ||
|
||
assert isinstance(self.debug_heloer.gt_x, list) | ||
assert isinstance(self.debug_heloer.gt_y, list) | ||
assert isinstance(self.debug_heloer.gt_yaw, list) | ||
assert isinstance(self.debug_heloer.gt_spd, list) | ||
|
||
assert self.debug_heloer.hxEst.shape == (2, 1) | ||
assert self.debug_heloer.hTrue.shape == (2, 1) | ||
assert self.debug_heloer.hz.shape == (2, 1) | ||
|
||
assert self.debug_heloer.actor_id == self.actor_id | ||
|
||
def test_run_step(self): | ||
self.debug_heloer.run_step(10.0, 10.0, 10.0, 20.0, | ||
10.4, 10.4, 10.4, 20.4, | ||
10.3, 10.3, 10.3, 20.3) | ||
|
||
assert len(self.debug_heloer.gnss_x) == 1 | ||
assert len(self.debug_heloer.filter_x) == 1 | ||
assert len(self.debug_heloer.gt_x) == 1 | ||
assert self.debug_heloer.hTrue.shape[1] == 2 | ||
assert self.debug_heloer.hxEst.shape[1] == 2 | ||
assert self.debug_heloer.hz.shape[1] == 2 | ||
|
||
def test_evaluate(self): | ||
self.debug_heloer.run_step(10.0, 10.0, 10.0, 20.0, | ||
10.4, 10.4, 10.4, 20.4, | ||
10.3, 10.3, 10.3, 20.3) | ||
assert self.debug_heloer.evaluate()[0] | ||
assert isinstance(self.debug_heloer.evaluate()[1], str) | ||
|
Oops, something went wrong.