# Server setup

This is what you need on the GVL lab box (or wherever you run training)
before any of the scripts work.

## Python env

```bash
# Use Cameron's existing torch124 env if you can:
conda activate /data2/cameron/miniconda3/envs/torch124

# Or a fresh one:
conda create -n para_panda python=3.10 -y
conda activate para_panda
conda install pytorch torchvision pytorch-cuda=12.4 -c pytorch -c nvidia -y

# Repo deps
pip install -r requirements.txt           # roslibpy etc.
pip install wandb tqdm opencv-python h5py scipy mujoco mink imageio
```

## DINOv3 weights

The PARA model loads a custom DINOv3 ViT-S/16 variant from local weights:

```bash
export DINO_REPO_DIR=/data/cameron/keygrip/dinov3
export DINO_WEIGHTS_PATH=/data/cameron/.cache/torch/hub/checkpoints/dinov3_vits16plus_pretrain_lvd1689m-4057cbaa.pth
```

If those paths don't exist on your box, ask Cameron — or copy the
`dinov3` directory from a working machine.

## ROS bridge to the robot

The Panda lives on a remote machine reachable via ngrok. To get joint
states + commanded positions flowing:

```bash
cd panda_streaming
./scripts/start_robot_server.sh <ngrok_host> <ngrok_port>
```

This brings up three tmux sessions on your local box:

| tmux session | What it runs |
|---|---|
| `panda_tunnel` | SSH tunnel: `localhost:9090` → remote rosbridge `9090` |
| `panda_rosbridge` | rosbridge_server (websocket on 9090) |
| `panda_driver` | Franka FR3 driver (`arm_id:=fr3 load_gripper:=true`) |

Wait for `panda_driver` to print `Successfully connected to robot` and
`Configured and activated joint_state_broadcaster` before any client
script runs.

Connection details (host, port, current ngrok address) are in
`/data/cameron/agents_stuff/agents/panda/connection.txt`. Cameron updates
that file when ngrok rotates.

## RealSense camera server

The RealSense lives on the robot box. Start it there (Cameron handles
this — agents in the fleet have a memory note that the panda agent
should always start `camera_server.py` itself rather than ask).

## wandb

```bash
wandb login
```

All training runs go to project `para_panda`.

## Quick sanity check

After setup, you should be able to:

```bash
# 1. MuJoCo viewer with live joint states (no camera)
python panda_streaming/stream_panda_with_vis.py

# 2. Model loads + DINO weights resolve
python -c "
import sys; sys.path.insert(0, 'para')
import importlib.util
spec = importlib.util.spec_from_file_location('m', 'para/model.py')
m = importlib.util.module_from_spec(spec); spec.loader.exec_module(m)
m.TrajectoryHeatmapPredictor()
"
```

If those two work, you're set up.
