Skip to main content

Python bindings for the L2F (Learning to Fly) Simulator

Project description

L2F: Learning to Fly Simulator

pip install l2f

This repo contains Python bindings for the simulator introduced in Learning to Fly in Seconds.

Please check the example for how to use it.

CUDA

For the CUDA usage please refer to rl-tools/l2f-benchmark

Getting Started

pip install l2f ui-server
ui-server
import l2f
import asyncio, websockets, json
device = l2f.Device()
rng = l2f.Rng()
env = l2f.Environment()
ui = l2f.UI()
params = l2f.Parameters()
state = l2f.State()
next_state = l2f.State()
l2f.initialize_environment(device, env)
l2f.initialize_rng(device, rng, 0)
l2f.sample_initial_parameters(device, env, params, rng)
l2f.initial_state(device, env, params, state)
async def main():
    uri = "ws://localhost:13337/backend"
    async with websockets.connect(uri) as websocket:
        handshake = json.loads(await websocket.recv(uri))
        assert(handshake["channel"] == "handshake")
        namespace = handshake["data"]["namespace"]
        ui.ns = namespace
        ui_message = l2f.set_ui_message(device, env, ui)
        parameters_message = l2f.set_parameters_message(device, env, params, ui)
        await websocket.send(ui_message)
        await websocket.send(parameters_message)
        for _ in range(100):
            action = [1, 0, 0, 0]
            dt = l2f.step(device, env, params, state, action, next_state, rng)
            state.assign(next_state)
            state_action_message = l2f.set_state_action_message(device, env, params, ui, state, action)
            await websocket.send(state_action_message)
            await asyncio.sleep(dt)
if __name__ == "__main__":
    asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

l2f-2.0.9.tar.gz (461.9 kB view details)

Uploaded Source

File details

Details for the file l2f-2.0.9.tar.gz.

File metadata

  • Download URL: l2f-2.0.9.tar.gz
  • Upload date:
  • Size: 461.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for l2f-2.0.9.tar.gz
Algorithm Hash digest
SHA256 a694b19fa0b55e875a45e1528e38a4a63a368d35a727b09eb3e837c5a47c4d50
MD5 4fea3620ed391aee11dd7302d0ddadc7
BLAKE2b-256 0b148eaeebcbda6c2490b0e0fceb2602a6fe505d73491bce58eb4422dd54ce9e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page