29 template <
typename SCALAR =
double>
60 setup(x0, xT, abs_v_max, abs_a_max);
89 t0n_ = v_max_ / a_max_;
91 SCALAR delta_x = 0.5 * a_max_ * t0n_ * t0n_;
95 if (2 * fabs(delta_x) >= fabs(xT_ - x0_))
99 SCALAR delta_x_mid = 0.5 * (xT_ - x0_);
100 x_mid_ = 0.5 * (xT_ + x0_);
102 t0_ = sqrt(delta_x_mid * 2 / a_max_);
103 v_max_ = a_max_ * t0_;
110 x_t0n_ = x0_ + 0.5 * a_max_ * t0n_ * t0n_;
111 x_t1_ = xT_ - delta_x;
112 t1_ = t0n_ + (x_t1_ - x_t0n_) / v_max_;
129 throw std::runtime_error(
"SingleAxisTrajGenerator: time cannot be negative!");
132 queryPlanAccADec(time, x_new, v_new);
134 queryPlanAccHDec(time, x_new, v_new);
136 throw std::runtime_error(
"SingleAxisTrajectoryGenerator: operation mode not available.");
142 MODE operation_mode_;
143 SCALAR x0_, x_t0n_, x_mid_, x_t1_, xT_;
145 SCALAR t0_, t0n_, t1_, T_;
151 x_new = x0_ + 0.5 * a_max_ * time * time;
152 v_new = a_max_ * time;
154 else if (time > t0_ && time <= 2 * t0_)
157 x_new = x_mid_ + v_max_ * (time - t0_) - 0.5 * a_max_ * (time - t0_) * (time - t0_);
159 v_new = v_max_ - a_max_ * (time - t0_);
161 else if (time > 2 * t0_)
168 throw std::runtime_error(
"SingleAxisTrajectoryGenerator: something is wrong with the time.");
176 x_new = 0.5 * a_max_ * time * time + x0_;
177 v_new = a_max_ * time;
179 else if (time > t0n_ && time <= t1_)
181 x_new = x_t0n_ + v_max_ * (time - t0n_);
184 else if (time > t1_ && time <= T_)
187 x_new = x_t1_ + v_max_ * (time - t1_) - 0.5 * a_max_ * ((time - t1_) * (time - t1_));
189 v_new = v_max_ - ((time - t1_) * a_max_);
198 throw std::runtime_error(
"SingleAxisTrajectoryGenerator: something is wrong with the time.");
void queryTrajectory(const SCALAR time, SCALAR &x_new, SCALAR &v_new)
Definition: SingleDOFTrajectoryGenerator.h:126
SCALAR setup(const SCALAR x0, const SCALAR xT, SCALAR abs_v_max, SCALAR abs_a_max)
Definition: SingleDOFTrajectoryGenerator.h:74
Definition: SingleDOFTrajectoryGenerator.h:35
SingleDOFTrajectoryGenerator(const SCALAR x0, const SCALAR xT, SCALAR abs_v_max, SCALAR abs_a_max)
Definition: SingleDOFTrajectoryGenerator.h:57
Definition: SingleDOFTrajectoryGenerator.h:30
CppAD::AD< CppAD::cg::CG< double > > SCALAR
MODE
Definition: SingleDOFTrajectoryGenerator.h:33
Definition: SingleDOFTrajectoryGenerator.h:36
SingleDOFTrajectoryGenerator()
Definition: SingleDOFTrajectoryGenerator.h:40