示例#1
0
    def test_raises_error_when_seconds_negative(self) -> None:
        mock_samples = [{'token': '1', 'timestamp': 0, 'anns': ['1', '1b']}]
        nusc = MockNuScenes(self.mock_annotations, mock_samples)
        helper = PredictHelper(nusc)
        with self.assertRaises(ValueError):
            helper.get_future_for_agent('1', '1', -1, False)

        with self.assertRaises(ValueError):
            helper.get_past_for_agent('1', '1', -1, False)

        with self.assertRaises(ValueError):
            helper.get_past_for_sample('1', -1, False)

        with self.assertRaises(ValueError):
            helper.get_future_for_sample('1', -1, False)
示例#2
0
    def test_get_past_for_agent_in_frame(self) -> None:

        mock_samples = [{
            'token': '5',
            'timestamp': 0
        }, {
            'token': '4',
            'timestamp': -1e6
        }, {
            'token': '3',
            'timestamp': -2e6
        }, {
            'token': '2',
            'timestamp': -3e6
        }, {
            'token': '1',
            'timestamp': -4e6
        }]

        # Testing we can get the exact amount of past seconds available
        nusc = MockNuScenes(self.mock_annotations, mock_samples)
        helper = PredictHelper(nusc)
        past = helper.get_past_for_agent('1', '5', 3, True)
        np.testing.assert_allclose(past,
                                   np.array([[1., -1.], [2., -2.], [3., -3.]]))
示例#3
0
    def test_get_past_for_last_returns_nothing(self) -> None:
        mock_samples = [{'token': '1', 'timestamp': 0}]

        # Testing we get nothing if we're at the last annotation
        nusc = MockNuScenes(self.mock_annotations, mock_samples)
        helper = PredictHelper(nusc)
        past = helper.get_past_for_agent('1', '1', 3, False)
        np.testing.assert_equal(past, np.array([]))
示例#4
0
    def test_get_no_data_when_seconds_0(self):
        mock_samples = [{'token': '1', 'timestamp': 0, 'anns': ['1']}]
        nusc = MockNuScenes(self.mock_annotations, mock_samples)
        helper = PredictHelper(nusc)

        np.testing.assert_equal(helper.get_future_for_agent('1', '1', 0, False), np.array([]))
        np.testing.assert_equal(helper.get_past_for_agent('1', '1', 0, False), np.array([]))
        np.testing.assert_equal(helper.get_future_for_sample('1', 0, False), np.array([]))
        np.testing.assert_equal(helper.get_past_for_sample('1', 0, False), np.array([]))
示例#5
0
    def test_get_past_for_agent_no_data_to_get(self,):
        mock_samples = [{'token': '5', 'timestamp': 0},
                        {'token': '4', 'timestamp': -3.5e6}]

        # Testing we get nothing if the first sample annotation is past our threshold
        nusc = MockNuScenes(self.mock_annotations, mock_samples)
        helper = PredictHelper(nusc)
        past = helper.get_past_for_agent('1', '5', 3, False)
        np.testing.assert_equal(past, np.array([]))
示例#6
0
    def test_get_past_for_agent_within_buffer(self,):

        mock_samples = [{'token': '5', 'timestamp': 0},
                        {'token': '4', 'timestamp': -1e6},
                        {'token': '3', 'timestamp': -3.05e6},
                        {'token': '2', 'timestamp': -3.2e6}]

        # Testing we get data if it is after future seconds but within buffer
        nusc = MockNuScenes(self.mock_annotations, mock_samples)
        helper = PredictHelper(nusc)
        past = helper.get_past_for_agent('1', '5', 3, False)
        np.testing.assert_equal(past, np.array([[3, 3], [2, 2]]))
示例#7
0
    def test_get_past_for_agent_less_amount(self,):

        mock_samples = [{'token': '5', 'timestamp': 0},
                        {'token': '4', 'timestamp': -1e6},
                        {'token': '3', 'timestamp': -2.6e6},
                        {'token': '2', 'timestamp': -4e6},
                        {'token': '1', 'timestamp': -5.5e6}]

        # Testing we do not include data after the past seconds
        nusc = MockNuScenes(self.mock_annotations, mock_samples)
        helper = PredictHelper(nusc)
        past = helper.get_past_for_agent('1', '5', 3, False)
        np.testing.assert_equal(past, np.array([[3, 3], [2, 2]]))
示例#8
0
    def test_get_past_for_agent_exact_amount(self,):

        mock_samples = [{'token': '5', 'timestamp': 0},
                        {'token': '4', 'timestamp': -1e6},
                        {'token': '3', 'timestamp': -2e6},
                        {'token': '2', 'timestamp': -3e6},
                        {'token': '1', 'timestamp': -4e6}]

        # Testing we can get the exact amount of past seconds available
        nusc = MockNuScenes(self.mock_annotations, mock_samples)
        helper = PredictHelper(nusc)
        past = helper.get_past_for_agent('1', '5', 3, False)
        np.testing.assert_equal(past, np.array([[3, 3], [2, 2], [1, 1]]))