Add Python TrainSim with loop track map and physics.
FastAPI server, replaceable JSON config, tests, Dockerfile. Pairs with ATO via spec/interface.md contract. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
45c95836ef
commit
9c5ef3a5cd
18 changed files with 414 additions and 18 deletions
45
spec/interface.md
Normal file
45
spec/interface.md
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# ATO ↔ TrainSim interface (v1)
|
||||
|
||||
Standalone. No ETCS. No ATP. JSON over HTTP.
|
||||
|
||||
Base URL (TrainSim): `http://trainsim:8080`
|
||||
|
||||
## TrainSim → ATO reads
|
||||
|
||||
`GET /train/state`
|
||||
|
||||
```json
|
||||
{
|
||||
"speed_mps": 0.0,
|
||||
"position_m": 0.0,
|
||||
"track_length_m": 1000.0,
|
||||
"sim_running": false
|
||||
}
|
||||
```
|
||||
|
||||
## ATO → TrainSim writes
|
||||
|
||||
`POST /train/actuate`
|
||||
|
||||
```json
|
||||
{
|
||||
"traction_pct": 0,
|
||||
"brake_pct": 0
|
||||
}
|
||||
```
|
||||
|
||||
Percent 0–100. Do not send both > 0 (TrainSim clamps brake wins).
|
||||
|
||||
`POST /sim/start` — start physics tick (empty body)
|
||||
|
||||
`POST /sim/stop` — pause physics (empty body)
|
||||
|
||||
Optional (TrainSim logs only): `POST /train/doors` `{ "command": "open" | "close" }`
|
||||
|
||||
## ATO configuration (env)
|
||||
|
||||
| Variable | Meaning |
|
||||
|----------|---------|
|
||||
| `TRAINSIM_URL` | TrainSim base URL |
|
||||
| `TARGET_SPEED_MPS` | Cruise target (default 10) |
|
||||
| `TICK_MS` | Control period (default 100) |
|
||||
Loading…
Add table
Add a link
Reference in a new issue