提交 f1b34a8d 编写于 作者: D deidaraho 提交者: Xiangquan Xiao

planning: move ExprtChart from planning_base to online_planning for future extension

上级 27597ee5
......@@ -32,7 +32,9 @@
#include "modules/planning/common/trajectory_stitcher.h"
#include "modules/planning/on_lane_planning.h"
#include "modules/planning/planner/rtk/rtk_replay_planner.h"
#include "modules/planning/proto/planning_internal.pb.h"
#include "modules/planning/reference_line/reference_line_provider.h"
#include "modules/planning/tasks/task_factory.h"
#include "modules/planning/traffic_rules/traffic_decider.h"
#include "modules/planning/util/util.h"
......@@ -48,6 +50,10 @@ using apollo::common::math::Vec2d;
using apollo::common::time::Clock;
using apollo::hdmap::HDMapUtil;
using apollo::routing::RoutingResponse;
using apollo::dreamview::Chart;
using apollo::planning_internal::SLFrameDebug;
using apollo::planning_internal::SpeedPlan;
using apollo::planning_internal::STGraphDebug;
OnLanePlanning::~OnLanePlanning() {
if (reference_line_provider_) {
......@@ -487,5 +493,93 @@ bool OnLanePlanning::CheckPlanningConfig(const PlanningConfig& config) {
return true;
}
void AddStGraph(const STGraphDebug& st_graph, Chart* chart) {
chart->set_title(st_graph.name());
auto* options = chart->mutable_options();
options->mutable_x()->set_min(-2.0);
options->mutable_x()->set_max(10.0);
options->mutable_x()->set_label_string("t(second)");
options->mutable_y()->set_label_string("s(meter)");
options->set_legend_display(false);
for (const auto& boundary : st_graph.boundary()) {
auto* boundary_chart = chart->add_polygon();
// from 'ST_BOUNDARY_TYPE_' to the end
std::string type =
StGraphBoundaryDebug_StBoundaryType_Name(boundary.type()).substr(17);
boundary_chart->set_label(boundary.name() + "_" + type);
for (const auto& point : boundary.point()) {
auto* point_debug = boundary_chart->add_point();
point_debug->set_x(point.t());
point_debug->set_y(point.s());
}
}
}
void AddSlFrame(const SLFrameDebug& sl_frame, Chart* chart) {
chart->set_title(sl_frame.name());
auto* options = chart->mutable_options();
options->mutable_x()->set_min(0.0);
options->mutable_x()->set_max(80.0);
options->mutable_x()->set_label_string("s (meter)");
options->mutable_y()->set_min(-8.0);
options->mutable_y()->set_max(8.0);
options->mutable_y()->set_label_string("l (meter)");
auto* sl_line = chart->add_line();
sl_line->set_label("SL Path");
for (const auto& sl_point : sl_frame.sl_path()) {
auto* point_debug = sl_line->add_point();
point_debug->set_x(sl_point.s());
point_debug->set_x(sl_point.l());
}
}
void AddSpeedPlan(
const ::google::protobuf::RepeatedPtrField<SpeedPlan>& speed_plans,
Chart* chart) {
chart->set_title("Speed Plan");
auto* options = chart->mutable_options();
options->mutable_x()->set_min(0.0);
options->mutable_x()->set_max(80.0);
options->mutable_x()->set_label_string("s (meter)");
options->mutable_y()->set_min(0.0);
options->mutable_y()->set_max(50.0);
options->mutable_y()->set_label_string("v (m/s)");
for (const auto& speed_plan : speed_plans) {
auto* line = chart->add_line();
line->set_label(speed_plan.name());
for (const auto& point : speed_plan.speed_point()) {
auto* point_debug = line->add_point();
point_debug->set_x(point.s());
point_debug->set_y(point.v());
}
// Set chartJS's dataset properties
auto* properties = line->mutable_properties();
(*properties)["borderWidth"] = "2";
(*properties)["pointRadius"] = "0";
(*properties)["fill"] = "false";
(*properties)["showLine"] = "true";
if (speed_plan.name() == "DpStSpeedOptimizer") {
(*properties)["color"] = "\"rgba(27, 249, 105, 0.5)\"";
} else if (speed_plan.name() == "QpSplineStSpeedOptimizer") {
(*properties)["color"] = "\"rgba(54, 162, 235, 1)\"";
}
}
}
void OnLanePlanning::ExportChart(const planning_internal::Debug& debug_info,
planning_internal::Debug* debug_chart) {
for (const auto& st_graph : debug_info.planning_data().st_graph()) {
AddStGraph(st_graph, debug_chart->mutable_planning_data()->add_chart());
}
for (const auto& sl_frame : debug_info.planning_data().sl_frame()) {
AddSlFrame(sl_frame, debug_chart->mutable_planning_data()->add_chart());
}
AddSpeedPlan(debug_info.planning_data().speed_plan(),
debug_chart->mutable_planning_data()->add_chart());
}
} // namespace planning
} // namespace apollo
......@@ -76,6 +76,8 @@ class OnLanePlanning : public PlanningBase {
void ExportReferenceLineDebug(planning_internal::Debug* debug);
bool CheckPlanningConfig(const PlanningConfig& config);
void GenerateStopTrajectory(ADCTrajectory* trajectory_pb);
void ExportChart(const planning_internal::Debug& debug_info,
planning_internal::Debug* debug_chart);
private:
routing::RoutingResponse last_routing_;
......
......@@ -54,94 +54,5 @@ void PlanningBase::FillPlanningPb(const double timestamp,
trajectory_pb->mutable_routing_header()->CopyFrom(
local_view_.routing->header());
}
void AddStGraph(const STGraphDebug& st_graph, Chart* chart) {
chart->set_title(st_graph.name());
auto* options = chart->mutable_options();
options->mutable_x()->set_min(-2.0);
options->mutable_x()->set_max(10.0);
options->mutable_x()->set_label_string("t(second)");
options->mutable_y()->set_label_string("s(meter)");
options->set_legend_display(false);
for (const auto& boundary : st_graph.boundary()) {
auto* boundary_chart = chart->add_polygon();
// from 'ST_BOUNDARY_TYPE_' to the end
std::string type =
StGraphBoundaryDebug_StBoundaryType_Name(boundary.type()).substr(17);
boundary_chart->set_label(boundary.name() + "_" + type);
for (const auto& point : boundary.point()) {
auto* point_debug = boundary_chart->add_point();
point_debug->set_x(point.t());
point_debug->set_y(point.s());
}
}
}
void AddSlFrame(const SLFrameDebug& sl_frame, Chart* chart) {
chart->set_title(sl_frame.name());
auto* options = chart->mutable_options();
options->mutable_x()->set_min(0.0);
options->mutable_x()->set_max(80.0);
options->mutable_x()->set_label_string("s (meter)");
options->mutable_y()->set_min(-8.0);
options->mutable_y()->set_max(8.0);
options->mutable_y()->set_label_string("l (meter)");
auto* sl_line = chart->add_line();
sl_line->set_label("SL Path");
for (const auto& sl_point : sl_frame.sl_path()) {
auto* point_debug = sl_line->add_point();
point_debug->set_x(sl_point.s());
point_debug->set_x(sl_point.l());
}
}
void AddSpeedPlan(
const ::google::protobuf::RepeatedPtrField<SpeedPlan>& speed_plans,
Chart* chart) {
chart->set_title("Speed Plan");
auto* options = chart->mutable_options();
options->mutable_x()->set_min(0.0);
options->mutable_x()->set_max(80.0);
options->mutable_x()->set_label_string("s (meter)");
options->mutable_y()->set_min(0.0);
options->mutable_y()->set_max(50.0);
options->mutable_y()->set_label_string("v (m/s)");
for (const auto& speed_plan : speed_plans) {
auto* line = chart->add_line();
line->set_label(speed_plan.name());
for (const auto& point : speed_plan.speed_point()) {
auto* point_debug = line->add_point();
point_debug->set_x(point.s());
point_debug->set_y(point.v());
}
// Set chartJS's dataset properties
auto* properties = line->mutable_properties();
(*properties)["borderWidth"] = "2";
(*properties)["pointRadius"] = "0";
(*properties)["fill"] = "false";
(*properties)["showLine"] = "true";
if (speed_plan.name() == "DpStSpeedOptimizer") {
(*properties)["color"] = "\"rgba(27, 249, 105, 0.5)\"";
} else if (speed_plan.name() == "QpSplineStSpeedOptimizer") {
(*properties)["color"] = "\"rgba(54, 162, 235, 1)\"";
}
}
}
void PlanningBase::ExportChart(const planning_internal::Debug& debug_info,
planning_internal::Debug* debug_chart) {
for (const auto& st_graph : debug_info.planning_data().st_graph()) {
AddStGraph(st_graph, debug_chart->mutable_planning_data()->add_chart());
}
for (const auto& sl_frame : debug_info.planning_data().sl_frame()) {
AddSlFrame(sl_frame, debug_chart->mutable_planning_data()->add_chart());
}
AddSpeedPlan(debug_info.planning_data().speed_plan(),
debug_chart->mutable_planning_data()->add_chart());
}
} // namespace planning
} // namespace apollo
......@@ -75,9 +75,6 @@ class PlanningBase {
virtual void FillPlanningPb(const double timestamp,
ADCTrajectory* const trajectory_pb);
virtual void ExportChart(const planning_internal::Debug& debug_info,
planning_internal::Debug* debug_chart);
LocalView local_view_;
const hdmap::HDMap* hdmap_ = nullptr;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册