55 {
56 if (trajectory_segments_.empty()) {
57 trajectory_segments_.push_back(trajectory);
58 } else {
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);
63
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);
70
71 if (std::fabs(s0 - s1) > 1.0e-4) {
72 AWARN <<
"The appended segment is not smooth in order 0";
73 }
74
75 if (std::fabs(v0 - v1) > 1.0e-4) {
76 AWARN <<
"The appended segment is not smooth in order 1";
77 }
78
79 if (std::fabs(a0 - a1) > 1.0e-4) {
80 AWARN <<
"The appended segment is not smooth in order 2";
81 }
82
83 if (std::fabs(j0 - j1) > 1.0e-4) {
84 AWARN <<
"The appended segment is not smooth in order 3";
85 }
86 trajectory_segments_.push_back(trajectory);
87 }
88
89 double accumulated_param_length = trajectory->ParamLength();
90 if (accumulated_param_lengths_.size() > 0) {
91 accumulated_param_length += accumulated_param_lengths_.back();
92 }
93 accumulated_param_lengths_.push_back(accumulated_param_length);
94}