提交 4e7c6c0b 编写于 作者: J jmtao 提交者: Yifei Jiang

planning: update learning data proto to align with the layout better

上级 ac7a7aa5
...@@ -41,18 +41,19 @@ bool FeatureOutput::Ready() { ...@@ -41,18 +41,19 @@ bool FeatureOutput::Ready() {
void FeatureOutput::InsertLearningDataFrame( void FeatureOutput::InsertLearningDataFrame(
const std::string& record_file, const std::string& record_file,
const LearningDataFrame& learning_data_frame) { const LearningDataFrame& learning_data_frame) {
learning_data_.add_learning_data()->CopyFrom(learning_data_frame); learning_data_.add_learning_data_frame()->CopyFrom(learning_data_frame);
// write frames into a file // write frames into a file
if (learning_data_.learning_data_size() >= if (learning_data_.learning_data_frame_size() >=
FLAGS_learning_data_frame_num_per_file) { FLAGS_learning_data_frame_num_per_file) {
WriteLearningData(record_file); WriteLearningData(record_file);
} }
} }
LearningDataFrame* FeatureOutput::GetLatestLearningDataFrame() { LearningDataFrame* FeatureOutput::GetLatestLearningDataFrame() {
const int size = learning_data_.learning_data_size(); const int size = learning_data_.learning_data_frame_size();
return size > 0 ? learning_data_.mutable_learning_data(size - 1) : nullptr; return size > 0 ? learning_data_.mutable_learning_data_frame(size - 1)
: nullptr;
} }
void FeatureOutput::InsertPlanningResult() {} void FeatureOutput::InsertPlanningResult() {}
...@@ -72,7 +73,7 @@ void FeatureOutput::WriteLearningData(const std::string& record_file) { ...@@ -72,7 +73,7 @@ void FeatureOutput::WriteLearningData(const std::string& record_file) {
void FeatureOutput::WriteRemainderiLearningData( void FeatureOutput::WriteRemainderiLearningData(
const std::string& record_file) { const std::string& record_file) {
if (learning_data_.learning_data_size() > 0) { if (learning_data_.learning_data_frame_size() > 0) {
WriteLearningData(record_file); WriteLearningData(record_file);
} }
} }
......
...@@ -27,16 +27,17 @@ void LearningBasedData::Clear() { ...@@ -27,16 +27,17 @@ void LearningBasedData::Clear() {
void LearningBasedData::InsertLearningDataFrame( void LearningBasedData::InsertLearningDataFrame(
const LearningDataFrame& learning_data_frame) { const LearningDataFrame& learning_data_frame) {
learning_data_.add_learning_data()->CopyFrom(learning_data_frame); learning_data_.add_learning_data_frame()->CopyFrom(learning_data_frame);
while (learning_data_.learning_data_size() > 10) { while (learning_data_.learning_data_frame_size() > 10) {
learning_data_.mutable_learning_data()->DeleteSubrange(0, 1); learning_data_.mutable_learning_data_frame()->DeleteSubrange(0, 1);
} }
} }
LearningDataFrame* LearningBasedData::GetLatestLearningDataFrame() { LearningDataFrame* LearningBasedData::GetLatestLearningDataFrame() {
const int size = learning_data_.learning_data_size(); const int size = learning_data_.learning_data_frame_size();
return size > 0 ? learning_data_.mutable_learning_data(size - 1) : nullptr; return size > 0 ? learning_data_.mutable_learning_data_frame(size - 1)
: nullptr;
} }
} // namespace planning } // namespace planning
......
...@@ -54,8 +54,8 @@ void Evaluator::Evaluate(const std::string& source_file) { ...@@ -54,8 +54,8 @@ void Evaluator::Evaluate(const std::string& source_file) {
cyber::common::GetProtoFromFile(source_file, &learning_data_); cyber::common::GetProtoFromFile(source_file, &learning_data_);
for (int i = 0; i < learning_data_.learning_data_size(); ++i) { for (int i = 0; i < learning_data_.learning_data_frame_size(); ++i) {
auto learning_data_frame = learning_data_.mutable_learning_data(i); auto learning_data_frame = learning_data_.mutable_learning_data_frame(i);
if (learning_data_frame->adc_trajectory_point_size() <= 0) { if (learning_data_frame->adc_trajectory_point_size() <= 0) {
continue; continue;
} }
...@@ -72,14 +72,15 @@ void Evaluator::Evaluate(const std::string& source_file) { ...@@ -72,14 +72,15 @@ void Evaluator::Evaluate(const std::string& source_file) {
// evaluate adc future trajectory // evaluate adc future trajectory
std::vector<TrajectoryPointFeature> adc_future_trajectory; std::vector<TrajectoryPointFeature> adc_future_trajectory;
for (const auto& tp : learning_data_.learning_data(i) for (const auto& tp : learning_data_.learning_data_frame(i)
.output() .output()
.adc_future_trajectory_point()) { .adc_future_trajectory_point()) {
adc_future_trajectory.push_back(tp); adc_future_trajectory.push_back(tp);
} }
std::vector<TrajectoryPointFeature> evaluated_adc_future_trajectory; std::vector<TrajectoryPointFeature> evaluated_adc_future_trajectory;
trajectory_evaluator_.EvaluateADCFutureTrajectory( trajectory_evaluator_.EvaluateADCFutureTrajectory(
learning_data_.learning_data(i).frame_num(), adc_future_trajectory, learning_data_.learning_data_frame(i).frame_num(),
adc_future_trajectory,
start_point_timestamp_sec, FLAGS_trajectory_delta_t, start_point_timestamp_sec, FLAGS_trajectory_delta_t,
&evaluated_adc_future_trajectory); &evaluated_adc_future_trajectory);
learning_data_frame->mutable_output()->clear_adc_future_trajectory_point(); learning_data_frame->mutable_output()->clear_adc_future_trajectory_point();
......
...@@ -175,7 +175,7 @@ bool PlanningComponent::Proc( ...@@ -175,7 +175,7 @@ bool PlanningComponent::Proc(
injector_->learning_based_data()->GetLatestLearningDataFrame(); injector_->learning_based_data()->GetLatestLearningDataFrame();
if (learning_data_frame) { if (learning_data_frame) {
planning_learning_data.mutable_learning_data() planning_learning_data.mutable_learning_data()
->add_learning_data() ->add_learning_data_frame()
->CopyFrom(*learning_data_frame); ->CopyFrom(*learning_data_frame);
common::util::FillHeader(node_->Name(), &planning_learning_data); common::util::FillHeader(node_->Name(), &planning_learning_data);
planning_learning_data_writer_->Write(planning_learning_data); planning_learning_data_writer_->Write(planning_learning_data);
......
...@@ -229,7 +229,7 @@ message LearningDataFrame { ...@@ -229,7 +229,7 @@ message LearningDataFrame {
} }
message LearningData { message LearningData {
repeated LearningDataFrame learning_data = 1; repeated LearningDataFrame learning_data_frame = 1;
} }
message PlanningLearningData { message PlanningLearningData {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册