How to use "planning" module in a closed area?
Hi, everyone. I have recorded trajectories in a closed area and there is no high-definition map in it. I want to test the correctness of the recorded data and I have two questions. First, how can I use the "routing" module to output the "navigation information" as the input to the "planning" module? Second, Can I use the "EMPlanner" for local path planning? Thanks so much.
The apollo 1.0 version do not rely on hdmap. You can refer it for details.
@lianglia-apollo Thanks. But I want to use the "EMPlanner" and it isn't provided in the 1.0 version. Can you give me more suggestion?
If it is only repeating a recorded trajectory, there is no need to use EM planner. The current (2.0) version of planner requires to load hdmap in planning.cc.
Maybe a better way to do this is to entirely separate each planner from the beginning. For now, I think you can comment the following code in the Init() function of planning.cc:
hdmap_ = apollo::hdmap::HDMapUtil::BaseMapPtr(); CHECK(hdmap_) << "Failed to load map file:" << apollo::hdmap::BaseMapFile();
and all other code that uses hdmap_.
@lianglia-apollo Thanks for your patience. I'm afraid that I didn't describe the question clearly. My purpose is to test the ability of the "EMPlanner" such as avoiding static obstacles and making correct decisions for the traffic signs on the ground in a closed area. As you know, there isn't a high-definition map in it and maybe the navigating path from the source to the destination can't be generated. As a result, I have two questions. First, Can I use the "EMPlanner" for local path planning? Second, how can I use the "routing" module to output the "navigation information" as the input to the "planning" module? I think your answer gives me the method to address the first question. I will highly appreciate your kindness if you can give me more advice on the second question.
@davidhopper2003 I guess you need HDMap. That's the easiest way to enable routing and EMPlaner. Even the traffic signs on the ground can be marked in the map. We have some internal tools that can create a map without intersection. If in your area, there is no intersection, maybe you can send us the trajectories you have recorded, then we can create a one-lane map for you.
@startcode Yes, I need it. Thank you. How can I make contact with you? In addition, I find the "PathDecider" class can be used to avoid static obstacles. Can I use it in the "RTKReplayPlanner"? My implementation is listed as follows ( Note that the block with the "davidhopper" tag). But it doesn't work. Can you give me some advice? Thanks so much.
Status RTKReplayPlanner::PlanOnReferenceLine(
const TrajectoryPoint& planning_init_point, Frame* frame,
ReferenceLineInfo* reference_line_info) {
if (complete_rtk_trajectory_.empty() || complete_rtk_trajectory_.size() < 2) {
std::string msg(
"RTKReplayPlanner doesn't have a recorded trajectory or "
"the recorded trajectory doesn't have enough valid trajectory "
"points.");
AERROR << msg;
return Status(ErrorCode::PLANNING_ERROR, msg);
}
std::uint32_t matched_index =
QueryPositionMatchedPoint(planning_init_point, complete_rtk_trajectory_);
std::uint32_t forward_buffer = FLAGS_rtk_trajectory_forward;
// end_index is excluded.
std::uint32_t end_index = std::min<std::uint32_t>(
complete_rtk_trajectory_.size(), matched_index + forward_buffer);
// auto* trajectory_points = trajectory_pb->mutable_trajectory_point();
std::vector<TrajectoryPoint> trajectory_points(
complete_rtk_trajectory_.begin() + matched_index,
complete_rtk_trajectory_.begin() + end_index);
// reset relative time
double zero_time = complete_rtk_trajectory_[matched_index].relative_time();
for (auto& trajectory_point : trajectory_points) {
trajectory_point.set_relative_time(trajectory_point.relative_time() -
zero_time);
}
// check if the trajectory has enough points;
// if not, append the last points multiple times and
// adjust their corresponding time stamps.
while (trajectory_points.size() <
static_cast<std::size_t>(FLAGS_rtk_trajectory_forward)) {
const auto& last_point = trajectory_points.rbegin();
auto new_point = last_point;
new_point->set_relative_time(new_point->relative_time() +
FLAGS_rtk_trajectory_resolution);
trajectory_points.push_back(*new_point);
}
reference_line_info->SetTrajectory(DiscretizedTrajectory(trajectory_points));
//
// Added by davidhopper
// Date: 2018-2-4
// Purpose: Avoid obstacles.
if (!reference_line_info->AddObstacles(frame->obstacles())) {
AERROR << "Failed to add obstacles to reference line";
return Status(ErrorCode::PLANNING_ERROR,
"Failed to add obstacles to reference line");
}
if (!reference_line_info->IsChangeLanePath()) {
ADEBUG << "The vehicle is changing a lane. ";
const double kStraightForwardLineCost = 10.0;
reference_line_info->AddCost(kStraightForwardLineCost);
}
auto ret = Status::OK();
const double start_timestamp = Clock::NowInSeconds();
PathDecider optimizer;
ret = optimizer.Execute(frame, reference_line_info);
if (!ret.ok()) {
reference_line_info->AddCost(std::numeric_limits<double>::infinity());
AERROR << "Failed to run tasks[" << optimizer.Name()
<< "], Error message: " << ret.error_message();
}
const double end_timestamp = Clock::NowInSeconds();
const double time_diff_ms = (end_timestamp - start_timestamp) * 1000;
ADEBUG << "after optimizer " << optimizer.Name() << ":"
<< reference_line_info->PathSpeedDebugString() << std::endl;
ADEBUG << optimizer.Name() << " time spend: " << time_diff_ms << " ms.";
for (const auto* path_obstacle :
reference_line_info->path_decision()->path_obstacles().Items()) {
if (!path_obstacle->obstacle()->IsStatic()) {
continue;
}
if (path_obstacle->LongitudinalDecision().has_stop()) {
constexpr double kRefrenceLineStaticObsCost = 1e3;
reference_line_info->AddCost(kRefrenceLineStaticObsCost);
}
}
if (ret == Status::OK()) {
// vehicle can drive on this reference line.
reference_line_info->SetDrivable(true);
}
return ret;
//
// End of davidhopper
//
// return Status::OK();
}
Here is the error information:
W0205 10:45:25.797191 20163 reference_line_provider.cc:208] Reference line is NOT ready.
E0205 10:45:25.797283 20163 frame.cc:127] Failed to create reference line
E0205 10:45:25.797483 20163 frame.cc:301] Failed to init reference line info
E0205 10:45:25.797513 20163 planning.cc:68] failed to init frame
E0205 10:45:25.797833 20163 planning.cc:290] Failed to init frame
E0205 10:45:25.907582 20163 path_decider.cc:77] Path is empty.
E0205 10:45:25.907721 20163 path_decider.cc:65] Failed to make decisions for static obstacles
E0205 10:45:25.907811 20163 path_decider.cc:55] Failed to make decision based on tunnel
E0205 10:45:25.907850 20163 rtk_replay_planner.cc:144] Failed to run tasks[PathDecider], Error message: dp_road_graph decision
E0205 10:45:25.907976 20163 rtk_replay_planner.cc:70] planner failed to make a driving plan for: 0_0
E0205 10:45:25.908021 20163 planning.cc:390] planner failed to make a driving plan because NO valid reference line info.
E0205 10:45:25.908067 20163 planning.cc:325] Planning failed:PLANNING_ERROR: planner failed to make a driving plan because NO valid reference line info.
You can send me your trajectory to my email [] (deleted now)
@startcode Thank you very much.
The avoidance of obstacles are done from both dp_poly_path and path_decider. I think you need both modules to avoid obstacles. The dp path will sample points on a given road, and selected the curve with minimum cost. The path decider will generate a stop decision when certain obstacles are hard to avoid.
@lianglia-apollo OK, thanks.
@startcode @lianglia-apollo
I have the similar problem with @davidhopper2003 .
I cant't get the HD map, I am using the rtk planner, and I want to use the EM planner to use the ability of the "EMPlanner" such as avoiding static obstacles and making correct decisions for the traffic signs on the ground in a closed area now.
What should I do to enable routing and EMPlaner without HDmap?
Looking forward for your reply.