Skip to content

Commit 07d0d01

Browse files
committed
2 points at least in the clipped trajectory
Signed-off-by: Zhe Shen <lucidshenzhe@gmail.com>
1 parent d0cfc9a commit 07d0d01

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

control/mpc_lateral_controller/src/mpc_utils.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -473,12 +473,16 @@ MPCTrajectory clipTrajectoryByLength(const MPCTrajectory & trajectory, const dou
473473
clipped_trajectory.push_back(trajectory.at(0));
474474

475475
double current_length = 0.0;
476-
for (size_t i = 1; i < trajectory.size(); ++i) {
477-
current_length += calcDistance3d(trajectory, i, i - 1);
478-
if (current_length > length) {
479-
break;
480-
}
481-
clipped_trajectory.push_back(trajectory.at(i));
476+
{
477+
size_t i = 1;
478+
do {
479+
clipped_trajectory.push_back(trajectory.at(i));
480+
current_length += calcDistance3d(trajectory, i, i - 1);
481+
if (current_length > length) {
482+
break;
483+
}
484+
++i;
485+
} while (i < trajectory.size());
482486
}
483487

484488
return clipped_trajectory;

0 commit comments

Comments
 (0)