Help

Principles of Free Driving

This is RailKernel’s implementation of Koploper’s Free Driving method. Free Driving lets a group of placed trains move dynamically around the layout. Triplets describe physically valid movements; a central dispatcher decides which train moves next and uses RailKernel’s existing routing and safety controls.

1. Triplets as building blocks

A Triplet describes one valid movement: previous block → current block → next block. Three blocks unambiguously establish the direction through the middle block. Triplets are generated only through Free Driving → Check Layout, so opening a project remains fast.

  • Follows every physically possible path between blocks.
  • Respects turnouts, crossings and block directions.
  • Treats a turntable as a terminus for now.
  • Prevents reversal inside the middle block.
  • Generates only physically valid Triplets.

2. Usable and ignored blocks

Only blocks with Usable enabled participate in Free Driving as blocks. A block without feedback is automatically made unusable. The Triplet generator ignores such a block completely: it is not A, B or C and receives no Triplets of its own. Its rails remain part of the physical corridor to the next usable block, as if no block had been defined there. A dead-end block may be a starting point or destination, but can never be the middle block B of a Triplet. Check Layout reports how many unusable blocks and dead-end middle blocks were skipped.

  • Usable off: never A, B or C.
  • The rails remain traversable as an intermediate corridor.
  • A dead-end track is never used as B.
  • The generation report shows the skipped counts.

3. Triplet properties

Defaults are derived from the three participating blocks. Only explicit user changes are stored in the project.

  • Enabled.
  • Priority.
  • Weight or probability.
  • Maximum speed.
  • Minimum and maximum train length.
  • Allowed train types.
  • Comment.

4. Storage, regeneration and obsolete settings

Triplets themselves are derived runtime objects and are not stored as complete objects in the project. Only Triplet properties explicitly changed by the user are retained, associated with a stable key containing the GUIDs and traversed sides of A, B and C. These settings are loaded when a project is opened but are not validated yet, because current Triplets deliberately have not been generated at that point. Free Driving → Check Layout first regenerates every Triplet and subsequently applies stored settings to exactly matching stable keys.

  • Valid stored settings are retained and applied.
  • Settings without a match are reported as orphaned with A–B–C, sides and key.
  • After the report, orphaned settings are removed from the project model.
  • The project is marked as changed; the data disappears from the XML on the next save.
  • Current geometry and block directions always take precedence.

5. When does this happen?

A stored Triplet setting becomes orphaned when the movement for which it was defined no longer exists with exactly the same stable key after regeneration. Its properties cannot safely be restored: they described one specific physical movement and direction, not merely three block names. RailKernel therefore never applies them approximately to another Triplet.

  • The geometric direction of A, B or C was reversed, changing the traversed entrance or exit.
  • The BOTH/FORWARD_ONLY direction mode changed, removing or introducing a permitted direction.
  • A participating block was detached or deleted.
  • Usable was disabled, for example because a block no longer contains feedback; Free Driving then ignores that block.
  • Track, turnouts, crossings or connections changed, altering the physical corridor or reachability.
  • A block was reattached or regenerated with another GUID or different boundary connectors.
  • After such a change, no exact match remains for A, B, C and their traversed sides; automatic transfer could attach properties to the wrong movement.

6. Trains participating in Free Driving

The user selects a set of placed trains that may participate in Free Driving.

  • The train is correctly placed.
  • It is not already moving.
  • It is not defective, blocked or deadlocked.
  • A valid Triplet exists in its current direction.
  • It satisfies the participating block and Triplet restrictions.

7. The Free Driving Dispatcher

One central dispatcher determines which train receives the next movement.

  • Available Triplets and block directions.
  • Train and block restrictions, train length and train type.
  • Electrification.
  • Triplet priority and weight.
  • Existing reservations.
  • Waiting time since the previous movement.
  • Potential conflicts and deadlocks.

8. The relay principle

