提交 def33049 编写于 作者: D Dong Li 提交者: Jiangtao Hu

planning: added GetPointAtTime for static obstacle.

上级 7ad0fbb0
......@@ -101,20 +101,36 @@ bool Obstacle::IsVirtualObstacle(
common::TrajectoryPoint Obstacle::GetPointAtTime(
const double relative_time) const {
auto comp = [](const common::TrajectoryPoint p, const double time) {
return p.relative_time() < time;
};
const auto& points = trajectory_.trajectory_point();
auto it_lower =
std::lower_bound(points.begin(), points.end(), relative_time, comp);
if (it_lower == points.begin()) {
return *points.begin();
} else if (it_lower == points.end()) {
return *points.rbegin();
if (points.size() < 2) {
common::TrajectoryPoint point;
point.mutable_path_point()->set_x(perception_obstacle_.position().x());
point.mutable_path_point()->set_y(perception_obstacle_.position().y());
point.mutable_path_point()->set_z(perception_obstacle_.position().z());
point.mutable_path_point()->set_theta(perception_obstacle_.theta());
point.mutable_path_point()->set_s(0.0);
point.mutable_path_point()->set_kappa(0.0);
point.mutable_path_point()->set_dkappa(0.0);
point.mutable_path_point()->set_ddkappa(0.0);
point.set_v(0.0);
point.set_a(0.0);
point.set_relative_time(0.0);
return point;
} else {
auto comp = [](const common::TrajectoryPoint p, const double time) {
return p.relative_time() < time;
};
auto it_lower =
std::lower_bound(points.begin(), points.end(), relative_time, comp);
if (it_lower == points.begin()) {
return *points.begin();
} else if (it_lower == points.end()) {
return *points.rbegin();
}
return util::interpolate(*(it_lower - 1), *it_lower, relative_time);
}
return util::interpolate(*(it_lower - 1), *it_lower, relative_time);
}
common::math::Box2d Obstacle::GetBoundingBox(
......
......@@ -55,6 +55,7 @@ class Obstacle {
bool IsStatic() const;
common::TrajectoryPoint GetPointAtTime(const double time) const;
common::math::Box2d GetBoundingBox(
const common::TrajectoryPoint &point) const;
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册