-
Notifications
You must be signed in to change notification settings - Fork 673
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: yoshiri <yoshiyoshidetteiu@gmail.com>
- Loading branch information
Showing
3 changed files
with
85 additions
and
2 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
75 changes: 75 additions & 0 deletions
75
perception/probabilistic_occupancy_grid_map/test/fusion_policy_test.cpp
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 @@ | ||
// Copyright 2023 TIER IV, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "cost_value.hpp" | ||
#include "fusion/single_frame_fusion_policy.hpp" | ||
#include "gtest/gtest.h" | ||
|
||
// Test the log-odds update rule | ||
TEST(FusionPolicyTest, TestLogOddsUpdateRule) | ||
{ | ||
using fusion_policy::log_odds_fusion::logOddsFusion; | ||
const double MARGIN = 0.03; | ||
const double OCCUPIED = 1.0 - MARGIN; | ||
const double FREE = 0.0 + MARGIN; | ||
const double UNKNOWN = 0.5; | ||
const double EPSILON = 1e-3; | ||
|
||
// same case | ||
std::vector<double> case1_1 = {OCCUPIED, OCCUPIED}; | ||
std::vector<double> case1_2 = {FREE, FREE}; | ||
std::vector<double> case1_3 = {UNKNOWN, UNKNOWN}; | ||
EXPECT_GE(logOddsFusion(case1_1), OCCUPIED); | ||
EXPECT_LE(logOddsFusion(case1_2), FREE); | ||
EXPECT_NEAR(logOddsFusion(case1_3), UNKNOWN, EPSILON); | ||
|
||
// with unknown | ||
std::vector<double> case2_1 = {OCCUPIED, UNKNOWN}; | ||
std::vector<double> case2_2 = {FREE, UNKNOWN}; | ||
EXPECT_NEAR(logOddsFusion(case2_1), OCCUPIED, EPSILON); | ||
EXPECT_NEAR(logOddsFusion(case2_2), FREE, EPSILON); | ||
|
||
// with conflict | ||
std::vector<double> case3_1 = {OCCUPIED, FREE}; | ||
EXPECT_NEAR(logOddsFusion(case3_1), UNKNOWN, EPSILON); | ||
} | ||
|
||
// Test the dempster-shafer update rule | ||
TEST(FusionPolicyTest, TestDempsterShaferUpdateRule) | ||
{ | ||
using fusion_policy::dempster_shafer_fusion::dempsterShaferFusion; | ||
const double MARGIN = 0.03; | ||
const double OCCUPIED = 1.0 - MARGIN; | ||
const double FREE = 0.0 + MARGIN; | ||
const double UNKNOWN = 0.5; | ||
const double EPSILON = 1e-3; | ||
|
||
// same case | ||
std::vector<double> case1_1 = {OCCUPIED, OCCUPIED}; | ||
std::vector<double> case1_2 = {FREE, FREE}; | ||
std::vector<double> case1_3 = {UNKNOWN, UNKNOWN}; | ||
EXPECT_GE(dempsterShaferFusion(case1_1), OCCUPIED); | ||
EXPECT_LE(dempsterShaferFusion(case1_2), FREE); | ||
EXPECT_NEAR(dempsterShaferFusion(case1_3), UNKNOWN, EPSILON); | ||
|
||
// with unknown | ||
std::vector<double> case2_1 = {OCCUPIED, UNKNOWN}; | ||
std::vector<double> case2_2 = {FREE, UNKNOWN}; | ||
EXPECT_NEAR(dempsterShaferFusion(case2_1), OCCUPIED, EPSILON); | ||
EXPECT_NEAR(dempsterShaferFusion(case2_2), FREE, EPSILON); | ||
|
||
// with conflict | ||
std::vector<double> case3_1 = {OCCUPIED, FREE}; | ||
EXPECT_NEAR(dempsterShaferFusion(case3_1), UNKNOWN, EPSILON); | ||
} |