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.0.tar.gz (48.9 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.0-py3-none-any.whl (65.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ssl_simulator-1.0.0.tar.gz
  • Upload date:
  • Size: 48.9 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.0.tar.gz
Algorithm Hash digest
SHA256 6585825f65e649d4fb1a33abdd39a348ecd67cf74cf8ea03c07c17ffac125135
MD5 d8440cdbe92f5ef893ceb129f5efa797
BLAKE2b-256 13904daa5caecedadcacc4dbb748f7d20a12095f09c345e52274b7ac7ed83ef9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ssl_simulator-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 65.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c22ad97026d01158fc52ce856e14276e9c6af6b5594aef584816496f4fb65558
MD5 d6e6a9cf29d591b8445812fcba94e63c
BLAKE2b-256 1389c348e67e5386c3babbb437e6dfff0812d4b9ee6bf06ff15e2c729e18de6b

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