apollo icon indicating copy to clipboard operation
apollo copied to clipboard

Question: How to handle the situation when the size of QpSplineReferenceLineSmoother::t_knots is less than 3?

Open jilinzhou opened this issue 8 years ago • 5 comments

Here is the code snippet for related functions:

bool QpSplineReferenceLineSmoother::Sampling() {
  const double length = anchor_points_.back().path_point.s() -
                        anchor_points_.front().path_point.s();
  uint32_t num_spline =
      std::max(1u, static_cast<uint32_t>(
                       length / smoother_config_.max_spline_length() + 0.5));
  for (std::uint32_t i = 0; i <= num_spline; ++i) {
    t_knots_.push_back(i * 1.0);
  }
  // normalize point xy
  ref_x_ = anchor_points_.front().path_point.x();
  ref_y_ = anchor_points_.front().path_point.y();
  return true;
}

bool QpSplineReferenceLineSmoother::AddConstraint() {
...

  // all spline should be connected smoothly to the second order derivative.
  if (!spline_constraint->AddSecondDerivativeSmoothConstraint()) {
    AERROR << "Add jointness constraint failed.";
    return false;
  }

  return true;
}

// guarantee upto second order derivative are joint
bool Spline2dConstraint::AddSecondDerivativeSmoothConstraint() {
  if (t_knots_.size() < 3) {
    return false;
  }
...
}

bool ReferenceLineProvider::SmoothPrefixedReferenceLine(
    const ReferenceLine &prefix_ref, const ReferenceLine &raw_ref,
    ReferenceLine *reference_line) {
...
  smoother_->SetAnchorPoints(anchor_points);
  if (!smoother_->Smooth(raw_ref, reference_line)) {
    AERROR << "Failed to smooth prefixed reference line with anchor points";
    return false;
  }
...
}

We came across this issue during our testing on route (the speed profile experienced was a bit unexpected). The last lane segment of our map is about 40 meters and we set the destination to be the beginning of this last segment (using routing_request.py). As we were reaching the destination, we got the error msg "Failed to smooth prefixed reference line with anchor points". The car kept moving at its current speed and suddenly stopped at the destination point (very sharp braking).

After tracing the code a bit, I noticed it was caused by failed call to Spline2dConstraint::AddSecondDerivativeSmoothConstraint() due to t_knots.size() < 3. The default smoother_config_.max_spline_length() is 25 meters.

Here is log message:

E0523 13:03:21.062803    14 qp_spline_reference_line_smoother.cc:181] Add jointness constraint failed.
E0523 13:03:21.062803    14 qp_spline_reference_line_smoother.cc:60] Add constraint for spline smoother failed
E0523 13:03:21.062803    14 reference_line_provider.cc:587] Failed to smooth prefixed reference line with anchor points
W0523 13:03:21.063802    14 reference_line_provider.cc:444] Failed to smooth forward shifted reference line

jilinzhou avatar May 28 '18 16:05 jilinzhou

In practice, the t_knots will be at least 3.

lianglia-apollo avatar Jul 22 '18 20:07 lianglia-apollo

Do you know how to solve this problem now? My t_knots=2, I don't know how to cause this.

sadsearth avatar Aug 29 '18 02:08 sadsearth

what reasons cause k_knots less than 3 @lianglia-apollo

sadsearth avatar Aug 29 '18 06:08 sadsearth

I have similar issue, I guess. When I run smooth.sh I get:

F0829 09:50:50.689420 1838 spiral_reference_line_smoother.cc:198] Check failed: point2d.size() > 1 (1 vs. 1) *** Check failure stack trace: *** smooth.sh: line 25: 1838 Aborted (core dumped) ./bazel-bin/modules/planning/reference_line/smoother_util --input_file ${pathname} --smooth_length $2

Leonardo092 avatar Aug 29 '18 07:08 Leonardo092

We fixed this issue in the most recent code.

lianglia-apollo avatar Dec 14 '18 19:12 lianglia-apollo