提交 10333917 编写于 作者: K kechxu 提交者: Kecheng Xu

Prediction: initialize scenario submodule

上级 72f9e5c3
......@@ -16,6 +16,7 @@ cc_library(
"//modules/prediction/container",
"//modules/prediction/container/obstacles:obstacle",
"//modules/prediction/proto:prediction_proto",
"//modules/prediction/proto:submodule_messages_proto",
],
)
......
......@@ -438,8 +438,8 @@ bool ObstaclesContainer::IsMovable(
double ObstaclesContainer::timestamp() const { return timestamp_; }
PredictionObstacles ObstaclesContainer::GetPredictionObstacles() {
PredictionObstacles prediction_obstacles;
PredictionContainerMessage ObstaclesContainer::GetContainerMessage() {
PredictionContainerMessage container_message;
for (const auto& id_pair : curr_frame_id_mapping_) {
int id = id_pair.second;
Obstacle* obstacle_ptr = GetObstacle(id);
......@@ -449,11 +449,11 @@ PredictionObstacles ObstaclesContainer::GetPredictionObstacles() {
}
PredictionObstacle prediction_obstacle =
obstacle_ptr->GeneratePredictionObstacle();
prediction_obstacles.add_prediction_obstacle()->CopyFrom(
container_message.add_prediction_obstacle()->CopyFrom(
prediction_obstacle);
}
// TODO(kechxu) add other info into prediction_obstacles if needed
return prediction_obstacles;
return container_message;
}
} // namespace prediction
......
......@@ -30,6 +30,7 @@
#include "modules/prediction/container/container.h"
#include "modules/prediction/container/obstacles/obstacle.h"
#include "modules/prediction/proto/prediction_obstacle.pb.h"
#include "modules/prediction/proto/submodule_messages.pb.h"
namespace apollo {
namespace prediction {
......@@ -133,7 +134,7 @@ class ObstaclesContainer : public Container {
double timestamp() const;
PredictionObstacles GetPredictionObstacles();
PredictionContainerMessage GetContainerMessage();
private:
Obstacle* GetObstacleWithLRUUpdate(const int obstacle_id);
......
......@@ -212,3 +212,26 @@ proto_library(
"//modules/common/proto:geometry_proto_lib",
],
)
cc_proto_library(
name = "submodule_messages_proto",
deps = [
":submodule_messages_proto_lib",
],
)
proto_library(
name = "submodule_messages_proto_lib",
srcs = [
"submodule_messages.proto",
],
deps = [
"//modules/common/proto:error_code_proto_lib",
"//modules/common/proto:header_proto_lib",
"//modules/common/proto:pnc_point_proto_lib",
"//modules/perception/proto:perception_proto_lib",
"//modules/prediction/proto:feature_proto_lib",
"//modules/prediction/proto:scenario_proto_lib",
"//modules/prediction/proto:prediction_proto_lib",
],
)
syntax = "proto2";
package apollo.prediction;
import "modules/common/proto/header.proto";
import "modules/prediction/proto/prediction_obstacle.proto";
message PredictionContainerMessage {
// timestamp is included in header
optional apollo.common.Header header = 1;
// make prediction for multiple obstacles
repeated PredictionObstacle prediction_obstacle = 2;
// start timestamp
optional double start_timestamp = 3;
// end timestamp
optional double end_timestamp = 4;
}
......@@ -21,6 +21,7 @@ cc_library(
"//modules/prediction/common:prediction_gflags",
"//modules/prediction/container:container_manager",
"//modules/prediction/container/obstacles:obstacles_container",
"//modules/prediction/proto:submodule_messages_proto",
],
)
......@@ -31,4 +32,33 @@ cc_binary(
deps = [":container_submodule_lib"],
)
cc_library(
name = "scenario_submodule_lib",
srcs = ["scenario_submodule.cc"],
hdrs = [
"scenario_submodule.h",
],
copts = [
"-DMODULE_NAME=\\\"scenario_submodule\\\"",
],
deps = [
"//cyber",
"//modules/common/adapters:adapter_gflags",
"//modules/common/adapters/proto:adapter_config_proto",
"//modules/common/time",
"//modules/perception/proto:perception_proto",
"//modules/prediction/common:message_process",
"//modules/prediction/common:prediction_gflags",
"//modules/prediction/scenario:scenario_manager",
"//modules/prediction/proto:submodule_messages_proto",
],
)
cc_binary(
name = "scenario_submodule.so",
linkshared = True,
linkstatic = False,
deps = [":scenario_submodule_lib"],
)
cpplint()
......@@ -53,8 +53,8 @@ bool ContainerSubmodule::Init() {
FLAGS_localization_topic, nullptr);
// TODO(kechxu) change topic name when finalized
prediction_writer_ =
node_->CreateWriter<PredictionObstacles>(FLAGS_prediction_topic);
container_writer_ =
node_->CreateWriter<PredictionContainerMessage>(FLAGS_prediction_topic);
return true;
}
......@@ -66,7 +66,12 @@ bool ContainerSubmodule::Proc(
ContainerManager::Instance()->GetContainer<ObstaclesContainer>(
AdapterConfig::PERCEPTION_OBSTACLES);
CHECK_NOTNULL(obstacles_container_ptr);
// TODO(kechxu): implement the writer
PredictionContainerMessage container_message =
obstacles_container_ptr->GetContainerMessage();
container_writer_->Write(std::make_shared<PredictionContainerMessage>(
container_message));
return true;
}
......
......@@ -29,6 +29,7 @@
#include "modules/perception/proto/perception_obstacle.pb.h"
#include "modules/planning/proto/planning.pb.h"
#include "modules/prediction/proto/prediction_obstacle.pb.h"
#include "modules/prediction/proto/submodule_messages.pb.h"
/**
* @namespace apollo::prediction
......@@ -73,7 +74,7 @@ class ContainerSubmodule
std::shared_ptr<cyber::Reader<localization::LocalizationEstimate>>
localization_reader_;
std::shared_ptr<cyber::Writer<PredictionObstacles>> prediction_writer_;
std::shared_ptr<cyber::Writer<PredictionContainerMessage>> container_writer_;
};
CYBER_REGISTER_COMPONENT(ContainerSubmodule)
......
/******************************************************************************
* Copyright 2019 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/submodules/scenario_submodule.h"
namespace apollo {
namespace prediction {
bool ScenarioSubmodule::Init() {
// TODO(kechxu) implement
return true;
}
bool ScenarioSubmodule::Proc(
const std::shared_ptr<PredictionContainerMessage>& container_message) {
// TODO(kechxu) implement
return true;
}
} // namespace prediction
} // namespace apollo
/******************************************************************************
* Copyright 2019 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 Use scenario submodule to deal with scenario-related tasks
*/
#pragma once
#include <memory>
#include <string>
#include "cyber/component/component.h"
#include "modules/prediction/proto/submodule_messages.pb.h"
namespace apollo {
namespace prediction {
class ScenarioSubmodule : public cyber::Component<PredictionContainerMessage> {
public:
/**
* @brief Destructor
*/
~ScenarioSubmodule();
/**
* @brief Get name of the node
* @return Name of the node
*/
std::string Name() const;
/**
* @brief Initialize the node
* @return If initialized
*/
bool Init() override;
/**
* @brief Data callback upon receiving a prediction container message.
* @param Prediction container message.
*/
bool Proc(const std::shared_ptr<PredictionContainerMessage>&) override;
private:
// TODO(kechxu) define storytelling reader
// TODO(kechxu) define writer
};
CYBER_REGISTER_COMPONENT(ScenarioSubmodule)
} // namespace prediction
} // namespace apollo
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册