提交 1dc8f980 编写于 作者: C Calvin Miao

Added pose container and enable container factory in container manager

上级 6571e1d6
......@@ -5,7 +5,7 @@ cc_library(
srcs = ["container_manager.cc"],
hdrs = ["container_manager.h"],
deps = [
"//modules/prediction/container:container",
"//modules/prediction/container/obstacles:obstacles_container",
"//modules/common:macro",
"@glog//:glog"
]
......
......@@ -16,6 +16,8 @@
#include "modules/prediction/container/container_manager.h"
#include "modules/prediction/container/obstacles/obstacles_container.h"
namespace apollo {
namespace prediction {
......@@ -25,7 +27,9 @@ ContainerManager::~ContainerManager() {
containers_.clear();
}
void ContainerManager::RegisterContainer() {}
void ContainerManager::RegisterContainers() {
RegisterContainer("PerceptionObstacles");
}
Container* ContainerManager::mutable_container(const std::string& name) {
if (containers_.find(name) != containers_.end()) {
......@@ -35,5 +39,18 @@ Container* ContainerManager::mutable_container(const std::string& name) {
}
}
std::unique_ptr<Container> ContainerManager::CreateContainer(
const std::string& name) {
std::unique_ptr<Container> container_ptr(nullptr);
if (name == "PerceptionObstacles") {
container_ptr.reset(new ObstaclesContainer());
}
return container_ptr;
}
void ContainerManager::RegisterContainer(const std::string& name) {
containers_[name] = CreateContainer(name);
}
}
}
......@@ -23,6 +23,7 @@
#define MODULES_PREDICTION_CONTAINER_CONTAINER_MANAGER_H_
#include <unordered_map>
#include <string>
#include "modules/prediction/container/container.h"
#include "modules/common/macro.h"
......@@ -44,7 +45,7 @@ class ContainerManager {
/**
* @brief Register all containers
*/
void RegisterContainer();
void RegisterContainers();
/**
* @brief Get mutable container
......@@ -53,6 +54,11 @@ class ContainerManager {
*/
Container* mutable_container(const std::string& name);
private:
std::unique_ptr<Container> CreateContainer(const std::string& name);
void RegisterContainer(const std::string& name);
private:
std::unordered_map<std::string, std::unique_ptr<Container>> containers_;
......
......@@ -6,7 +6,6 @@ cc_library(
hdrs = ["obstacles_container.h"],
deps = [
"//modules/prediction/container:container",
"//modules/perception/proto:perception_proto"
]
)
......
......@@ -19,8 +19,7 @@
namespace apollo {
namespace prediction {
void ObstaclesContainer::Insert(
const ::apollo::perception::PerceptionObstacles& obstacles) {}
void ObstaclesContainer::Insert(const ::google::protobuf::Message& message) {}
}
}
......@@ -24,8 +24,6 @@
#include "modules/prediction/container/container.h"
#include "modules/perception/proto/perception_obstacle.pb.h"
namespace apollo {
namespace prediction {
......@@ -45,8 +43,7 @@ class ObstaclesContainer : public Container {
* @brief Insert a data message into the container
* @param Data message to be inserted in protobuf
*/
virtual void Insert(
const ::apollo::perception::PerceptionObstacles& obstacles);
virtual void Insert(const ::google::protobuf::Message& message) override;
};
} // namespace prediction
......
package(default_visibility = ["//visibility:public"])
cc_library(
name = "pose_container",
srcs = ["pose_container.cc"],
hdrs = ["pose_container.h"],
deps = [
"//modules/prediction/container:container",
]
)
\ No newline at end of file
/******************************************************************************
* 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/container/pose/pose_container.h"
namespace apollo {
namespace prediction {
void PoseContainer::Insert(const ::google::protobuf::Message& message) {}
}
}
/******************************************************************************
* 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 Obstacles container
*/
#ifndef MODULES_PREDICTION_CONTAINER_POSE_OBSTACLES_H_
#define MODULES_PREDICTION_CONTAINER_POSE_OBSTACLES_H_
#include "modules/prediction/container/container.h"
namespace apollo {
namespace prediction {
class PoseContainer : public Container {
public:
/**
* @brief Constructor
*/
explicit PoseContainer() = default;
/**
* @brief Destructor
*/
virtual ~PoseContainer() = default;
/**
* @brief Insert a data message into the container
* @param Data message to be inserted in protobuf
*/
virtual void Insert(const ::google::protobuf::Message& message) override;
};
} // namespace prediction
} // namespace apollo
#endif // MODULES_PREDICTION_CONTAINER_POSE_OBSTACLES_H_
......@@ -38,12 +38,14 @@ std::string Prediction::Name() const { return FLAGS_prediction_module_name; }
Status Prediction::Init() {
// Load prediction conf
conf_.Clear();
if (!::apollo::common::util::GetProtoFromFile(FLAGS_prediction_conf_file,
&conf_)) {
return OnError("Unable to load prediction conf file" +
FLAGS_prediction_conf_file);
}
// Initialize the adapters
AdapterManager::instance()->Init();
CHECK(AdapterManager::GetLocalization())
......@@ -52,6 +54,7 @@ Status Prediction::Init() {
CHECK(AdapterManager::GetPerceptionObstacles())
<< "Perception is not ready.";
// Set perception obstacle callback function
AdapterManager::SetPerceptionObstaclesCallback(&Prediction::OnPerception,
this);
return Status::OK();
......@@ -81,7 +84,7 @@ void Prediction::OnPerception(const PerceptionObstacles &perception_obstacles) {
ContainerManager::instance()->mutable_container("Obstacles")->Insert(perception_obstacles);
EvaluatorManager::instance()->Run(perception_obstacles);
PredictorManager::instance()->Run(perception_obstacles);
// AdapterManager::PublishPrediction(GeneratorManager::instance()->GetPredictions());
// AdapterManager::PublishPrediction(PredictorManager::instance()->GetPredictions());
}
Status Prediction::OnError(const std::string& error_msg) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册