Skip to content

core: handle backtracks #12209

@eckter

Description

@eckter

So we need to handle backtracks.

https://github.com/osrd-project/osrd-confidential/issues/1055

Input:

class PathfindingBlockRequest(
    @Json(name = "rolling_stock_loading_gauge") val rollingStockLoadingGauge: RJSLoadingGaugeType,
    @Json(name = "rolling_stock_is_thermal") val rollingStockIsThermal: Boolean,
    @Json(name = "rolling_stock_supported_electrifications")
    val rollingStockSupportedElectrifications: List<String>,
    @Json(name = "rolling_stock_supported_signaling_systems")
    val rollingStockSupportedSignalingSystems: List<String>,
    @Json(name = "rolling_stock_maximum_speed") val rollingStockMaximumSpeed: Double,
    @Json(name = "rolling_stock_length") val rollingStockLength: Double,
    val timeout: Double?,
    val infra: String,
    @Json(name = "expected_version") val expectedVersion: Int?,
 
    @Json(name = "path_items") val pathItems: List<PathItem> // <---- Adapt 
)

class PathItem(val locations: Collection<TrackLocation>, val canBacktrack: boolean)

Output:

class PathfindingBlockSuccess(
    // Block ids
    val blocks: List<String>,

    // Route ids
    val routes: List<String>,
    @Json(name = "track_section_ranges") val trackSectionRanges: List<DirectionalTrackRange>,
    val length: Length<TravelledPath>,

    /** Offsets of the waypoints given as input */
    @Json(name = "path_item_positions") val pathItemPositions: List<Offset<TravelledPath>>
    @Json(name = "backtrack_positions") val backtrackPositions: List<Offset<TravelledPath>> // New field
)

Some goals:

  • TravelledPath should not have any "holes", which makes it not continuous. At the backtrack location, we move forward by an espilon and the "train head" teleports to its tail. At any point of the TravelledPath, we can query a train speed.
  • That TravelledPath is the type of any offset in the endpoint output

Implementation plan (suggestion, not fixed yet):

  • We define several path types (keeping the current nomenclature as much as possible): TravelledPath, BlockPath, probably some new ones.
  • We define a new interface for each, with the data we may want to query on it
  • We define a new interface that implement each path type interface
  • We create a single implementation for the unified interface, not a new implementation for each
  • That implementation class handles every conversion across paths
  • We still use the most "restrictive" interface in the rest of the code (if we only need TravelledPath data, we don't require the unified interface as input
  • We may want to write mock implementation for the specific path types for the unit tests

Alternative: we just implement one unified class, without all the interfaces. Upside: a lot less complexity. Downside: writing tests requires a fully valid infra and path.

We may want to have a first implementation that does not handle backtracking, and then a second implementation with backtracks that uses the first one internally.


Notes:

This would be a good time to remove the "portal" from which the train appears. We consider it out of scope for this issue (it hasn't been asked and the refactoring would be large enough as it is). But we should keep it in mind and assume we may have to implement it soon.


Now we need to name these different paths. Here's a rough draft, to be edited with a cleaner version once we have the names:

Image

Current suggestion (to be discussed):

  • Violet: FullBlockPath (just to have a different name during the transition, to be mass-renamed later to BlockPath)
  • Orange: CoveredPath
  • Green: HeadTravelledPath

Implementation plan (core)

Can be done in advance, no editoast requirement

Need editoast features (or feature flag)

Sub-issues

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions