GithubHelp home page GithubHelp logo

openrailassociation / osrd Goto Github PK

View Code? Open in Web Editor NEW
182.0 182.0 31.0 29.78 MB

An open source web application for railway infrastructure design, capacity analysis, timetabling and simulation

Home Page: https://osrd.fr

License: GNU Lesser General Public License v3.0

Java 12.43% Dockerfile 0.07% Python 3.61% JavaScript 0.44% HTML 0.02% SCSS 2.08% TypeScript 43.37% Shell 0.14% Rust 21.92% Kotlin 15.11% MDX 0.07% PLpgSQL 0.62% Nix 0.06% HCL 0.05% C 0.02%
railway simulation

osrd's People

Contributors

akctarus avatar alexandredamiron avatar anisometropie avatar axrolld avatar bgiuliana avatar bloussou avatar clarani avatar dependabot[bot] avatar eckter avatar flomonster avatar hamz2a avatar jacomyal avatar khoyo avatar kmer2016 avatar leovalais avatar multun avatar nicolaswurtz avatar pguenezan avatar romainvalls avatar sarahbellaha avatar sharglutdev avatar shenriotpro avatar sim51 avatar tguisnet avatar transifex-integration[bot] avatar tristramg avatar uriel-sautron avatar wadjetz avatar yohh avatar younesschrifi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

osrd's Issues

Fix style issues

It wasn't automatically checked for a while, so style errors have accumulated. Especially in the test files.

Infrastructure validator endpoint

Create an endpoint to check if an infrastructure is valid:

We could check the following things:

  • The infrastructure is consistent (no references to objects that doesn't exists)
  • No cyclic dependency between the signals
  • The warning signals are spaced far enough apart to allow the train to slow down in extreme cases.

Add primitives and Optional to railscript

Add primitives to simplify railscript

  • Add signal list for routes.
    • Add it to the infra.
    • Add it in railjson.
    • Parse it from railml.
  • Add Optional type
  • Add reserved_route(Signal) -> Optional<Route> primitive
  • Add next_signal(Signal, Route) -> Optional<Signal> primitive

Example of matched Optional:

match Some("test") {
    Some(signal): AspectSet { GREEN },
    None: AspectSet { RED }
}
match reserved_route(current_signal) {
    Some(route): AspectSet {
        match next_signal(current_signal) {
            Some(signal): AspectSet {
                GREEN,
                YELLOW if signal_has_aspect(signal, RED)
            },
            None: AspectSet { YELLOW }
        }
    },
    None: AspectSet { RED }
}

Provide a unified simulation API

Currently, to start a simulation, OSRD needs:

  • an infrastructure file
  • a rolling stock file per train type
  • a schedule

It'd be quite a bit fancier to be able to start a simulation from a single API call, once the infrastructure is loaded. We could put the rolling stocks and schedule in the same JSON parameter file, as neither really need to be persistent in the backend (both are pretty small)

Pathfind in TIVs crashes

java.lang.NullPointerException
	at fr.sncf.osrd.utils.graph.BiDijkstra.findPaths(BiDijkstra.java:62)
	at fr.sncf.osrd.api.PathfindingTracksEndpoint.act(PathfindingTracksEndpoint.java:77)
	at org.takes.facets.fork.FkRegex$1.act(FkRegex.java:157)
	at org.takes.facets.fork.FkRegex.route(FkRegex.java:228)
	at org.takes.facets.fork.FkChain.route(FkChain.java:72)
	at org.takes.facets.fork.TkFork.act(TkFork.java:100)
	at org.takes.facets.fallback.TkFallback.route(TkFallback.java:89)
	at org.takes.facets.fallback.TkFallback.access$000(TkFallback.java:57)
	at org.takes.facets.fallback.TkFallback$1.act(TkFallback.java:69)
	at org.takes.tk.TkWrap.act(TkWrap.java:58)
	at org.takes.tk.TkSlf4j.act(TkSlf4j.java:92)
	at org.takes.http.BkBasic.print(BkBasic.java:127)
	at org.takes.http.BkBasic.accept(BkBasic.java:103)
	at org.takes.http.BkSafe$1.accept(BkSafe.java:49)
	at org.takes.http.BkWrap.accept(BkWrap.java:51)
	at org.takes.http.FtBasic.loop(FtBasic.java:114)
	at org.takes.http.FtBasic.start(FtBasic.java:100)
	at fr.sncf.osrd.cli.ApiServerCommand.run(ApiServerCommand.java:75)
	at fr.sncf.osrd.App.main(App.java:43)

Implement the route graph as a directed graph

Currently, it uses the same base code as the track section graph, where neighbors are stored on each ends of edges. this is pretty wrong : the pathfinding algorithm does extra work for nothing

Improve error reporting when parsing invalid files

If a field is missing, has the wrong name, or an object is generally not properly formed, we end up with an obscure NullPointerException or similar. It would be better to have a clear error, something like "missing field foo in object bar".

Improve the train movement simulation and control

  • Make an explicit list of the inputs required to make the position of the train evolve
  • Move the simulation loop in a separate class
  • Try to make an alternate simulator which uses an approximate analytical method (it can be done easily by ignoring slope)
  • Design an interface which would work for simulating extra parameters, like train battery charge
  • Make a remote control API, which would enable manual control of trains using a video game UI

This work touches two major components:

  • the integrator
  • the driver decision making process

Try to reduce the number of changes

The tiny simulation example renegates 60 changes, which sounds like a bit much. It can be optimized:

  • route and tvd section state changes account for most of the noise. Consider bundling changes together.

Slope

  • Add slope in railjson
  • Add circular curve into TrainPhysicsIntegrator.make
  • Inject slope in TrackSection.slope
  • Parse slope from railml
  • Parse slope from rsl
 "track_sections": [
  {
    "id": "my_track_section",
    "slope": [
        {
          "begin": 0,
          "end": 1000,
          "gradient": 10
        }
     ],
     "curve": [
        {
          "begin": 0,
          "end": 1000,
          "radius": 10
        }
     ]
  }
]

Phase rework

We need to rework the phases as it has become an accumulation of too many things.

  • Separate train path
    • Create another class containing the whole path
    • Move all relevant methods from SignalNavigatePhase
  • Separate margin limits
    • Add a parameter for margin begin and end positions relative to the full train path
  • Move SpeedInstruction instance to TrainSchedule
  • Create an alternative for stops
    • Create a list of stops
    • Add configs to the schedule
    • Replace the EndOfPhase event
  • Improve Phase interface for an easier integration of mobile block
    • Create new evolveUntilTimeOrPosition function in TrainState

improve end of phase detection

In the current implementation, the end of phase is detected with an interaction on the path. But if we reach a stop slightly earlier, it's not reached and the event doesn't happen. We need to improve this behavior.

Provide a pathfinding API

The end user selects a starting point, an end point, and expects a path to be found.
This can be done ahead of time in the route graph.

inputs:

  • some infrastructure
  • a start and end operational point

output:

  • a route path from the infrastructure

Another endpoint will be needed to get the track section a route goes through.

API Pathfinding Routes: add operational points

Change pathfinding/routes endpoint response with the following format:

{
  "path": [
    {
    "route": "route_id_1",
    "track_sections": [{"track_section": "track_id_1", "begin": 30, "end": 45}]
    },
    {
    "route": "route_id_2",
    "track_sections": [{"track_section": "track_id_2", "begin": 30, "end": 45}]
    }
  ],
  "operational_points": [
    {
      "op": "my_operational_point_1",
      "position": {"track_section": "track_1", "offset": 50}
    }
  ]
}

RSL Parser

Implement the rsl to railJSON parser to support this format.

Investigate using custom linter rules

https://medium.com/@dbottillo/how-to-write-a-custom-rule-in-lint-d2395d88c8c2

Some of the simulation APIs can easily be misused. This could be proactively prevented by writing proper checks ahead of time:

  • changes should be published once applied
  • timeline events can only be created, identified using nextEventId and inserted on the timeline using scheduleEvent in a class which implements Change
  • the constructor of TimelineEvent subclasses must be private, as these should be created in a change (which can have access to the private constructor)

Add delays for switch position changes

When a switch moves, routes are kept in a requested but not yet locked state
TODO:

  • add the position_change_delay field to RailJSON
  • add the REQUESTED RouteStatus, which applies while the switches are moving
  • add a MOVING member to the SwitchState enum
  • create a new event corresponding to the successful position change of a switch
  • when the event completes, tell the route so it can lock itself if all switches are ready (doing nothing otherwise)

Following speed limits shifts them

At a given simulation step, we consider the speed limit at the current position to compute the speed at the next step. This shifts the speeds by speed * dt.

Fixing this breaks a lot of tests, so we need to reconsider precisely the wanted behavior whenever we compute speeds per position and rework the tests accordingly.

Rework speed controllers and physics integrator to later integrate mareco

This is what I've understood of the issue #39 after discussing with everyone involved, as well as a suggested implementation. Please correct me if I'm wrong somewhere.

The main changes will affect speed controllers. This is the tool we use to pre-compute and describe train speeds at every point, for now it only defines the max speed.

We would need to add a similar tool to describe the desired speed on top of the max speed, with a way to tell the train when it is running late. This desired speed would come from an abstract interface, configured in simulation.json. The mareco implementation would follow this interface, and the default behavior would be to follow the max speed.

To do this, we would also need to rework the TrainPhysicsIntegrator. We need it to be able to simulate a train speed from start to finish easily and with as little inputs as possible, excluding any interaction. We may also need more complex operations such as backward steps, which would also let us improve max speed estimations.

Handle multiple signal linked to the same detector

In some cases two signals (in opposite direction) can be linked to the same detector.
To handle this case multiple things must be done in the RailJSONParser.

Change route def in railjson

Route:

    {
      "id": "rt.C1-S7",
      "entry_point": "buffer_stop_b",
      "switches_position": {
        "il.switch_foo": "RIGHT"
      },
      "release_groups": [
        [
          "tvd.track"
        ],
        [
          "tvd.switch_foo"
        ]
      ]
    }

Signal:

{
  "expr": {
    "type": "call",
    "function": "warn_signal",
    "arguments": [
      {
        "type": "signal",
        "signal": "il.sig.C6"
      }
    ]
  },
  "id": "il.sig.W4",
  "applicable_direction": "REVERSE",
  "position": 1025,
  "sight_distance": 400,
  "linked_detector": "tde.foo_a-switch_foo"
}

Railjson:

  • Suppress waypoints field
  • Add entry_point. Takes a waypoint.
  • Add field linked_detector for signal. This field is optional.

Core:

  • RouteGraph.makeRoute() must retrieve TVDSectionPath from entryPoint and tvdSections.
  • If entry_point is a detector then we must have at least one signal linked to it.

RailML:

  • Adapt railml parser.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.