提交 80911e8f 编写于 作者: K Kecheng Xu 提交者: Dong Li

add vehicle evaluator base class (#26)

上级 bed2f770
......@@ -31,7 +31,7 @@ cc_library(
name = "evaluator",
hdrs = ["evaluator.h"],
deps = [
"//modules/prediction/container/obstacles:obstacle"
]
)
......
......@@ -22,8 +22,8 @@
#ifndef MODULES_PREDICTION_EVALUATOR_EVALUATOR_H_
#define MODULES_PREDICTION_EVALUATOR_EVALUATOR_H_
#include <google/protobuf/message.h>
#include "google/protobuf/message.h"
#include "modules/prediction/container/obstacles/obstacle.h"
/**
* @namespace apollo::prediction
* @brief apollo::prediction
......@@ -42,6 +42,8 @@ class Evaluator {
* @brief Destructor
*/
virtual ~Evaluator() = default;
virtual void Evaluate(Obstacle* obstacle) = 0;
};
} // namespace prediction
......
load("//tools:cpplint.bzl", "cpplint")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "vehicle_evaluator",
hdrs = [
"vehicle_evaluator.h",
],
srcs = [
"vehicle_evaluator.cc",
],
deps = [
"//modules/prediction/evaluator:evaluator",
"//modules/prediction/container/obstacles:obstacle",
],
)
cpplint()
/******************************************************************************
* 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 <utility>
#include "modules/prediction/evaluator/vehicle/vehicle_evaluator.h"
namespace apollo {
namespace prediction {
VehicleEvaluator::VehicleEvaluator() : evaluator_(nullptr) {
Init();
}
void VehicleEvaluator::Init() {
CHECK(map_evaluators_.find("DefaultVehicleEvaluator") !=
map_evaluators_.end());
evaluator_ = map_evaluators_["DefaultVehicleEvaluator"].get();
// TODO(kechxu) load user defined model taking over the default one
CHECK(evaluator_ != nullptr);
}
void VehicleEvaluator::Evaluate(Obstacle* obstacle) {
evaluator_->Evaluate(obstacle);
}
void VehicleEvaluator::RegisterClass(const std::string& name,
std::unique_ptr<Evaluator> ptr) {
map_evaluators_[name] = std::move(ptr);
}
} // namespace prediction
} // namespace apollo
/******************************************************************************
* 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.
*****************************************************************************/
/**
* @file
* @brief Define the vehicle evaluator.
*/
#ifndef MODULES_PREDICTION_EVALUATOR_VEHICLE_VEHICLE_EVALUATOR_H_
#define MODULES_PREDICTION_EVALUATOR_VEHICLE_VEHICLE_EVALUATOR_H_
#include <string>
#include <memory>
#include <unordered_map>
#include "modules/prediction/evaluator/evaluator.h"
#include "modules/prediction/container/obstacles/obstacle.h"
namespace apollo {
namespace prediction {
class VehicleEvaluator : public Evaluator {
public:
VehicleEvaluator();
virtual ~VehicleEvaluator();
void Evaluate(Obstacle* obstacle);
void Clear();
private:
void RegisterClass(const std::string& name, std::unique_ptr<Evaluator> ptr);
void Init();
private:
Evaluator* evaluator_;
std::unordered_map<std::string, std::unique_ptr<Evaluator>> map_evaluators_;
};
} // namespace prediction
} // namespace apollo
#endif // MODULES_PREDICTION_EVALUATOR_VEHICLE_VEHICLE_EVALUATOR_H_
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册