22 const double& vel,
const double& ldr_vel,
23 const double& time_step)
const {
24 const double ts2 = time_step * time_step,
26 delta_acc = (min_acc - max_acc),
28 next_dist = dist + (ldr_vel - vel) * time_step
29 + delta_acc * ts2 / 2,
30 next_ldr_vel = ldr_vel + min_acc * time_step,
31 next_vel = vel + max_acc * time_step,
32 next_vel_inc = next_vel - min_acc * time_step / 2,
33 next_vel_mod = next_vel_inc + max_acc * time_step,
34 next_crit = next_dist - lim_dist
35 + (next_vel * next_vel - next_ldr_vel * next_ldr_vel)
38 next_next_crit = std::max(0., next_crit - delta_acc
39 * (next_vel + max_acc * time_step / 2)
40 / min_acc - delta_acc * ts2);
42 return std::min( min_acc + 2 * (next_dist - lim_dist
43 + (next_ldr_vel - next_vel)
44 * time_step) / (3 * ts2),
45 std::min( sqrt( next_vel_inc * next_vel_inc
46 - 2 * min_acc * next_crit
48 + min_acc * time_step) / time_step,
49 ( sqrt( next_vel_mod * next_vel_mod
50 - 2 * min_acc * next_next_crit )
51 - next_vel) / time_step + delta_acc
77 (
double& trans_vel,
double& rot_vel,
const double& trans_fact,
78 const double& rot_fact,
const double& time_step)
const {
79 static const int nbVal = 2;
82 max_vel[nbVal] = {limits[
vMax], limits[
omMax]},
83 acc[nbVal] = {limits[
aMax], limits[
gmMax]},
84 dec[nbVal] = {limits[
aMin], limits[
gmMin]};
85 const double fact[nbVal] = {trans_fact, rot_fact};
86 double *vel[nbVal] = {&trans_vel, &rot_vel};
88 for(
int id = 0;
id < nbVal;
id++) {
89 double delta_t = time_step;
92 const bool isAcc = (*vel[id] * fact[id] >= 0);
94 = fact[id] * ( isAcc ? acc[id] : fabs(dec[
id]) );
95 *vel[id] += delta_a * delta_t;
99 if (*vel[
id] > max_vel[
id]) *vel[id] = max_vel[id];
101 if (*vel[
id] < min_vel[
id]) *vel[id] = min_vel[id];
104 if (*vel[
id] * fact[
id] > 0) {
105 *vel[id] -= delta_a * delta_t;
107 delta_t = time_step + *vel[id] / delta_a;
110 }
while (delta_t > 0);
129 (
double& trans_vel,
double& rot_vel,
const double& trans_acc,
130 const double& rot_acc,
const double& time_step)
const {
131 static const int nbVal = 2;
134 max_vel[nbVal] = {limits[
vMax], limits[
omMax]},
135 max_acc[nbVal] = {limits[
aMax], limits[
gmMax]},
136 max_dec[nbVal] = {limits[
aMin], limits[
gmMin]};
137 const double acc[nbVal] = {trans_acc, rot_acc};
138 double *vel[nbVal] = {&trans_vel, &rot_vel};
140 for(
int id = 0;
id < nbVal;
id++) {
141 double delta_t = time_step;
144 const bool isAcc = (*vel[id] * acc[id] >= 0);
146 sgnAcc = (acc[id] < 0 ? -1 : 1), absAcc = sgnAcc * acc[
id],
148 ( isAcc ? (absAcc > max_acc[
id] ? max_acc[
id] : absAcc)
149 : (absAcc > - max_dec[id] ? - max_dec[id] : absAcc) );
150 *vel[id] += delta_a * delta_t;
154 if (*vel[
id] > max_vel[
id]) *vel[id] = max_vel[id];
156 if (*vel[
id] < min_vel[
id]) *vel[id] = min_vel[id];
159 if (*vel[
id] * sgnAcc > 0) {
160 *vel[id] -= delta_a * delta_t;
162 delta_t = time_step + *vel[id] / delta_a;
165 }
while (delta_t > 0);
double limits[nbLimits]
The array of limits.
Index of the maximum translation deceleration.
void applyAccelerationFactors(double &trans_vel, double &rot_vel, const double &trans_fact, const double &rot_fact, const double &time_step) const
Modify translation and rotation given velocities, applying the extremal accelerations multiplied by t...
void applyAccelerations(double &trans_vel, double &rot_vel, const double &trans_acc, const double &rot_acc, const double &time_step) const
Modify translation and rotation given velocities, applying the given accelerations during the given t...
Index of the minimum translation velocity.
Index of the maximum rotation deceleration.
Index of the maximum translation acceleration.
Motion model for qt_ctrl.
Index of the maximum rotation acceleration.
Index of the maximum rotation velocity.
Index of the maximum translation velocity.
double limAcc(const double &lim_dist, const double &dist, const double &vel, const double &ldr_vel, const double &time_step) const
Descriptive method, giving the limit acceleration which ensure to avoid reaching limit distance for a...