提交 24451743 编写于 作者: L luoqi06 提交者: Jiangtao Hu

Planning : update interface and fix enable chart

上级 96975899
...@@ -122,6 +122,9 @@ Status OpenSpacePlanning::Init(const PlanningConfig& config) { ...@@ -122,6 +122,9 @@ Status OpenSpacePlanning::Init(const PlanningConfig& config) {
} }
start_time_ = Clock::NowInSeconds(); start_time_ = Clock::NowInSeconds();
AINFO << "Open Space Planner Init Done";
return planner_->Init(config_); return planner_->Init(config_);
} }
...@@ -145,6 +148,8 @@ Status OpenSpacePlanning::InitFrame(const uint32_t sequence_num, ...@@ -145,6 +148,8 @@ Status OpenSpacePlanning::InitFrame(const uint32_t sequence_num,
return status; return status;
} }
AINFO << "Open Space Planner Init Frame Done";
return Status::OK(); return Status::OK();
} }
...@@ -206,10 +211,6 @@ void OpenSpacePlanning::RunOnce(const LocalView& local_view, ...@@ -206,10 +211,6 @@ void OpenSpacePlanning::RunOnce(const LocalView& local_view,
status = InitFrame(frame_num, stitching_trajectory.back(), start_timestamp, status = InitFrame(frame_num, stitching_trajectory.back(), start_timestamp,
vehicle_state, trajectory_pb); vehicle_state, trajectory_pb);
if (FLAGS_enable_record_debug) {
frame_->RecordInputDebug(trajectory_pb->mutable_debug());
}
trajectory_pb->mutable_latency_stats()->set_init_frame_time_ms( trajectory_pb->mutable_latency_stats()->set_init_frame_time_ms(
Clock::NowInSeconds() - start_timestamp); Clock::NowInSeconds() - start_timestamp);
...@@ -272,6 +273,7 @@ void OpenSpacePlanning::RunOnce(const LocalView& local_view, ...@@ -272,6 +273,7 @@ void OpenSpacePlanning::RunOnce(const LocalView& local_view,
ADEBUG << "Planning pb:" << trajectory_pb->header().DebugString(); ADEBUG << "Planning pb:" << trajectory_pb->header().DebugString();
frame_->mutable_trajectory()->CopyFrom(*trajectory_pb); frame_->mutable_trajectory()->CopyFrom(*trajectory_pb);
const uint32_t n = frame_->SequenceNum(); const uint32_t n = frame_->SequenceNum();
FrameHistory::Instance()->Add(n, std::move(frame_)); FrameHistory::Instance()->Add(n, std::move(frame_));
} }
...@@ -280,36 +282,46 @@ Status OpenSpacePlanning::Plan( ...@@ -280,36 +282,46 @@ Status OpenSpacePlanning::Plan(
const double current_time_stamp, const double current_time_stamp,
const std::vector<TrajectoryPoint>& stitching_trajectory, const std::vector<TrajectoryPoint>& stitching_trajectory,
ADCTrajectory* const trajectory_pb) { ADCTrajectory* const trajectory_pb) {
auto status = planner_->Plan(stitching_trajectory.back(), frame_.get());
// TODO(QiL): update last_publishable_trajectory_ for stitching
trajectory_pb->CopyFrom(frame_->trajectory());
auto* ptr_debug = trajectory_pb->mutable_debug(); auto* ptr_debug = trajectory_pb->mutable_debug();
if (FLAGS_enable_record_debug) { if (FLAGS_enable_record_debug) {
ptr_debug->mutable_planning_data()->mutable_init_point()->CopyFrom( ptr_debug->mutable_planning_data()->mutable_init_point()->CopyFrom(
stitching_trajectory.back()); stitching_trajectory.back());
ADEBUG << "Open space init point added!";
} }
auto status = planner_->Plan(stitching_trajectory.back(), frame_.get()); if (status.ok() && FLAGS_enable_record_debug) {
ptr_debug->mutable_planning_data()->mutable_open_space()->CopyFrom(
if (status.ok() && FLAGS_enable_record_debug && frame_->open_space_debug());
FLAGS_open_space_planner_switchable) { ADEBUG << "Open space debug information added!";
frame_.get()->RecordOpenSpacePlannerDebug(ptr_debug);
} }
// TODO(QiL): update last_publishable_trajectory_ for stitching if (FLAGS_export_chart) {
trajectory_pb->CopyFrom(frame_->trajectory()); ExportOpenSpaceChart(frame_->open_space_debug(), ptr_debug);
ADEBUG << "Open Space Planning debug from frame is : "
<< frame_->open_space_debug().ShortDebugString();
ADEBUG << "Open Space Planning export chart with : "
<< trajectory_pb->ShortDebugString();
}
return status; return status;
} }
void AddTrajectory(const OpenSpaceDebug& open_space, Chart* chart) { void AddOpenSpaceTrajectory(const OpenSpaceDebug& open_space_debug,
Chart* chart) {
chart->set_title("Open Space Trajectory Visualization"); chart->set_title("Open Space Trajectory Visualization");
auto* options = chart->mutable_options(); auto* options = chart->mutable_options();
options->mutable_x()->set_min(open_space.xy_boundary(0)); options->mutable_x()->set_min(open_space_debug.xy_boundary(0));
options->mutable_x()->set_max(open_space.xy_boundary(1)); options->mutable_x()->set_max(open_space_debug.xy_boundary(1));
options->mutable_x()->set_label_string("x (meter)"); options->mutable_x()->set_label_string("x (meter)");
options->mutable_y()->set_min(open_space.xy_boundary(2)); options->mutable_y()->set_min(open_space_debug.xy_boundary(2));
options->mutable_y()->set_max(open_space.xy_boundary(3)); options->mutable_y()->set_max(open_space_debug.xy_boundary(3));
options->mutable_y()->set_label_string("y (meter)"); options->mutable_y()->set_label_string("y (meter)");
for (const auto& obstacle : open_space.obstacles()) { for (const auto& obstacle : open_space_debug.obstacles()) {
auto* polygon = chart->add_polygon(); auto* polygon = chart->add_polygon();
polygon->set_label(obstacle.id()); polygon->set_label(obstacle.id());
for (int vertice_index = 0; for (int vertice_index = 0;
...@@ -320,7 +332,7 @@ void AddTrajectory(const OpenSpaceDebug& open_space, Chart* chart) { ...@@ -320,7 +332,7 @@ void AddTrajectory(const OpenSpaceDebug& open_space, Chart* chart) {
} }
} }
for (const auto& trajectory : open_space.trajectories().trajectory()) { for (const auto& trajectory : open_space_debug.trajectories().trajectory()) {
auto* line = chart->add_line(); auto* line = chart->add_line();
line->set_label(trajectory.name()); line->set_label(trajectory.name());
for (const auto& point : trajectory.trajectory_point()) { for (const auto& point : trajectory.trajectory_point()) {
...@@ -338,12 +350,13 @@ void AddTrajectory(const OpenSpaceDebug& open_space, Chart* chart) { ...@@ -338,12 +350,13 @@ void AddTrajectory(const OpenSpaceDebug& open_space, Chart* chart) {
} }
} }
void OpenSpacePlanning::ExportChart(const planning_internal::Debug& debug_info, void OpenSpacePlanning::ExportOpenSpaceChart(
planning_internal::Debug* debug_chart) { const planning_internal::OpenSpaceDebug& debug_info,
planning_internal::Debug* debug_chart) {
// Export Trajectory Visualization Chart. // Export Trajectory Visualization Chart.
if (FLAGS_open_space_planner_switchable && FLAGS_enable_record_debug) { if (FLAGS_enable_record_debug) {
AddTrajectory(debug_info.planning_data().open_space(), AddOpenSpaceTrajectory(debug_info,
debug_chart->mutable_planning_data()->add_chart()); debug_chart->mutable_planning_data()->add_chart());
} }
} }
......
...@@ -67,8 +67,8 @@ class OpenSpacePlanning : public PlanningBase { ...@@ -67,8 +67,8 @@ class OpenSpacePlanning : public PlanningBase {
const std::vector<common::TrajectoryPoint>& stitching_trajectory, const std::vector<common::TrajectoryPoint>& stitching_trajectory,
ADCTrajectory* const trajectory) override; ADCTrajectory* const trajectory) override;
void ExportChart(const planning_internal::Debug& debug_info, void ExportOpenSpaceChart(const planning_internal::OpenSpaceDebug& debug_info,
planning_internal::Debug* debug_chart) override; planning_internal::Debug* debug_chart);
private: private:
common::Status InitFrame(const uint32_t sequence_num, common::Status InitFrame(const uint32_t sequence_num,
...@@ -76,7 +76,6 @@ class OpenSpacePlanning : public PlanningBase { ...@@ -76,7 +76,6 @@ class OpenSpacePlanning : public PlanningBase {
const double start_time, const double start_time,
const common::VehicleState& vehicle_state, const common::VehicleState& vehicle_state,
ADCTrajectory* output_trajectory); ADCTrajectory* output_trajectory);
void ExportReferenceLineDebug(planning_internal::Debug* debug);
bool CheckPlanningConfig(const PlanningConfig& config); bool CheckPlanningConfig(const PlanningConfig& config);
private: private:
......
...@@ -124,10 +124,12 @@ bool PlanningComponent::Proc( ...@@ -124,10 +124,12 @@ bool PlanningComponent::Proc(
} }
if (!CheckInput()) { if (!CheckInput()) {
AERROR << "Input check failed";
return false; return false;
} }
ADCTrajectory adc_trajectory_pb; ADCTrajectory adc_trajectory_pb;
AINFO << "Call RunOnce in Planning";
planning_base_->RunOnce(local_view_, &adc_trajectory_pb); planning_base_->RunOnce(local_view_, &adc_trajectory_pb);
common::util::FillHeader(node_->Name(), &adc_trajectory_pb); common::util::FillHeader(node_->Name(), &adc_trajectory_pb);
planning_writer_->Write(std::make_shared<ADCTrajectory>(adc_trajectory_pb)); planning_writer_->Write(std::make_shared<ADCTrajectory>(adc_trajectory_pb));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册