Skip to content

Commit 46aa74f

Browse files
eckterErashin
authored andcommitted
core: avoid recomputing unnecessary coastings, which sometimes crashed
The forward coasting would sometimes not intersect with the base curve, which causes some weirdness and 0-length steps. That coasting would only happen if there's no intersection with min speed limit. In that case, it's not actually necessary to compute it (it's supposed to give the same result as the backwards one). Signed-off-by: Eloi Charpentier <eloi.charpentier.42@gmail.com>
1 parent d493d7e commit 46aa74f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/envelope-sim/src/main/java/fr/sncf/osrd/envelope_sim/allowances/mareco_impl/CoastingGenerator.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@ public static EnvelopePart coastFromEnd(
6767

6868
assert constrainedBuilder.getLastPos() < endPos;
6969

70-
if (!reachedLowLimit && constrainedBuilder.getLastPos() != envelope.getBeginPos())
70+
if (!reachedLowLimit) {
7171
return backwardPartBuilder.build();
72+
// We only need to recompute a coasting going forward if the low speed limit has been reached,
73+
// as we'd need to add accelerations in places where we've clipped the speed
74+
}
7275

7376
var resultCoast = coastFromBeginning(
7477
envelope, context, constrainedBuilder.getLastPos(), constrainedBuilder.getLastSpeed());

0 commit comments

Comments
 (0)