elmoghany commited on
Commit
7c85fa3
·
verified ·
1 Parent(s): 5c7735c

Add Foresight response models: linear-response operator (headline) + k1 residual; rewrite card

Browse files
Files changed (3) hide show
  1. README.md +131 -44
  2. linres_head.pt +3 -0
  3. residual_predictor_k1.pt +3 -0
README.md CHANGED
@@ -1,44 +1,131 @@
1
- ---
2
- license: mit
3
- library_name: pytorch
4
- pipeline_tag: robotics
5
- tags:
6
- - robotics
7
- - social-navigation
8
- - human-robot-interaction
9
- - pedestrian-trajectory-prediction
10
- - model-predictive-control
11
- ---
12
-
13
- # PeRoI controller — trained weights
14
-
15
- `residual_predictor.pt` — the action-conditioned pedestrian-response predictor behind the **PeRoI
16
- social-navigation controller**. A NeuRoSFM residual (`ŷ = SocialForce + learned_correction`) trained on
17
- the real **PeRoI** robot–human interaction dataset; deployed on a robot as a velocity-grid MPC that
18
- anticipates how each nearby person will react to the robot and plans around them.
19
-
20
- **The controller code, real-robot integration guide, ROS node, and sanity check live in the private
21
- GitHub repo `github.com/elmoghany/peroi-controller`.** This HF repo hosts only the weights.
22
-
23
- ## Download the weights
24
-
25
- ```bash
26
- pip install huggingface_hub
27
- hf download elmoghany/peroi-controller residual_predictor.pt --local-dir .
28
- # (private repo — run `hf auth login` first with an account that has access)
29
- ```
30
-
31
- ## Use
32
-
33
- ```python
34
- from peroi_controller import PeRoIController # from the GitHub repo
35
- ctrl = PeRoIController("residual_predictor.pt", robot_radius=0.30, v_max=0.6)
36
- vx, vy = ctrl.step(robot_xy, goal_xy, {track_id: (x, y), ...}, dt=loop_dt)
37
- ```
38
-
39
- Architecture: 3-layer MLP residual on a Social-Force prior; input = pedestrian local-frame features
40
- (past 1 s + goal direction + robot relative state + nearest neighbours + robot-condition one-hot),
41
- output = 8×2 future deltas (2 s @ 0.25 s). ~90 KB, runs in <1 ms/step on CPU.
42
-
43
- Provenance + metrics + videos: **https://elmoghany.com/crowd-nav**. License: MIT.
44
- Contact: Mohamed Elmoghany (Cornell).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ library_name: pytorch
4
+ pipeline_tag: robotics
5
+ tags:
6
+ - robotics
7
+ - social-navigation
8
+ - human-robot-interaction
9
+ - pedestrian-trajectory-prediction
10
+ - model-predictive-control
11
+ - convex-optimization
12
+ ---
13
+
14
+ # crowd-nav — human-response models for the Foresight controller
15
+
16
+ Trained weights for **Foresight**, a convex receding-horizon controller that predicts how each
17
+ nearby pedestrian will respond to the robot's *candidate plan*, and then chooses that plan by
18
+ exact convex optimization. These are the response models the controller calls; the planner is
19
+ plain code (no learned policy, no RL).
20
+
21
+ | file | model | role |
22
+ |---|---|---|
23
+ | `linres_head.pt` | **Linear-response operator** (headline) | best closed-loop performance; makes planning an exact convex QP |
24
+ | `residual_predictor_k1.pt` | Residual predictor | most accurate on real data; the safest variant in closed loop |
25
+ | `residual_predictor.pt` | *legacy* | **deprecated** — trained with a robot-force prior of 0 but deployed at 1; superseded by `residual_predictor_k1.pt` |
26
+
27
+ ## Which one should I use?
28
+
29
+ **`linres_head.pt`** unless you have a reason not to. It is a few centimetres less accurate as a
30
+ pure forecaster, but its prediction is *exactly affine* in the robot's planned displacement, so the
31
+ planner gets an exact constant Jacobian and the safety constraints stay linear — the whole plan
32
+ selection becomes a convex QP that solves in ~17 ms with a checkable feasibility certificate.
33
+ That trade wins where it counts: it leads our benchmark, and it is the only variant that crossed a
34
+ 90-pedestrian oncoming corridor with zero contacts.
35
+
36
+ ## Measured results
37
+
38
+ Isaac Sim, 16 scenarios × 10 paired seeds (160 episodes per method), identical hardware:
39
+
40
+ | model | goal reach | hard collisions / ep | plan latency (mean) |
41
+ |---|---|---|---|
42
+ | **Foresight-LinRes** (`linres_head.pt`) | **94.4 %** | 0.013 | **16.6 ms** |
43
+ | Foresight-Residual (`residual_predictor_k1.pt`) | 90.0 % | **0.006** | 19.7 ms |
44
+ | Foresight-SFM (physics only, ablation) | 93.8 % | 0.013 | 17.2 ms |
45
+ | Foresight-CV (straight-line, ablation) | 90.0 % | 0.019 | 16.4 ms |
46
+ | SICNav [T-RO '24] (nonconvex bilevel MPC) | 89.2 % | 0.042 | 1843 ms |
47
+
48
+ Stress test — a 4.5 m × 105 m corridor with 90 pedestrians *all walking against* the robot and a
49
+ continuous inflow so it never empties: LinRes reached the goal in 98.5 s with **zero contacts**;
50
+ against pedestrian models it was never tuned on (SRFM, social-force) it reached in 85.0 s and
51
+ 91.7 s, also contact-free.
52
+
53
+ Prediction accuracy on the held-out real split (factual ADE, metres — lower is better):
54
+
55
+ | model | no robot | stationary robot | moving robot |
56
+ |---|---|---|---|
57
+ | Constant velocity | 0.240 | 0.253 | 0.354 |
58
+ | Social force | 0.343 | 0.358 | 0.416 |
59
+ | Residual (k1) | **0.192** | **0.217** | 0.285 |
60
+ | Linear response | 0.204 | 0.248 | 0.319 |
61
+
62
+ ## Architecture
63
+
64
+ Both models are a **physics prior plus a learned correction** — small by design, because the real
65
+ moving-robot data is scarce.
66
+
67
+ ```
68
+ prior (no parameters, per pedestrian per 0.25 s step)
69
+ f_goal = (1.3·(g−p)/‖g−p‖ − v)/0.5
70
+ f_ped = Σ 2.0·exp(−d/0.4)·d̂ (d < 2.0 m)
71
+ f_robot = k·exp(−d/0.5)·d̂ (d < 3.0 m)
72
+ v ← clip(v + f·Δt, 1.8); p ← p + v·Δt
73
+
74
+ residual_predictor_k1.pt ŷ = prior(k=1) + f_θ(x)
75
+ f_θ : MLP 22 → 128 → 128 → 16 (21,520 params)
76
+
77
+ linres_head.pt ŷ = prior(k=0) + f_θ(x) + G_φ(x)·ΔR
78
+ f_θ : MLP 22 → 128 → 128 → 16 (21,520 params)
79
+ G_φ : MLP 22 → 64 → 96 (7,712 params) ⇒ rank-3 16×16 operator
80
+ G = Σ_{r=1..3} a_r b_rᵀ, ΔR = (R − 1⊗r₀)/5.0
81
+ ⇒ ∂ŷ/∂R = G/5.0 — exact, constant, no differentiation needed
82
+ ```
83
+
84
+ Input `x` (22-d, pedestrian local frame): 1 s of past positions (4 @ 0.25 s), velocity, goal
85
+ direction, robot relative position, a robot-nearby flag, the two nearest neighbours, and a 3-way
86
+ condition one-hot. Output: 8 × 2 future displacements — 2.0 s at 0.25 s.
87
+
88
+ Training: supervised (Adam, lr 1e-3, batch 128, ~25 epochs), synthetic pre-train then fine-tune on
89
+ the real **PeRoI** robot–pedestrian recordings. No reinforcement learning anywhere in this stack.
90
+ Both run in well under 1 ms per call on CPU.
91
+
92
+ ## Load
93
+
94
+ ```bash
95
+ pip install huggingface_hub torch
96
+ hf download elmoghany/crowd-nav linres_head.pt residual_predictor_k1.pt --local-dir .
97
+ ```
98
+
99
+ ```python
100
+ import torch
101
+ ck = torch.load("linres_head.pt", map_location="cpu")
102
+ ck["config"]
103
+ # {'in_dim': 22, 'horizon_dim': 16, 'rank': 3, 'hidden': 64, 'dr_scale': 5.0,
104
+ # 'sfm_k_robot': 0.0, 'convention': 'y = sfm(k=0) + f_resid(x_ctx) + head(x_ctx, dR)'}
105
+ ck["f_resid"], ck["head"] # two state_dicts
106
+ ```
107
+
108
+ The `config` block is authoritative: `sfm_k_robot` **must** match the robot-force strength used in
109
+ your prior at deployment. Mismatching them is a real bug we shipped once — the residual then
110
+ corrects an error that is not there. `residual_predictor.pt` is the artifact of that mistake and is
111
+ kept only for reproducibility.
112
+
113
+ Model classes (`ResidualPredictor`, `LinearResponseHead`) and the full controller live in the
114
+ research repo: **[github.com/elmoghany/crowd-nav](https://github.com/elmoghany/crowd-nav)**.
115
+ A sim-free packaging of the controller for real robots is at
116
+ [github.com/elmoghany/peroi-controller](https://github.com/elmoghany/peroi-controller).
117
+
118
+ ## Honest limitations
119
+
120
+ - **Real-data forecasting is a tie.** On four real robot–pedestrian datasets (including JRDB),
121
+ every learned model here ties the analytic baselines on factual accuracy. Our measured
122
+ explanation: the counterfactual proxy those benchmarks rely on (constant-velocity extrapolation)
123
+ correlates only r ≈ 0.30 with exact simulated counterfactuals — the target is mostly noise. The
124
+ gains above are **closed-loop** gains, not forecasting gains.
125
+ - **Compliance bias.** The training recordings contain cooperative pedestrians. On deliberately
126
+ stubborn crowds the k1 residual is the weakest learned variant; compliance-randomized training
127
+ data is the known fix, not yet applied.
128
+ - **Cross-dataset transfer.** Moving `residual_predictor_k1.pt` to JRDB over-predicts robot-induced
129
+ deviation by ~6× (its k=1 prior is calibrated to our robot). It makes a controller conservative,
130
+ not unsafe — it still threaded real JRDB crowds contact-free — but retune `sfm_k_robot` for a
131
+ different platform.
linres_head.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0b62533c21dc5914bb9d146cbb09be99717ec1e6be7f7fa90a8d8025e9f33539
3
+ size 121136
residual_predictor_k1.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c775aa7966703671bb7b75f6d53a5a4543d4b92a2e49724a8e5c86e68b9ae547
3
+ size 88980