Spaces:
Sleeping
Sleeping
File size: 8,219 Bytes
4935703 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | # Universal terminal execution guide
This guide walks a brand-new user from a clean clone to a working
simulation, in any of the supported terminal environments:
| Shell / environment | Verified |
|---|---|
| Windows **PowerShell 5.1 & 7+** | β
|
| Windows **CMD (cmd.exe)** | β
|
| **Git Bash** for Windows | β
|
| Linux **bash** / **zsh** | β
|
| macOS **bash** / **zsh** | β
|
| **VSCode integrated terminal** | inherits from above |
| Remote **SSH** terminal | inherits from above |
| Cloud notebook terminals (Colab, Kaggle, HF Spaces) | β
|
The simulator is **pure Python** above NumPy and SciPy β every
verified path uses identical Python invocations. The only differences
between shells are how you set environment variables and chain
commands.
---
## Step 1 β Prerequisites
* **Python 3.10, 3.11, or 3.12** (CI is green on 3.11 and 3.12).
* **Git**.
* (Optional) a clean virtual environment.
Check what you have:
```powershell
# PowerShell / CMD
python --version
git --version
```
```bash
# bash / zsh
python3 --version
git --version
```
---
## Step 2 β Clone the repository
```powershell
# PowerShell
git clone https://github.com/Tachia/cdpr_simulator.git
cd cdpr_simulator
```
```bash
# bash / zsh
git clone https://github.com/Tachia/cdpr_simulator.git
cd cdpr_simulator
```
CMD users: same commands, no changes.
---
## Step 3 β Create and activate a virtual environment
A `venv` is recommended (keeps the project's deps separate from system
Python). It is not strictly required β system Python with the right
packages works too.
### PowerShell
```powershell
python -m venv .venv
.\.venv\Scripts\Activate.ps1
# If activation is blocked by execution policy:
# Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
```
### Windows CMD
```cmd
python -m venv .venv
.\.venv\Scripts\activate.bat
```
### Linux / macOS / Git Bash
```bash
python3 -m venv .venv
source .venv/bin/activate
```
After activation `which python` (bash) or `Get-Command python`
(PowerShell) should point inside `.venv`.
---
## Step 4 β Install the package
Pick the install profile matching what you want to do.
### Minimum (CLI simulation + plots)
```bash
# Works in every shell above:
python -m pip install --upgrade pip
python -m pip install -e ".[viz,data,api]"
```
### + Streamlit local GUI
```bash
python -m pip install -e ".[viz,data,api,gui]"
```
### + Gradio local GUI
```bash
python -m pip install -e ".[viz,data,api,gradio]"
```
### + Data-driven training (PINN / MLP / PPO / SAC)
```bash
python -m pip install -e ".[viz,data,api,learn,rl]"
```
### Everything
```bash
python -m pip install -e ".[all]"
# then individually add gui and/or gradio if you want them:
python -m pip install -e ".[gui,gradio]"
```
---
## Step 5 β Run a built-in example end-to-end
```powershell
# PowerShell
python scripts\run_example.py --list
python scripts\run_example.py --name circle --open
```
```bash
# bash / zsh / Git Bash / CMD
python scripts/run_example.py --list
python scripts/run_example.py --name circle
```
The example produces `out/example-circle/` containing 14 figures +
`timeseries.csv` + `manifest.json` + `feasibility.json`. The `--open`
flag (PowerShell only) opens the folder in Explorer.
Other examples:
```bash
python scripts/run_example.py --name spiral # 6-DoF helical spiral
python scripts/run_example.py --name mshape # pick-and-place letter M
python scripts/run_example.py --name train # Phase-2 PINN
python scripts/run_example.py --name compare # Phase-2 multi-model bench
```
---
## Step 6 β Run a custom Phase-1 simulation
Direct simulation with CLI flags:
```powershell
# PowerShell (back-tick line continuations)
python scripts\run_simulation.py `
--robot dissertation_8cable `
--kind circle --radius 0.05 --duration 12 --dt 1e-3 `
--controller pd --kp-pos 400 --kp-rot 100 `
--t-min 5 --t-max 500 `
--out out\my-run --open
```
```bash
# bash / zsh (backslash continuations)
python scripts/run_simulation.py \
--robot dissertation_8cable \
--kind circle --radius 0.05 --duration 12 --dt 1e-3 \
--controller pd --kp-pos 400 --kp-rot 100 \
--t-min 5 --t-max 500 \
--out out/my-run
```
Heavy industrial scenario from a JSON robot config:
```bash
python scripts/run_simulation.py \
--robot-config examples/robots/industrial_heavy.json \
--kind circle --radius 1.0 --duration 20 \
--t-min 50 --t-max 5000 \
--out out/industrial-circle
```
Run `python scripts/run_simulation.py --help` for the full flag list.
---
## Step 7 β Phase-2 CSV training / comparison
Single PINN fit on a CSV the simulator just produced:
```bash
python scripts/train_from_csv.py \
--input out/example-circle/timeseries.csv \
--model pinn --epochs 80
```
Single model from a **URL**:
```bash
python scripts/train_from_csv.py \
--input "https://example.com/data.csv" \
--model mlp --epochs 60
```
Multi-model comparison:
```bash
python scripts/compare_models.py \
--input out/example-circle/timeseries.csv \
--out out/compare \
--models replay mlp pinn ppo sac \
--epochs 60 --rl-steps 2000 --eval-episodes 2
```
CSV with non-standard column names? Supply an explicit mapping:
```bash
python scripts/train_from_csv.py \
--input data.csv --model pinn \
--column-map "px=Position X,py=Position Y,pz=Position Z"
```
Interactive PowerShell wrapper (prompts for CSV + model menu):
```powershell
.\scripts\train_interactive.ps1
```
---
## Step 8 β Launch a GUI
### Streamlit (local dev)
```bash
streamlit run streamlit_app.py
# open http://localhost:8501
```
### Gradio (local β recommended for casual use)
```bash
python gradio_app.py
# open http://localhost:7860
```
### FastAPI backend (local)
```bash
uvicorn cdpr.interface.api:app --reload --port 8000
# open http://localhost:8000/docs
```
These all run in-process against the cdpr scientific core; you can
launch them concurrently in three terminals if you want all three
URLs alive at once.
---
## Step 9 β Diagnostics & troubleshooting
```bash
# Check the cdpr import + version + which Python loaded it
python -c "import cdpr; print(cdpr.__file__)"
# Run the test subset that CI also runs:
python -m pytest tests/ -q \
--ignore=tests/test_learn_env.py \
--ignore=tests/test_learn_supervised.py \
--ignore=tests/test_learn_benchmark.py \
--ignore=tests/test_learn_rl_factories.py \
--ignore=tests/test_adapters_mujoco.py
# Probe which extras are installed
python -c "import importlib.util as u; print({k: bool(u.find_spec(k)) for k in ('torch','gymnasium','stable_baselines3','streamlit','gradio')})"
# Hit the deployed FastAPI for liveness
# PowerShell:
.\scripts\call_render.ps1 -Action health
# bash:
curl -s https://cdpr-api.onrender.com/health
```
Common pitfalls:
| Symptom | Cause | Fix |
|---|---|---|
| `python: command not found` on macOS | macOS ships `python3` not `python` | Use `python3` (or `alias python=python3` in your shell rc) |
| `Activate.ps1 cannot be loaded` | PowerShell execution policy | `Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned` |
| `ModuleNotFoundError: cdpr` | Forgot `-e .` install | Re-run Step 4 |
| Cold first call to Render API takes ~50 s | Free-tier sleep after 15 min idle | First call wakes the worker; subsequent calls are 200-300 ms |
| `torch` not installed warning | Phase-2 model needs the `learn` extra | `pip install -e ".[learn,rl]"` |
| `tracking_error` plot fails with `\lVert` | Pre-2026-05-28 commit | `git pull` |
---
## One-page cheat sheet
```bash
# Clean clone to first sim in under 10 minutes.
git clone https://github.com/Tachia/cdpr_simulator.git
cd cdpr_simulator
python -m venv .venv
# Activate per your shell (see Step 3)
python -m pip install -e ".[viz,data,api]"
python scripts/run_example.py --name circle
ls out/example-circle/ # 14 PNGs + CSV + manifest
```
---
## Cross-references
* `docs/frontend-architecture.md` β why Gradio is the recommended hosted GUI
* `docs/examples.md` β the 5 built-in examples
* `docs/csv-schema.md` β accepted CSV layouts + alias table
* `docs/runbook.md` β operational runbook
|