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

Uploaded Source

File details

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

File metadata

  • Download URL: l2f-2.0.6.tar.gz
  • Upload date:
  • Size: 268.6 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.6.tar.gz
Algorithm Hash digest
SHA256 0ba1baf1f7f850daf2a6590372a32705a910009566fcd5ab7fc1a02c2174d2d7
MD5 c5e4829ec619479b9be767872453ab33
BLAKE2b-256 2ed64e1609bdfd5671b7474e41bad0a792c479751c20c2335aed4537f4253ce0

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