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

planning added min_s, min_t, max_s, max_t function in st graph. which is

used to calculate the fence point in st graph
上级 9986cc88
......@@ -46,6 +46,12 @@ StGraphBoundary::StGraphBoundary(const PathObstacle* path_obstacle,
CHECK_EQ(points.size(), 4)
<< "StGraphBoundary must have exactly four points. Input points size: "
<< points.size();
for (const auto& point : points) {
min_s_ = std::fmin(min_s_, point.s());
min_t_ = std::fmin(min_t_, point.t());
max_s_ = std::fmax(max_s_, point.s());
max_t_ = std::fmax(max_t_, point.t());
}
}
StGraphBoundary::StGraphBoundary(
......@@ -56,6 +62,12 @@ StGraphBoundary::StGraphBoundary(
CHECK_EQ(points.size(), 4)
<< "StGraphBoundary must have exactly four points. Input points size: "
<< points.size();
for (const auto& point : points) {
min_s_ = std::fmin(min_s_, point.y());
min_t_ = std::fmin(min_t_, point.x());
max_s_ = std::fmax(max_s_, point.y());
max_t_ = std::fmax(max_t_, point.x());
}
}
bool StGraphBoundary::IsPointInBoundary(
......@@ -153,5 +165,10 @@ void StGraphBoundary::GetBoundaryTimeScope(double* start_t,
*end_t = right.t();
}
double StGraphBoundary::min_s() const { return min_s_; }
double StGraphBoundary::min_t() const { return min_t_; }
double StGraphBoundary::max_s() const { return max_s_; }
double StGraphBoundary::max_t() const { return max_t_; }
} // namespace planning
} // namespace apollo
......@@ -79,12 +79,21 @@ class StGraphBoundary : public common::math::Polygon2d {
const PathObstacle* path_obstacle() const;
double min_s() const;
double min_t() const;
double max_s() const;
double max_t() const;
private:
const PathObstacle* path_obstacle_ = nullptr;
BoundaryType boundary_type_ = BoundaryType::UNKNOWN;
std::string id_;
double characteristic_length_ = 1.0;
double s_high_limit_ = 200.0;
double min_s_ = std::numeric_limits<double>::max();
double max_s_ = std::numeric_limits<double>::lowest();
double min_t_ = std::numeric_limits<double>::max();
double max_t_ = std::numeric_limits<double>::lowest();
};
} // namespace planning
......
......@@ -45,6 +45,10 @@ TEST(StGraphBoundaryTest, basic_test) {
boundary.GetBoundaryTimeScope(&left_t, &right_t);
EXPECT_DOUBLE_EQ(left_t, 0.0);
EXPECT_DOUBLE_EQ(right_t, 10.0);
EXPECT_FLOAT_EQ(0.0, boundary.min_s());
EXPECT_FLOAT_EQ(5.0, boundary.max_s());
EXPECT_FLOAT_EQ(0.0, boundary.min_t());
EXPECT_FLOAT_EQ(10.0, boundary.max_t());
}
} // namespace planning
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册