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.10.tar.gz (462.1 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: l2f-2.0.10.tar.gz
  • Upload date:
  • Size: 462.1 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.10.tar.gz
Algorithm Hash digest
SHA256 b9f45c1675ca3bf6bea3a6f8c3e6cb98e62fb2f6f93c6aa9f08511652bda3cdc
MD5 6cc6d258fb3c3597be4232f5180847f7
BLAKE2b-256 f2233ef79ca5052c911167043a59cb06a99e70df079c2c3d98e768358f5b6774

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