75 constexpr const char* kMalformedSplineExceptionMsg =
76 "Could not parameterize a malformed spline. This means that you "
77 "probably had two or more adjacent waypoints that were very close "
78 "together with headings in opposing directions.";
79 std::vector<PoseWithCurvature> splinePoints;
82 if (
auto point = spline.
GetPoint(t0)) {
83 splinePoints.push_back(point.value());
90 std::stack<StackContents> stack;
91 stack.emplace(StackContents{t0, t1});
95 while (!stack.empty()) {
96 auto current = stack.top();
99 auto start = spline.
GetPoint(current.t0);
104 auto end = spline.
GetPoint(current.t1);
109 const auto twist = (end.value().first - start.value().first).Log();
111 if (units::math::abs(twist.dy) > kMaxDy ||
112 units::math::abs(twist.dx) > kMaxDx ||
113 units::math::abs(twist.dtheta) > kMaxDtheta) {
114 stack.emplace(StackContents{(current.t0 + current.t1) / 2, current.t1});
115 stack.emplace(StackContents{current.t0, (current.t0 + current.t1) / 2});
117 splinePoints.push_back(end.value());
120 if (iterations++ >= kMaxIterations) {