提交 333b796e 编写于 作者: K kechxu 提交者: Jiangtao Hu

setup mlp evaluator for vehicle evaluator

上级 a4b7ec87
......@@ -48,7 +48,7 @@ class Evaluator {
virtual void Evaluate(Obstacle* obstacle) = 0;
protected:
std::vector<double> feature_values;
std::vector<double> feature_values_;
};
} // namespace prediction
......
......@@ -3,16 +3,17 @@ load("//tools:cpplint.bzl", "cpplint")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "vehicle_evaluator",
name = "mlp_evaluator",
hdrs = [
"vehicle_evaluator.h",
"mlp_evaluator.h",
],
srcs = [
"vehicle_evaluator.cc",
"mlp_evaluator.cc",
],
deps = [
"//modules/prediction/evaluator:evaluator",
"//modules/prediction/container/obstacles:obstacle",
"//modules/prediction/proto:lane_graph_proto",
],
)
......
......@@ -14,34 +14,60 @@
* limitations under the License.
*****************************************************************************/
#include <utility>
#include "modules/prediction/evaluator/vehicle/vehicle_evaluator.h"
#include "modules/prediction/evaluator/vehicle/mlp_evaluator.h"
namespace apollo {
namespace prediction {
VehicleEvaluator::VehicleEvaluator() : evaluator_(nullptr) {
Init();
MLPEvaluator::MLPEvaluator() {
}
void VehicleEvaluator::Init() {
CHECK(map_evaluators_.find("DefaultVehicleEvaluator") !=
map_evaluators_.end());
evaluator_ = map_evaluators_["DefaultVehicleEvaluator"].get();
MLPEvaluator::~MLPEvaluator() {
}
// TODO(kechxu) load user defined model taking over the default one
void MLPEvaluator::Evaluate(Obstacle* obstacle_ptr) {
Clear();
if (obstacle_ptr == nullptr) {
AERROR << "Invalid obstacle.";
return;
}
CHECK(evaluator_ != nullptr);
}
int id = obstacle_ptr->id();
Feature latest_feature = obstacle_ptr->latest_feature();
if (!latest_feature.IsInitialized()) {
ADEBUG << "Obstacle [" << id << "] has no latest feature.";
return;
}
Lane* lane_ptr = latest_feature.mutable_lane();
if (!latest_feature.has_lane() || lane_ptr == nullptr) {
ADEBUG << "Obstacle [" << id << "] has no lane feature.";
return;
}
LaneGraph* lane_graph_ptr = lane_ptr->mutable_lane_graph();
if (!latest_feature.lane().has_lane_graph() || lane_graph_ptr == nullptr) {
ADEBUG << "Obstacle [" << id << "] has no lane graph.";
return;
}
if (latest_feature.lane().lane_graph().lane_sequence_size() == 0) {
ADEBUG << "Obstacle [" << id << "] has no lane sequences.";
return;
}
void VehicleEvaluator::Evaluate(Obstacle* obstacle) {
evaluator_->Evaluate(obstacle);
for (int i = 0;
i < latest_feature.lane().lane_graph().lane_sequence_size(); ++i) {
LaneSequence* lane_sequence_ptr = lane_graph_ptr->mutable_lane_sequence(i);
CHECK(lane_sequence_ptr != nullptr);
ExtractFeatureValues(obstacle_ptr, lane_sequence_ptr);
}
}
void VehicleEvaluator::RegisterClass(const std::string& name,
std::unique_ptr<Evaluator> ptr) {
map_evaluators_[name] = std::move(ptr);
void MLPEvaluator::ExtractFeatureValues(Obstacle* obstacle_ptr,
LaneSequence* lane_sequence_ptr) {
feature_values_.clear();
// TODO(kechxu) implement insert feture values into feature_values_
}
} // namespace prediction
......
......@@ -14,45 +14,33 @@
* limitations under the License.
*****************************************************************************/
/**
* @file
* @brief Define the vehicle evaluator.
*/
#ifndef MODULES_PREDICTION_EVALUATOR_VEHICLE_MLP_EVALUATOR_H_
#define MODULES_PREDICTION_EVALUATOR_VEHICLE_MLP_EVALUATOR_H_
#ifndef MODULES_PREDICTION_EVALUATOR_VEHICLE_VEHICLE_EVALUATOR_H_
#define MODULES_PREDICTION_EVALUATOR_VEHICLE_VEHICLE_EVALUATOR_H_
#include <string>
#include <memory>
#include <unordered_map>
#include <vector>
#include "modules/prediction/evaluator/evaluator.h"
#include "modules/prediction/container/obstacles/obstacle.h"
#include "modules/prediction/proto/lane_graph.pb.h"
namespace apollo {
namespace prediction {
class VehicleEvaluator : public Evaluator {
class MLPEvaluator : public Evaluator {
public:
VehicleEvaluator();
virtual ~VehicleEvaluator();
MLPEvaluator();
void Evaluate(Obstacle* obstacle);
virtual ~MLPEvaluator();
void Clear();
void Evaluate(Obstacle* obstacle_ptr);
private:
void RegisterClass(const std::string& name, std::unique_ptr<Evaluator> ptr);
void ExtractFeatureValues(Obstacle* obstacle_ptr,
LaneSequence* lane_sequence_ptr);
void Init();
private:
Evaluator* evaluator_;
std::unordered_map<std::string, std::unique_ptr<Evaluator>> map_evaluators_;
void Clear();
};
} // namespace prediction
} // namespace apollo
#endif // MODULES_PREDICTION_EVALUATOR_VEHICLE_VEHICLE_EVALUATOR_H_
#endif // MODULES_PREDICTION_EVALUATOR_VEHICLE_MLP_EVALUATOR_H_
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册