mlp_evaluator_test.cc 2.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/******************************************************************************
 * 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/prediction/evaluator/vehicle/mlp_evaluator.h"

19
#include <string>
K
kechxu 已提交
20
#include <vector>
21

22 23
#include "gtest/gtest.h"

24
#include "modules/common/util/file.h"
25
#include "modules/prediction/common/prediction_gflags.h"
K
kechxu 已提交
26 27
#include "modules/prediction/container/obstacles/obstacle.h"
#include "modules/prediction/container/obstacles/obstacles_container.h"
28
#include "modules/perception/proto/perception_obstacle.pb.h"
29 30 31 32 33 34

namespace apollo {
namespace prediction {

class MLPEvaluatorTest : public ::testing::Test {
 public:
35
  void SetUp() override {
36
    std::string file =
37
      "modules/prediction/testdata/single_perception_vehicle_onlane.pb.txt";
38
    CHECK(apollo::common::util::GetProtoFromFile(file, &perception_obstacles_));
K
kechxu 已提交
39
    FLAGS_map_file = "modules/prediction/testdata/kml_map.bin";
40 41 42
  }
 protected:
  apollo::perception::PerceptionObstacles perception_obstacles_;
43 44
};

K
kechxu 已提交
45 46 47 48 49 50
TEST_F(MLPEvaluatorTest, OnLaneCase) {
  EXPECT_DOUBLE_EQ(perception_obstacles_.header().timestamp_sec(),
                   1501183430.161906);
  apollo::perception::PerceptionObstacle perception_obstacle =
      perception_obstacles_.perception_obstacle(0);
  EXPECT_EQ(perception_obstacle.id(), 1);
51
  MLPEvaluator mlp_evaluator;
K
kechxu 已提交
52 53 54 55 56 57 58
  ObstaclesContainer container;
  container.Insert(perception_obstacles_);
  Obstacle* obstacle_ptr = container.GetObstacle(1);
  EXPECT_TRUE(obstacle_ptr != nullptr);
  mlp_evaluator.Evaluate(obstacle_ptr);
  const std::vector<double> feature_values = mlp_evaluator.feature_values();
  EXPECT_EQ(feature_values.size(), 38);
59 60 61 62
}

}  // namespace prediction
}  // namespace apollo