Free Driving does not mean that one fixed group runs continuously. A pool contains waiting trains and a configurable limit controls how many may move simultaneously.

  • Trailing reservations are released after arrival.
  • The arriving train returns at the back of the waiting pool.
  • Another suitable train receives the released movement slot.
  • Trains alternate and the same train does not continually receive priority.

9. Selecting the next movement

The dispatcher finds every valid Triplet from the current position and direction, removes those that cannot be executed, and selects from the remainder. A planned movement may end only in a block where the train is allowed to stop according to the block settings. Station blocks are normal stopping places; other blocks must be explicitly marked for stopping. An emergency or safety stop remains possible in every block.

  • A required block or accessory is unavailable.
  • Block direction, train length, train type or electrification rejects the movement.
  • The destination block is not an allowed stopping place for this train.
  • The movement creates a reservation conflict or known deadlock.
  • Selection uses priority, waiting time, weight or randomness and a preference for variety.
  • Recently used blocks and repetitive shuttling can be avoided.

10. Reservation and execution

The movement is reserved atomically: either every required component is reserved, or none is. If any component fails, the attempt is rolled back and another Triplet or train is tried. During generation, corridors A → B and B → C are recorded together with their track and accessories. The required position of each turnout is derived from the connectors actually traversed, including a train approaching from a branch. Points are therefore always set in advance and are never trailed open by the train.

  • Blocks A, B and C according to the current movement phase.
  • All required intermediate track.
  • Accessories inside the blocks and corridors A → B and B → C.
  • The required state of every normal, curved, three-way and double-slip turnout.
  • An optional following safety section.
  • Existing route, feedback, speed, braking, stopping and safety logic executes the movement.

11. Sharp release

Free Driving uses sharp release by default. Block A, accessories in A and corridor A → B are held no longer than necessary. As soon as feedback in B and the known train position prove that the complete train, including its rear, is inside B, these trailing reservations are released atomically. B and corridor B → C remain reserved. A following train can consequently use the released pointwork quickly and safely. If train length or position cannot be established reliably, RailKernel conservatively releases nothing yet.

  • The entire train, not merely its front, must be inside B.
  • Train length, direction and geometric position determine the release moment.
  • A and A → B are released together.
  • B and B → C remain protected.
  • When uncertain, safety takes precedence over throughput.

12. Arrival in the next block

The first implementation makes a fresh decision after every Triplet. This is simple, safe and dynamic. The train continues when the block is not an allowed stopping place and another safe Triplet is available. Planned stops and waiting take place in station blocks and other blocks explicitly marked as stopping places. A future movement may optionally join several Triplets.

  • The train stops at an allowed stopping place when required.
  • A safety or emergency stop may always be made regardless of the marker.
  • Trailing reservations are released.
  • Position and direction are updated.
  • Relevant events and RailScripts run.
  • After any dwell time, the train becomes available again.

13. Waiting and deadlocks

If a train has no valid Triplet, it waits while the dispatcher tries another train. Availability is reconsidered when blocks or accessories change. If no participant can move, the Train Monitor reports DEADLOCKED.

  • Inspect the situation.
  • Move a train manually or release a reservation.
  • Find an alternative route or disable a Triplet.
  • Stop the Free Driving session.

14. The role of RailScript

RailScript is optional; Free Driving requires no script. Scripts can nevertheless react to its events.

  • Departure, block entry and block exit.
  • Movement start, completion or abortion.
  • Train stop, deadlock or emergency stop.
  • Operate sounds and lighting, display messages, change variables or start other scripts.

15. Summary

Triplets describe what is physically possible. The dispatcher decides which waiting train moves next. Existing RailKernel routing reserves and executes the movement safely. This provides Koploper-style Free Driving based on explicit geometry, visible Triplets, verifiable constraints, dynamic reservations and RailScript events.

  • Triplets describe valid movements.
  • The dispatcher and relay principle provide fair alternation.
  • Reservations prevent conflicts.
  • Feedbacks determine the real train position.
  • A new decision follows every movement.
  • The Train Monitor shows waiting, running and deadlocked states.