Elodin is a platform for rapid design, testing, and simulation of drones, satellites, and aerospace control systems.
Quick Demo: https://app.elodin.systems/sandbox/hn/cube-sat
Sandbox Alpha: https://app.elodin.systems
Docs (WIP): https://docs.elodin.systems
This repository is a collection of core libraries:
libs/nox
: Tensor library that compiles to XLA (like JAX, but for Rust).libs/nox-ecs
: Rust ECS framework built to work with JAX and Nox, that allows you to build your own physics engine.libs/nox-py
: Python version ofnox-ecs
, that works with JAXlibs/nox-ecs-macros
: Derive macros to generate implementations of ECS and Nox traits.libs/conduit
: Column-based protocol for transferring ECS data between different systems.libs/xla-rs
: Rust bindings to XLA's C++ API (originally based on https://github.com/LaurentMazare/xla-rs).
Join us on Discord: https://discord.gg/agvGJaZXy5!
- Install Rust using https://rustup.rs
- Setup a new venv with:
python3 -m venv .venv
. .venv/bin/activate.fish # or activate.sh if you do not use fish
- Install
elodin
, andmatplotlib
with
pip install libs/nox-py
pip install matplotlib
- Try running the following code
import matplotlib.pyplot as plt
import jax.numpy as np
from elodin import *
@system
def gravity(q: Query[WorldPos]) -> Query[Force]:
return q.map(Force, lambda _p: Force.from_linear(np.array([0.0, -9.81, 0.0])))
@system
def bounce(q: Query[WorldPos, WorldVel]) -> Query[WorldVel]:
return q.map(WorldVel, lambda p, v: jax.lax.cond(
jax.lax.max(p.linear()[1], v.linear()[1]) < 0.0,
lambda _: WorldVel.from_linear(v.linear() * np.array([1.,-1.,1.]) * 0.85),
lambda _: v,
operand=None
))
w = WorldBuilder()
w.spawn(
Body(
world_pos=WorldPos.from_linear(np.array([0.0, 10.0, 0.0])),
world_vel=WorldVel.from_linear(np.array([0.0, 0.0, 0.0])),
inertia=Inertia.from_mass(1.0),
)
)
client = Client.cpu()
exec = w.build(bounce.pipe(six_dof(1.0 / 60.0, gravity)))
t = range(500)
pos = []
for _ in t:
exec.run(client)
y = exec.column_array(Component.id(WorldPos))[0, 5]
pos.append(y)
fig, ax = plt.subplots()
ax.plot(t, pos)
plt.show()
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.