Skip to main content

tau-ctrl

Simulator-agnostic control algorithms — feedback, sampling-based MPC, safety filtering, and GPU-native RL behind one interface.

A unified library for the whole controller spectrum, over any gymnasium.Env. No simulator dependency: works with whatever hands you an env (e.g. tau-sim). The RL methods train on-device and scale to vectorized environments for real GPU speedup.

Installation

pip install tau-ctrl            # PID, MPPI/CEM/iCEM, iLQR, CBF (numpy + scipy + gymnasium)
pip install tau-ctrl[torch]     # + RL: PPO, SAC, TD3, and vectorized on-device training

Usage

from tau_ctrl import make

ctrl = make("mppi", env, horizon=25, n_samples=300)   # or MPPI(env, ...), SAC(env), ...
action, _ = ctrl.predict(obs)                          # standard interface
ctrl.learn(total_timesteps=100_000)                    # trainable methods (ppo/sac/td3)
ctrl.save("ctrl.pkl")

Algorithms

Method Family Needs Notes
pid feedback obs only independent PID/PD over selected obs indices
mppi sampling MPC get_state/set_state Model-Predictive Path Integral; plans against the env's own reward; noise_beta>0 for smoother ("colored-noise") torques
cem sampling MPC get_state/set_state Cross-Entropy Method MPC
icem sampling MPC get_state/set_state Improved CEM — colored noise + elite memory across iterations
ilqr gradient MPC get_state/set_state Iterative LQR via finite-difference linearization; fast, precise convergence on smooth dynamics
cbf safety filter get_state/set_state wraps any base controller, projects its action to keep h(x) >= 0
ppo RL (on-policy) torch GPU-automatic via device="auto"
sac RL (off-policy) torch replay buffer + twin critics + auto entropy tuning; far more sample-efficient than PPO
td3 RL (off-policy) torch replay buffer + twin critics + delayed policy updates + target smoothing

Model-based methods (mppi/cem/icem/ilqr/cbf) need the env to be branchable (expose get_state() / set_state()) so they can roll candidate sequences forward without disturbing the live episode. All torch-based methods auto-select cuda when available (device="auto", including reproducible seeding of torch's RNG).

GPU-native RL: vectorized, on-device training

Standard pipelines step CPU environments sequentially and perform updates in slow Python loops. tau-ctrl's SAC/TD3 instead run the replay buffer and the update on the target device, and — given a batched env — step thousands of environments in parallel with no numpy in the hot loop. Trainer.auto probes your env and hardware and picks the fastest correct strategy, so the same call adapts across the whole env-reality spectrum:

import gymnasium as gym
from tau_ctrl import Trainer

# One line: probes env + hardware, wraps as needed, trains on the best engine.
model = Trainer.auto("sac", env=gym.make_vec("HalfCheetah-v4", num_envs=64),
                     total_timesteps=1_000_000)
action, _ = model.predict(obs)
You have Adapter GPU helps
native TorchVecEnv (or MJX/Brax via jax_to_torch, Isaac Gym) — (fits directly) env and update on-device — the real win
gymnasium.vector.VectorEnv GymVectorAdapter buffer + update on device (env stepping stays CPU)
a single, non-batchable env (PyBullet, classic MuJoCo) + a factory SyncTorchVecEnv batched update on device
one env you can't replicate (a real robot) — (single-env path) only the update

See benchmarks/RESULTS.md for performance comparison benchmarks, and examples/ for runnable scripts (quickstart.py, vectorized_rl.py, adaptive_training.py).

Safety filtering

# CBF wraps any base controller and only intervenes when a barrier is at risk
from tau_ctrl import CBFFilter, make

base = make("pid", env, kp=8.0, kd=5.0, target=[0.0], q_idx=[0], dq_idx=[1])
safe = CBFFilter(env, base=base, barriers=lambda state: v_max - state[1], alpha=0.5)
action, _ = safe.predict(obs)

Auto-tuning

from tau_ctrl import AutoTuner

tuner = AutoTuner({"kp": (1, 500), "kd": (0.1, 50)}, method="bayesian", n_iterations=50)
result = tuner.tune(cost_fn)   # cost_fn: dict of params -> scalar cost
print(result["best_params"])

Layout

src/tau_ctrl/
├── algorithms/   # base.py (interface + registry), off_policy.py (shared SAC/TD3 infra),
│   │             # pid.py, mppi.py (MPPI/CEM/ICEM), ilqr.py, cbf.py, ppo.py, sac.py, td3.py
│   │             # vec_env.py (TorchVecEnv), adapters.py, strategy.py (Trainer.auto)
│   └── envs/     # pure-Python toy envs for tests/examples
└── tuning/       # Bayesian & genetic auto-tuning

License

Apache 2.0 — see LICENSE.

  • tau-sim — robotics environment builder

Metadata

Release files for tau-ctrl 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tau-ctrl 0.2.0
File Size Uploaded Provenance Actions
tau_ctrl-0.2.0.tar.gz 44.0 kB Without provenance Details for tau_ctrl-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tau-ctrl 0.2.0
File Interpreter ABI Platform Actions
tau_ctrl-0.2.0-py3-none-any.whl Python 3 none any Details for tau_ctrl-0.2.0-py3-none-any.whl

Total release size: 97.4 kB

Release files / tau_ctrl-0.2.0.tar.gz

Download URL tau_ctrl-0.2.0.tar.gz
Size 44.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4c0a44c4c8563d11a55081e3215cd70a5da52b4f7079c3b4c98adc4a720840e0
BLAKE2b-256 checksum
How to use checksums
9ce440ed949877750a355bdac3d68eb1aa18fea513c9cbd3e99153f65506882f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Release files / tau_ctrl-0.2.0-py3-none-any.whl

Download URL tau_ctrl-0.2.0-py3-none-any.whl
Size 53.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
44b1f7366bf5f17600c0c8cb71be4ce583b33d5f49dcc7e2e28870a249f573b3
BLAKE2b-256 checksum
How to use checksums
9a63766166470344893b40bd86729bdf18768df01a55fc54cb11afd7f54208c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Security for tau-ctrl 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page