TurtleBot3 JEPA + PPO navigation policy (v6)
A PPO navigation policy for a TurtleBot3 Burger in the ROBOTIS Stage 3 arena with four moving obstacles. It drives to a goal and avoids the obstacles using a 360° lidar. The policy combines:
- the frozen LiDAR V-JEPA encoder, which embeds the last 4 s of lidar;
- small frozen risk / clearance heads that reduce the 1024-D embedding to 16 numbers: for 8 directions, the probability that an obstacle comes within 0.25 m during the next second, and the predicted free space there;
- a PPO policy (MLP 256-256) on the 74 classic inputs plus those 16;
- a collision shield that blocks actions heading into a direction whose risk is above 0.8.
last 20 lidar scans ─► JEPA encoder (frozen) ─► 1024 ─► risk/clearance heads (frozen) ─► 8 risk + 8 clearance
goal distance + angle + 3 × 24 front beams (74) ───────────────────────────────────────────────┤
90 ─► PPO MLP 256-256 ─► 5 action scores
collision shield: mask actions whose direction risk > 0.8 ─► action
Actions: 5 discrete turn rates at a constant 0.20 m/s: ω = +1.5, +0.75, 0, −0.75, −1.5 rad/s (+ = left). The control period is 0.1 s.
Files
| File | What it is |
|---|---|
v6_seed0_maskableppo.zip, v6_seed1_maskableppo.zip | The two trained policies in sb3-contrib MaskablePPO format (for evaluation or fine-tuning) |
v6_seed{0,1}_policy.safetensors | The same policy and value weights as plain tensors (no pickle) |
heads.safetensors | The frozen risk / clearance heads (MLP 1024-256-256-16) |
policy_config.json | Observation layout, actions, shield, reward, PPO settings, evaluation results |
tb3_jepa_agent.py | Standalone agent: raw lidar + goal → action, torch + numpy + safetensors only |
example.py | Downloads both repos and runs the agent on a synthetic scene |
training_code/ | The Gazebo / ROS 2 environment, trainer and heads trainer used (reference) |
figures/ | Evaluation and training plots |
Quick start (no ROS needed)
from huggingface_hub import snapshot_download
import sys
policy_dir = snapshot_download('penji2803/tb3-jepa-ppo-v6')
jepa_dir = snapshot_download('penji2803/lidar-vjepa-turtlebot3')
sys.path.insert(0, policy_dir)
from tb3_jepa_agent import V6Agent
agent = V6Agent.load(policy_dir, jepa_dir, seed=0)
agent.reset() # at the start of every episode
a = agent.act(scan360, goal_dist, goal_angle, new_scan=True) # every 0.1 s
cmd_v, cmd_w = V6Agent.SPEED, V6Agent.ANG_VEL[a]
Inputs:
scan360: 360 lidar ranges in metres. Ray i is at i·6.28/359 rad: 0 is straight ahead and angles increase counter-clockwise. Mapinfto 3.5.- The lidar runs at 5 Hz and control at 10 Hz, so pass
new_scan=Falsewhen the scan hasn't changed. goal_distandgoal_angleare relative to the robot (angle positive = goal to the left).
With stable-baselines3:
from sb3_contrib import MaskablePPO
model = MaskablePPO.load('v6_seed0_maskableppo.zip')
action, _ = model.predict(obs90, deterministic=True, action_masks=mask5)
obs90 and mask5 are built exactly as in tb3_jepa_agent.py. The standalone agent reproduces MaskablePPO.predict exactly.
Training
- Environment: Gazebo (ROS 2 Humble), TurtleBot3 Burger with a 360-ray lidar, ROBOTIS Stage 3 arena, 4 moving
cylindrical obstacles. Training used noisy-sensor randomisation:
- lidar noise σ = 0.01 m with 1–2 % dropouts;
- goal distance and angle drift;
- 1–2-step action delay;
- randomised obstacle size, speed and direction.
- Reward: the ROBOTIS DQN reward (+100 goal, −50 collision or timeout, heading and obstacle terms, ×0.1), plus potential-based progress shaping 2·(0.99·Φ(s′) − Φ(s)), with Φ = −distance to goal and Φ = 0 at episode end.
- Algorithm: sb3-contrib
MaskablePPO(masks from the shield):- n_steps 256 × 2 envs, batch 64, 10 epochs, lr 3e-4;
- γ 0.99, λ 0.95, clip 0.2, entropy coefficient 0.01;
- Tanh MLP 256-256 for both actor and critic; no observation normalisation; no mirroring.
- Length: stopped at about 245k (seed 0) and 251k (seed 1) steps. The published models are the best periodic checkpoints: seed 0 at 120,320 steps, seed 1 at 240,128 steps.
- Heads: trained offline, supervised, on the JEPA dataset with noise augmentation. Collision-risk AUROC is 0.988–0.992 in every direction and well calibrated (ECE ≤ 0.01).
Evaluation
The same 100 fixed episodes were used for every model (same goals, start poses, obstacle phases and noise seeds), with deterministic actions and the shield on. The baseline is a plain PPO on the 74 classic inputs (no JEPA, no shield, original reward, 100k steps).
| v6 seed 0 | v6 seed 1 | v6 pooled | Baseline PPO pooled | |
|---|---|---|---|---|
| Success, clean sensors | 32 % | 31 % | 31.5 % | 29.5 % |
| Success, noisy sensors | 37 % | 32 % | 34.5 % | 28.5 % |
| Collision, noisy sensors | 63 % | 68 % | 65.5 % | 70.5 % |
| Timeouts | 0 % | 0 % | 0 % | 0–1 % |
| Median steps to goal (successes) | 105 | 146 |
- Faster: v6 reaches the goal about 28 % faster when it succeeds (Mann–Whitney p ≈ 1e-8).
- More consistent across training seeds: 31–37 % against 17–42 % for the baseline.
- Higher success, not yet significant: pooled noisy-sensor success is 6 points higher, but the paired McNemar test gives p = 0.19.
- Not a like-for-like comparison: v6 also differs from the baseline in reward, shield and training length.

Limitations
- Not deployment-ready: about two-thirds of the evaluation episodes still end in a collision, even with the shield. The shield lowers risk but doesn't guarantee safety.
- Simulation only: one arena, cylindrical obstacles. Expect a sim-to-real gap.
- Sensor and robot assumptions: a 360-ray, 5 Hz, 3.5 m lidar; TurtleBot3 Burger kinematics at 0.20 m/s.
- Reliable goal position needed: the goal distance and angle must come from good localisation.
- Conservative evaluation numbers: the best checkpoints were picked on 10-episode periodic evaluations, which tend to overstate performance. The 100-episode numbers above are the reliable ones.
License
MIT. The JEPA encoder is in penji2803/lidar-vjepa-turtlebot3 (MIT). The environment builds on ROBOTIS turtlebot3_machine_learning (Stage 3 world, reward functions).