Skip to content

Commit

Permalink
core: use envelope part min in ETCS
Browse files Browse the repository at this point in the history
Signed-off-by: Erashin <[email protected]>
  • Loading branch information
Erashin committed Mar 4, 2025
1 parent cafbd21 commit 69253bf
Showing 1 changed file with 4 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,45 +126,11 @@ private fun computeMinSvlEoaIndCurve(
releaseSpeedPositionSvl,
NATIONAL_RELEASE_SPEED
)
val startIntersectingRange =
max(slicedIndicationCurveEoa.beginPos, slicedIndicationCurveSvl.beginPos)
var refCurve = slicedIndicationCurveEoa
var otherCurve = slicedIndicationCurveSvl
if (
slicedIndicationCurveEoa.interpolateSpeed(startIntersectingRange) >
slicedIndicationCurveSvl.interpolateSpeed(startIntersectingRange)
) {
refCurve = slicedIndicationCurveSvl
otherCurve = slicedIndicationCurveEoa
}
val pointCount = refCurve.pointCount()
var indicationPositions = DoubleArray(pointCount)
var indicationSpeeds = DoubleArray(pointCount)
for (i in 0 until pointCount) {
val newPos = refCurve.getPointPos(i)
val newSpeed = refCurve.getPointSpeed(i)
if (newPos < otherCurve.beginPos) {
indicationPositions[i] = newPos
indicationSpeeds[i] = newSpeed
} else if (newPos <= otherCurve.endPos) {
val otherSpeed = slicedIndicationCurveSvl.interpolateSpeed(newPos)
indicationPositions[i] = newPos
// TODO: unneeded for now: interpolate to not approximate position at intersection.
indicationSpeeds[i] = min(otherSpeed, newSpeed)
} else {
indicationPositions[i] = otherCurve.endPos
indicationSpeeds[i] = otherCurve.endSpeed
// Clean up the last unneeded points in the arrays before exiting the loop.
indicationPositions = indicationPositions.dropLast(pointCount - 1 - i).toDoubleArray()
indicationSpeeds = indicationSpeeds.dropLast(pointCount - 1 - i).toDoubleArray()
break
}
}
val firstIndicationPart =
EnvelopePart.generateTimes(
listOf(EnvelopeProfile.BRAKING),
indicationPositions,
indicationSpeeds
EnvelopePart.min(
slicedIndicationCurveEoa,
slicedIndicationCurveSvl,
listOf(EnvelopeProfile.BRAKING)
)
if (releaseSpeedPositionSvl < releaseSpeedPositionEoa) {
val maintainReleaseSpeedPart =
Expand Down

0 comments on commit 69253bf

Please sign in to comment.