sdsandbox-rl-scripts/README.md

102 lines
3.3 KiB
Markdown

# sdsandbox-rl-scripts
Modified C# scripts for the sdsandbox Unity simulator, used with the
[donkeycar-rl-autoresearch](https://git.paje.ca/paulh/donkeycar-rl-autoresearch) RL training project.
## What's here
- `Scripts/` — all C# scripts from `sdsim/Assets/Scripts/`, including our RL training modifications
- `ProjectSettings/` — Unity project settings
- `Packages/` — Unity package manifest
Binary assets (textures, models, scenes) are **not** included here — they come from the
upstream sdsandbox repo. See **Setup** below.
## Key modifications (vs upstream tawnkramer/sdsandbox)
- **`Car.cs`** — per-wheel OverlapSphere barrier collision detection; CCD tunneling prevention
- **`TcpCarHandler.cs`** — `regen_road` TCP message with direct RoadBuilder+PathManager fallback
when no TrainingManager is present; `set_ai_text` overlay message; BrakeOnUpdate support
- **`PathManager.cs`** — self-intersection fix: retry loop with XZ segment-segment math (up to 20 retries)
- **`RoadBuilder.cs`** — BoxCollider per segment with overlap to close corner gaps; `showBarrierMeshes` flag
- **`MapOverlay.cs`** — minimap refreshes on road node position change (not just node count)
## Setup on a new machine
### Step 1 — SSH access to paje.ca (one-time)
Generate an SSH key if you don't have one:
```bash
ssh-keygen -t ed25519 -C "your-name@your-machine"
```
Copy the public key:
```bash
cat ~/.ssh/id_ed25519.pub
```
Add it to Gitea: log in at **https://git.paje.ca** → Settings → SSH / GPG Keys → Add Key.
Test it:
```bash
ssh -T git@paje.ca
# Expected: Hi there, paulh! You've successfully authenticated...
```
### Step 2 — Clone both repos
Clone the upstream sdsandbox (provides all binary assets Unity needs):
```bash
git clone https://github.com/tawnkramer/sdsandbox
```
Clone this repo:
```bash
git clone git@paje.ca:paulh/sdsandbox-rl-scripts.git
```
### Step 3 — Overlay our scripts
```bash
cp -r sdsandbox-rl-scripts/Scripts/* sdsandbox/sdsim/Assets/Scripts/
cp -r sdsandbox-rl-scripts/ProjectSettings/* sdsandbox/sdsim/ProjectSettings/
cp -r sdsandbox-rl-scripts/Packages/* sdsandbox/sdsim/Packages/
```
### Step 4 — Open in Unity
Open `sdsandbox/sdsim` in **Unity 6000.4.4f1**. Unity will reimport assets on first open
(takes a few minutes).
Other Unity versions are not tested and may have incompatible APIs.
### Step 5 — Build the simulator
Run the batch build from WSL:
```bash
"/mnt/c/Program Files/Unity/Hub/Editor/6000.4.4f1/Editor/Unity.exe" \
-quit -batchmode \
-projectPath "C:/path/to/sdsandbox/sdsim" \
-executeMethod PlayerBuilder.WinBuild \
-logFile "C:/Users/YourName/AppData/Local/Temp/unity_rebuild.log"
```
Build output lands in `sdsim/Builds/DonkeySimWin/`. Copy the `Assembly-CSharp.dll`
from **that folder** (not `Library/ScriptAssemblies/`) to the runtime sim folder:
```bash
rsync -av "sdsim/Builds/DonkeySimWin/donkey_sim_Data/Managed/Assembly-CSharp.dll" \
"/path/to/DonkeySimWin/donkey_sim_Data/Managed/Assembly-CSharp.dll"
```
## Keeping scripts up to date
To pull the latest script changes onto an existing sdsandbox clone:
```bash
cd sdsandbox-rl-scripts && git pull
cp -r Scripts/* ../sdsandbox/sdsim/Assets/Scripts/
cp -r ProjectSettings/* ../sdsandbox/sdsim/ProjectSettings/
cp -r Packages/* ../sdsandbox/sdsim/Packages/
```
Then rebuild in Unity (Step 5 above).