Skip to main content

Swarm Systems Lab Python Simulator

Project description

ssl_simulator

Swarm Systems Lab Python Simulator - a data-oriented (ECS) simulation core for multi-agent robotics research.

All mutable simulation data lives in a World as struct-of-arrays component arrays. Behaviour is System callables that mutate those arrays in place, vectorized over the N agents. A scheduler orders systems by their declared reads/writes, and a thin Engine ticks them and logs.

Full documentation is in docs/ - start with architecture and usage.

Installation

Requires Python >= 3.12.

pip install ssl_simulator

Optional extras - pip install ssl_simulator[all] gets everything:

Extra What it adds
lie SO(3) state and Lie-group retraction (via lieplusplus)
fields Scalar fields (scipy)
hdf5 HDF5 logging and I/O
examples Dependencies for running examples/

Quick example

A swarm of single integrators driven to the origin. A controller is just a system that writes a command component:

import numpy as np
from ssl_simulator import Engine, System, World, load_sim
from ssl_simulator.robot_models import single_integrator


class GoToOrigin(System):
    reads, writes = ("p",), ("u",)

    def __init__(self, gain):
        self.gain = gain

    def run(self, world, dt):
        world["u"][:] = -self.gain * world["p"]   # vectorized over all N agents


world = World(n=5)
integrator = single_integrator(world, state="p", cmd="u",
                               init=np.random.default_rng(0).random((5, 2)))
world.add_system(GoToOrigin(gain=1.0))
world.add_system(integrator)

Engine(time_step=0.01, log_filename="run.csv", log_time_step=0.1).run(world, duration=5.0)

data, settings = load_sim("run.csv")   # logged names are flat: data["p"] -> (T, 5, 2)

Quick Setup (Examples & Development)

Make sure uv and just are installed:

curl -LsSf https://astral.sh/uv/install.sh | sh
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to ~/.local/bin

Both installers add themselves to ~/.local/bin, make sure that's on your PATH.

git clone https://github.com/Swarm-Systems-Lab/ssl_simulator
cd ssl_simulator

# One-command setup (installs ssl-pydev, creates .venv, installs dependencies)
just setup

# Optional: Install all extras for development
just sync

Common tasks - run just --list for the rest:

just test         # run the test suite
just lint         # ruff format + check
just docs         # serve the docs at http://localhost:8000

Examples

See the examples/ directory - it's a guided tour of the ECS core, meant to be read in order.

just example
# Or directly:
uv run python examples/basic_usage.py

Visualization

Visualization lives in the separate ssl_vista package, which reads the logged data directly.

License

MIT

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

ssl_simulator-1.0.1.tar.gz (44.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ssl_simulator-1.0.1-py3-none-any.whl (61.6 kB view details)

Uploaded Python 3

File details

Details for the file ssl_simulator-1.0.1.tar.gz.

File metadata

  • Download URL: ssl_simulator-1.0.1.tar.gz
  • Upload date:
  • Size: 44.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for ssl_simulator-1.0.1.tar.gz
Algorithm Hash digest
SHA256 80ab82d5833d4cd86ba629d227e1c382e36f64c53c65c8bc6ade50665f7ba0fc
MD5 d612e4ffede2d2b6fe5c00213064d93c
BLAKE2b-256 bc962401b9d9fa1807093cf3a2f0afb113bea1b77a1f37c520ad2a440b04b7f3

See more details on using hashes here.

File details

Details for the file ssl_simulator-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ssl_simulator-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 61.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for ssl_simulator-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 674cbeaa2e02f96bf6148ea9be0302a1919ec259a8f54976e79976b1cd240e1a
MD5 298d2dacc4dc19ca59c5a556ec98f5df
BLAKE2b-256 6bf27b2715a72953b0cf1337ee2a0a45efdb88842b28acf5ca03a034cffd8358

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