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

Uploaded Source

File details

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

File metadata

  • Download URL: l2f-2.0.7.tar.gz
  • Upload date:
  • Size: 326.8 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.7.tar.gz
Algorithm Hash digest
SHA256 0e0bc67fc87ad0fe96e2e2638977808f7b45db8a582e29214e0b9c9b44f59019
MD5 24fae43077890a8badd03480de38b1ca
BLAKE2b-256 7b3833178d57f667efa0f6d7e4a3b09f60da120d73dc6d1e1bbf3dafd8dc63ec

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