31 const double param)
const {
32 auto it_lower = std::lower_bound(accumulated_param_lengths_.begin(),
33 accumulated_param_lengths_.end(), param);
34 ACHECK(it_lower != accumulated_param_lengths_.end());
36 size_t index = (size_t)(it_lower - accumulated_param_lengths_.begin());
38 double param_overhead = 0.0;
40 param_overhead = accumulated_param_lengths_[index - 1];
42 return trajectory_segments_[index]->Evaluate(order, param - param_overhead);
55 const std::shared_ptr<Curve1d> trajectory) {
56 if (trajectory_segments_.empty()) {
57 trajectory_segments_.push_back(trajectory);
59 double s1 = trajectory->Evaluate(0, 0.0);
60 double v1 = trajectory->Evaluate(1, 0.0);
61 double a1 = trajectory->Evaluate(2, 0.0);
62 double j1 = trajectory->Evaluate(3, 0.0);
64 auto last_trajectory = trajectory_segments_.back();
65 double last_param_length = last_trajectory->ParamLength();
66 double s0 = last_trajectory->Evaluate(0, last_param_length);
67 double v0 = last_trajectory->Evaluate(1, last_param_length);
68 double a0 = last_trajectory->Evaluate(2, last_param_length);
69 double j0 = last_trajectory->Evaluate(3, last_param_length);
71 if (std::fabs(s0 - s1) > 1.0e-4) {
72 AWARN <<
"The appended segment is not smooth in order 0";
75 if (std::fabs(v0 - v1) > 1.0e-4) {
76 AWARN <<
"The appended segment is not smooth in order 1";
79 if (std::fabs(a0 - a1) > 1.0e-4) {
80 AWARN <<
"The appended segment is not smooth in order 2";
83 if (std::fabs(j0 - j1) > 1.0e-4) {
84 AWARN <<
"The appended segment is not smooth in order 3";
86 trajectory_segments_.push_back(trajectory);
89 double accumulated_param_length = trajectory->ParamLength();
90 if (accumulated_param_lengths_.size() > 0) {
91 accumulated_param_length += accumulated_param_lengths_.back();
93 accumulated_param_lengths_.push_back(accumulated_param_length);