Skip to content

Session

API Reference - session

This module allows you to get the state and interact with the simulation.

session.run([speed])

Starts or resumes simulation with a given speed. If no speed is provided, simulation will run with speed=1. You can use large number (f32::MAX or Infinity) to run with unlimited speed.

await client.rpc('session.run')
await client.rpc('session.run', { speed: 4.0 })

session.pause()

Pauses simulation.

await client.rpc('session.pause')

session.step()

Runs one step, then pauses simulation.

await client.rpc('session.step')

session.restart()

Restarts simulation from the beginning. Map will also be reset, so you need to spawn objects again if needed.

await client.rpc('session.restart')

session.exit([code])

Exits simulator with a given code (in [0-255] range, 0 by default).

await client.rpc('session.exit')
await client.rpc('session.exit', { code: 1 })

session.state()

Returns current simulation state (time elapsed, current sim-to-real speed).

let state = await client.rpc('session.state')
// or subscribe
let sub = client.newSubscription('session.state')

Return value is a table with two fields:

  • time_us (u64) - time elapsed since start of simulation in microseconds
  • speed (f32) - current sim-to-real speed