File size: 3,999 Bytes
9eb271c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
tags:
- robotics
- trajectory-generation
- diffusion-model
- navigation
- human-like-motion
- ddpm
library_name: pytorch
pipeline_tag: reinforcement-learning
license: mit
---

# ๐Ÿค–๐Ÿšถ Human-Like Robot Navigation Trajectory Generator

A **DDPM (Denoising Diffusion Probabilistic Model)** that generates human-like 2D navigation trajectories for robots.

## What It Does

Given a robot's current state (position + velocity) and a goal, this model generates future waypoints that mimic human walking โ€” smooth curves, natural speed changes, and obstacle-aware paths.

```
Input:  [x, y, vx, vy] + [goal_x, goal_y]
  โ†“ DDPM Reverse Diffusion (100 steps)
  โ†“ 1D Temporal UNet + FiLM conditioning
Output: 16 future waypoints [dx, dy]
```

## Key Features

- ๐Ÿšถ **Human-like paths** โ€” smooth curves, not robotic straight lines
- โšก **Variable speed** โ€” acceleration, cruising, deceleration like real walking
- ๐Ÿงฑ **Obstacle aware** โ€” learned from social force model training data
- ๐ŸŽฒ **Multi-modal** โ€” generates diverse trajectory samples via diffusion
- ๐ŸŽฏ **Goal-directed** โ€” conditions on target position

## Architecture

| Component | Details |
|-----------|---------|
| Backbone | 1D Temporal UNet ([64, 128, 256]) |
| Conditioning | FiLM (Feature-wise Linear Modulation) |
| Noise Schedule | Cosine (Improved DDPM) |
| Diffusion Steps | 100 |
| Parameters | 1,801,538 (1.8M) |
| Prediction | ฮต-prediction (noise) |

## Based On

- [Diffusion Policy](https://arxiv.org/abs/2303.04137) (Chi et al., RSS 2023)
- [TRACE](https://arxiv.org/abs/2304.01893) (Rempe et al., CVPR 2023)
- [Improved DDPM](https://arxiv.org/abs/2102.09672) (Nichol & Dhariwal, 2021)

## Training Data

2,000 synthetic episodes in a 20m ร— 20m environment with 8 obstacles:
- Social Force Model physics (Helbing & Molnar 1995)
- ~156K frames at 10 Hz
- Speed range: 0.3-2.0 m/s (avg ~1.3 m/s, matching human walking)

## Quick Start

```python
import torch, json, numpy as np

# Load
config = json.load(open('config.json'))
stats = json.load(open('normalization_stats.json'))

# Build model (copy architecture classes from this repo)
model = HumanTrajDiffusion(ad=2, sd=4, gd=2, H=16, T=100, dims=tuple(config['down_dims']))
model.load_state_dict(torch.load('model.pt', map_location='cpu'))
model.eval()

# Robot at (5,5) moving NE โ†’ goal (15,15)
state = np.array([5.0, 5.0, 0.5, 0.3])
goal = np.array([15.0, 15.0])

state_n = torch.tensor((state - stats['state_mean']) / stats['state_std'], dtype=torch.float32)
goal_n = torch.tensor((goal - stats['goal_mean']) / stats['goal_std'], dtype=torch.float32)

# Generate 5 diverse paths
trajectories = model.generate(state_n, goal_n, n=5)

# โ†’ Real coordinates
traj = trajectories.numpy() * stats['action_std'] + stats['action_mean']
positions = np.cumsum(traj, axis=1) + state[:2]
# positions.shape = (5, 16, 2) โ€” 5 paths, 16 waypoints, (x,y)
```

## Config
```json
{
  "horizon": 16,
  "action_dim": 2,
  "state_dim": 4,
  "goal_dim": 2,
  "num_diffusion_steps": 100,
  "down_dims": [
    64,
    128,
    256
  ],
  "batch_size": 32,
  "total_steps": 8000,
  "lr": 0.0002,
  "weight_decay": 1e-05,
  "warmup_steps": 200,
  "grad_clip": 10.0,
  "eval_freq": 2000,
  "log_freq": 25,
  "hub_model_id": "precison9/human-like-robot-nav-diffusion"
}
```

## Normalization Stats
```json
{
  "state_mean": [
    9.887735366821289,
    10.40771484375,
    0.02240574173629284,
    -0.010746479965746403
  ],
  "state_std": [
    4.021646976470947,
    3.9589571952819824,
    0.7364981174468994,
    0.7464056015014648
  ],
  "action_mean": [
    0.0022544937673956156,
    -0.001080495654605329
  ],
  "action_std": [
    0.07394769042730331,
    0.07494954019784927
  ],
  "goal_mean": [
    10.106578826904297,
    10.3273344039917
  ],
  "goal_std": [
    4.950056076049805,
    5.060120582580566
  ]
}
```

## Applications
- ๐Ÿค– Mobile robot navigation
- ๐ŸŽฎ NPC pedestrian AI
- ๐Ÿ—๏ธ Crowd simulation
- ๐Ÿ“Š Trajectory prediction/planning