From eae167e7dc2a9d1c38c6af40a20d939ac8a9759c Mon Sep 17 00:00:00 2001 From: xiaohuitu Date: Wed, 27 Dec 2017 21:17:25 +0800 Subject: [PATCH] perception: remove dummy fusion --- .../perception/obstacle/fusion/dummy/BUILD | 22 -------- .../obstacle/fusion/dummy/dummy_algorithms.cc | 27 --------- .../obstacle/fusion/dummy/dummy_algorithms.h | 55 ------------------- .../type_fuser/sequence_type_fuser/util.cc | 14 +++++ .../type_fuser/sequence_type_fuser/util.h | 7 +++ modules/perception/obstacle/onboard/BUILD | 1 - .../obstacle/onboard/obstacle_perception.cc | 2 - ...e_sequential_obstacle_perception_test.flag | 2 +- 8 files changed, 22 insertions(+), 108 deletions(-) delete mode 100644 modules/perception/obstacle/fusion/dummy/BUILD delete mode 100644 modules/perception/obstacle/fusion/dummy/dummy_algorithms.cc delete mode 100644 modules/perception/obstacle/fusion/dummy/dummy_algorithms.h diff --git a/modules/perception/obstacle/fusion/dummy/BUILD b/modules/perception/obstacle/fusion/dummy/BUILD deleted file mode 100644 index e365463025..0000000000 --- a/modules/perception/obstacle/fusion/dummy/BUILD +++ /dev/null @@ -1,22 +0,0 @@ -load("//tools:cpplint.bzl", "cpplint") - -package(default_visibility = ["//visibility:public"]) - -cc_library( - name = "perception_obstacle_fusion_dummy", - srcs = [ - "dummy_algorithms.cc", - ], - hdrs = [ - "dummy_algorithms.h", - ], - deps = [ - "//modules/common:log", - "//modules/perception/obstacle/common:perception_obstacle_common", - "//modules/perception/obstacle/fusion/interface:perception_obstacle_fusion_interface", - "@eigen//:eigen", - "@pcl//:pcl", - ], -) - -cpplint() diff --git a/modules/perception/obstacle/fusion/dummy/dummy_algorithms.cc b/modules/perception/obstacle/fusion/dummy/dummy_algorithms.cc deleted file mode 100644 index 5d88b4a982..0000000000 --- a/modules/perception/obstacle/fusion/dummy/dummy_algorithms.cc +++ /dev/null @@ -1,27 +0,0 @@ -/****************************************************************************** - * Copyright 2017 The Apollo Authors. All Rights Reserved. - * - * 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 "modules/perception/obstacle/fusion/dummy/dummy_algorithms.h" - -namespace apollo { -namespace perception { - -bool DummyFusion::Fuse(const std::vector &multi_sensor_objects, - std::vector *fused_objects) { - return result_detect_; -} - -} // namespace perception -} // namespace apollo diff --git a/modules/perception/obstacle/fusion/dummy/dummy_algorithms.h b/modules/perception/obstacle/fusion/dummy/dummy_algorithms.h deleted file mode 100644 index 5868328d22..0000000000 --- a/modules/perception/obstacle/fusion/dummy/dummy_algorithms.h +++ /dev/null @@ -1,55 +0,0 @@ -/****************************************************************************** - * Copyright 2017 The Apollo Authors. All Rights Reserved. - * - * 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. - *****************************************************************************/ -#ifndef MODULES_PERCEPTION_OBSTACLE_FUSION_DUMMY_DUMMY_ALGORITHMS_H_ -#define MODULES_PERCEPTION_OBSTACLE_FUSION_DUMMY_DUMMY_ALGORITHMS_H_ - -#include -#include - -#include "modules/perception/obstacle/fusion/interface/base_fusion.h" - -namespace apollo { -namespace perception { - -class DummyFusion : public BaseFusion { - public: - DummyFusion() : BaseFusion() {} - ~DummyFusion() = default; - - bool Init() override { - return result_init_; - } - - bool Fuse(const std::vector &multi_sensor_objects, - std::vector *fused_objects) override; - - std::string name() const override { - return "DummyFusion"; - } - - private: - // for unit test - bool result_init_ = true; - bool result_detect_ = true; - - DISALLOW_COPY_AND_ASSIGN(DummyFusion); -}; - -REGISTER_FUSION(DummyFusion); -} // namespace perception -} // namespace apollo - -#endif // MODULES_PERCEPTION_OBSTACLE_FUSION_DUMMY_DUMMY_ALGORITHMS_H_ diff --git a/modules/perception/obstacle/lidar/type_fuser/sequence_type_fuser/util.cc b/modules/perception/obstacle/lidar/type_fuser/sequence_type_fuser/util.cc index 42492a4d8c..fc48757ff4 100644 --- a/modules/perception/obstacle/lidar/type_fuser/sequence_type_fuser/util.cc +++ b/modules/perception/obstacle/lidar/type_fuser/sequence_type_fuser/util.cc @@ -68,6 +68,20 @@ void NormalizeRow(Matrixd* prob) { } } +void PrintProbability(const std::vector& prob, const std::string& name) { + std::cout << name << ": "; + float max_prob = -DBL_MAX; + std::size_t max_id = 0; + for (std::size_t i = 0; i < prob.size(); ++i) { + std::cout << std::setprecision(3) << prob[i] << " "; + if (prob[i] > max_prob) { + max_prob = prob[i]; + max_id = i; + } + } + std::cout << " max_type: " << max_id << std::endl; +} + bool LoadSingleMatrix(std::ifstream& fin, Matrixd* matrix) { for (std::size_t row = 0; row < VALID_OBJECT_TYPE; ++row) { for (std::size_t col = 0; col < VALID_OBJECT_TYPE; ++col) { diff --git a/modules/perception/obstacle/lidar/type_fuser/sequence_type_fuser/util.h b/modules/perception/obstacle/lidar/type_fuser/sequence_type_fuser/util.h index 584f4c6421..10d6d2f183 100644 --- a/modules/perception/obstacle/lidar/type_fuser/sequence_type_fuser/util.h +++ b/modules/perception/obstacle/lidar/type_fuser/sequence_type_fuser/util.h @@ -77,6 +77,13 @@ void Normalize(Vectord* prob); */ void NormalizeRow(Matrixd* prob); +/** + * @brief Print probability + * @param prob Probability to be printed + * @param name Name of probability to be printed +*/ +void PrintProbability(const std::vector& prob, const std::string& name); + /** * @brief Load a matrix from input file stream * @param fin The input file stream diff --git a/modules/perception/obstacle/onboard/BUILD b/modules/perception/obstacle/onboard/BUILD index 454245ccb3..b2cfe697d7 100644 --- a/modules/perception/obstacle/onboard/BUILD +++ b/modules/perception/obstacle/onboard/BUILD @@ -44,7 +44,6 @@ cc_library( "//modules/perception/obstacle/lidar/type_fuser/sequence_type_fuser:perception_obstacle_lidar_type_fuser_sequence_type_fuser", "//modules/perception/obstacle/lidar/visualizer/opengl_visualizer:perception_obstacle_lidar_opengl_visualizer", "//modules/perception/obstacle/radar/dummy:perception_obstacle_radar_dummy", - "//modules/perception/obstacle/fusion/dummy:perception_obstacle_fusion_dummy", "@eigen//:eigen", "@gtest//:gtest", "@ros//:ros_common", diff --git a/modules/perception/obstacle/onboard/obstacle_perception.cc b/modules/perception/obstacle/onboard/obstacle_perception.cc index ee65db0374..d7e6eef10f 100644 --- a/modules/perception/obstacle/onboard/obstacle_perception.cc +++ b/modules/perception/obstacle/onboard/obstacle_perception.cc @@ -23,7 +23,6 @@ #include "modules/perception/lib/base/timer.h" #include "modules/perception/obstacle/radar/dummy/dummy_algorithms.h" #include "modules/perception/obstacle/radar/modest/modest_radar_detector.h" -#include "modules/perception/obstacle/fusion/dummy/dummy_algorithms.h" #include "modules/perception/obstacle/fusion/probabilistic_fusion/probabilistic_fusion.h" DEFINE_string(obstacle_show_type, "fused", @@ -105,7 +104,6 @@ bool ObstaclePerception::Init() { void ObstaclePerception::RegistAllAlgorithm() { RegisterFactoryDummyRadarDetector(); - RegisterFactoryDummyFusion(); RegisterFactoryModestRadarDetector(); RegisterFactoryProbabilisticFusion(); diff --git a/modules/perception/tool/offline_visualizer_tool/conf/offline_sequential_obstacle_perception_test.flag b/modules/perception/tool/offline_visualizer_tool/conf/offline_sequential_obstacle_perception_test.flag index 6aa0bbd555..ed3a321ac4 100644 --- a/modules/perception/tool/offline_visualizer_tool/conf/offline_sequential_obstacle_perception_test.flag +++ b/modules/perception/tool/offline_visualizer_tool/conf/offline_sequential_obstacle_perception_test.flag @@ -22,7 +22,7 @@ # the fusion method for onboard # type: string -# candidate: DummyFusion, ProbabilisticFusion +# candidate: only ProbabilisticFusion --onboard_fusion=ProbabilisticFusion # enable visualization -- GitLab