• Stars
    star
    643
  • Rank 69,987 (Top 2 %)
  • Language
    Jupyter Notebook
  • License
    MIT License
  • Created almost 5 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Code accompanying the ECCV 2020 paper "Trajectron++: Dynamically-Feasible Trajectory Forecasting With Heterogeneous Data" by Tim Salzmann*, Boris Ivanovic*, Punarjay Chakravarty, and Marco Pavone (* denotes equal contribution).

NOTE: A new version of the Trajectron++ codebase has been released! Check it out here!

Trajectron++: Dynamically-Feasible Trajectory Forecasting With Heterogeneous Data

This repository contains the code for Trajectron++: Dynamically-Feasible Trajectory Forecasting With Heterogeneous Data by Tim Salzmann*, Boris Ivanovic*, Punarjay Chakravarty, and Marco Pavone (* denotes equal contribution).

Installation

Cloning

When cloning this repository, make sure you clone the submodules as well, with the following command:

git clone --recurse-submodules <repository cloning URL>

Alternatively, you can clone the repository as normal and then load submodules later with:

git submodule init # Initializing our local configuration file
git submodule update # Fetching all of the data from the submodules at the specified commits

NOTE: If you would like to use the code as it was for ECCV 2020, please check out the eccv2020 branch. The master branch will differ as new updates are made to the codebase (including potential non-interoperabilities between the two versions).

Environment Setup

First, we'll create a conda environment to hold the dependencies.

conda create --name trajectron++ python=3.6 -y
source activate trajectron++
pip install -r requirements.txt

Then, since this project uses IPython notebooks, we'll install this conda environment as a kernel.

python -m ipykernel install --user --name trajectronpp --display-name "Python 3.6 (Trajectron++)"

Data Setup

Pedestrian Datasets

We've already included preprocessed data splits for the ETH and UCY Pedestrian datasets in this repository, you can see them in experiments/pedestrians/raw. In order to process them into a data format that our model can work with, execute the follwing.

cd experiments/pedestrians
python process_data.py # This will take around 10-15 minutes, depending on your computer.

nuScenes Dataset

Download the nuScenes dataset (this requires signing up on their website). Note that the full dataset is very large, so if you only wish to test out the codebase and model then you can just download the nuScenes "mini" dataset which only requires around 4 GB of space. Extract the downloaded zip file's contents and place them in the experiments/nuScenes directory. Then, download the map expansion pack (v1.1) and copy the contents of the extracted maps folder into the experiments/nuScenes/v1.0-mini/maps folder. Finally, process them into a data format that our model can work with.

cd experiments/nuScenes

# For the mini nuScenes dataset, use the following
python process_data.py --data=./v1.0-mini --version="v1.0-mini" --output_path=../processed

# For the full nuScenes dataset, use the following
python process_data.py --data=./v1.0 --version="v1.0-trainval" --output_path=../processed

In case you also want a validation set generated (by default this will just produce the training and test sets), replace line 406 in process_data.py with:

    val_scene_names = val_scenes

Model Training

Pedestrian Dataset

To train a model on the ETH and UCY Pedestrian datasets, you can execute a version of the following command from within the trajectron/ directory.

python train.py --eval_every 10 --vis_every 1 --train_data_dict <dataset>_train.pkl --eval_data_dict <dataset>_val.pkl --offline_scene_graph yes --preprocess_workers 5 --log_dir ../experiments/pedestrians/models --log_tag <desired tag> --train_epochs 100 --augment --conf <desired model configuration>

For example, a fully-fleshed out version of this command to train a model without dynamics integration for evaluation on the ETH - University scene would look like:

python train.py --eval_every 10 --vis_every 1 --train_data_dict eth_train.pkl --eval_data_dict eth_val.pkl --offline_scene_graph yes --preprocess_workers 5 --log_dir ../experiments/pedestrians/models --log_tag _eth_vel_ar3 --train_epochs 100 --augment --conf ../experiments/pedestrians/models/eth_vel/config.json

What this means is to train a new Trajectron++ model which will be evaluated every 10 epochs, have a few outputs visualized in Tensorboard every 1 epoch, use the eth_train.pkl file as the source of training data (which actually contains the four other datasets, since we train using a leave-one-out scheme), and evaluate the partially-trained models on the data within eth_val.pkl. Further options specify that we want to perform a bit of preprocessing to make training as fast as possible (--offline_scene_graph yes), use 5 threads to parallelize data loading, save trained models and Tensorboard logs to ../experiments/pedestrians/models, mark the created log directory with an additional _eth_vel_ar3 at the end, run training for 100 epochs, augment the dataset with rotations (--augment), and use the same model configuration as in the model we previously trained for the ETH dataset without any dynamics integration (--conf ../experiments/pedestrians/models/eth_vel/config.json).

If you wanted to train a model with dynamics integration for the ETH - University scene, then you would instead run:

python train.py --eval_every 10 --vis_every 1 --train_data_dict eth_train.pkl --eval_data_dict eth_val.pkl --offline_scene_graph yes --preprocess_workers 5 --log_dir ../experiments/pedestrians/models --log_tag _eth_ar3 --train_epochs 100 --augment --conf ../experiments/pedestrians/models/eth_attention_radius_3/config.json

where the only difference is the sourced model configuration (now from ../experiments/pedestrians/models/eth_attention_radius_3/config.json). Our codebase is set up such that hyperparameters are saved in a json file every time a model is trained, so that you don't have to remember what settings you use when you end up training many models in parallel!

Commands like these would be used for all of the scenes in the ETH and UCY datasets (the options being eth, hotel, univ, zara1, and zara2). The only change would be what train_data_dict, eval_data_dict, log_tag, and configuration file (conf) you wish to use.

nuScenes Dataset

To train a model on the nuScenes dataset, you can execute one of the following commands from within the trajectron/ directory, depending on the model version you desire.

Model Command
Base python train.py --eval_every 1 --vis_every 1 --conf ../experiments/nuScenes/models/vel_ee/config.json --train_data_dict nuScenes_train_full.pkl --eval_data_dict nuScenes_val_full.pkl --offline_scene_graph yes --preprocess_workers 10 --batch_size 256 --log_dir ../experiments/nuScenes/models --train_epochs 20 --node_freq_mult_train --log_tag _vel_ee --augment
+Dynamics Integration python train.py --eval_every 1 --vis_every 1 --conf ../experiments/nuScenes/models/int_ee/config.json --train_data_dict nuScenes_train_full.pkl --eval_data_dict nuScenes_val_full.pkl --offline_scene_graph yes --preprocess_workers 10 --batch_size 256 --log_dir ../experiments/nuScenes/models --train_epochs 20 --node_freq_mult_train --log_tag _int_ee --augment
+Dynamics Integration, Maps python train.py --eval_every 1 --vis_every 1 --conf ../experiments/nuScenes/models/int_ee_me/config.json --train_data_dict nuScenes_train_full.pkl --eval_data_dict nuScenes_val_full.pkl --offline_scene_graph yes --preprocess_workers 10 --batch_size 256 --log_dir ../experiments/nuScenes/models --train_epochs 20 --node_freq_mult_train --log_tag _int_ee_me --map_encoding --augment
+Dynamics Integration, Maps, Robot Future python train.py --eval_every 1 --vis_every 1 --conf ../experiments/nuScenes/models/robot/config.json --train_data_dict nuScenes_train_full.pkl --eval_data_dict nuScenes_val_full.pkl --offline_scene_graph yes --preprocess_workers 10 --batch_size 256 --log_dir ../experiments/nuScenes/models --train_epochs 20 --node_freq_mult_train --log_tag _robot --incl_robot_node --map_encoding

In case you also want to produce the version of our model that was trained without the ego-vehicle (first row of Table 4 (b) in the paper), then run the command from the third row of the table above, but change line 132 of train.py to:

                                       return_robot=False)

CPU Training

By default, our training script assumes access to a GPU. If you want to train on a CPU, comment out line 38 in train.py and add --device cpu to the training command.

Model Evaluation

Pedestrian Datasets

To evaluate a trained model, you can execute a version of the following command from within the experiments/pedestrians directory.

python evaluate.py --model <model directory> --checkpoint <epoch number> --data ../processed/<dataset>_test.pkl --output_path results --output_tag <dataset>_<vel if no integration>_12 --node_type PEDESTRIAN

For example, a fully-fleshed out version of this command to evaluate a model without dynamics integration for evaluation on the ETH - University scene would look like:

python evaluate.py --model models/eth_vel --checkpoint 100 --data ../processed/eth_test.pkl --output_path results --output_tag eth_vel_12 --node_type PEDESTRIAN

The same for a model with dynamics integration would look like:

python evaluate.py --model models/eth_attention_radius_3 --checkpoint 100 --data ../processed/eth_test.pkl --output_path results --output_tag eth_12 --node_type PEDESTRIAN

These scripts will produce csv files in the results directory which can then be analyzed in the Result Analysis.ipynb notebook.

nuScenes Dataset

If you just want to use a trained model to generate trajectories and plot them, you can do this in the NuScenes Qualitative.ipynb notebook.

To evaluate a trained model's performance on forecasting vehicles, you can execute a one of the following commands from within the experiments/nuScenes directory.

Model Command
Base python evaluate.py --model models/vel_ee --checkpoint=12 --data ../processed/nuScenes_test_full.pkl --output_path results --output_tag vel_ee --node_type VEHICLE --prediction_horizon 6
+Dynamics Integration python evaluate.py --model models/int_ee --checkpoint=12 --data ../processed/nuScenes_test_full.pkl --output_path results --output_tag int_ee --node_type VEHICLE --prediction_horizon 6
+Dynamics Integration, Maps python evaluate.py --model models/int_ee_me --checkpoint=12 --data ../processed/nuScenes_test_full.pkl --output_path results --output_tag int_ee_me --node_type VEHICLE --prediction_horizon 6
+Dynamics Integration, Maps, Robot Future python evaluate.py --model models/robot --checkpoint=12 --data ../processed/nuScenes_test_full.pkl --output_path results --output_tag robot --node_type VEHICLE --prediction_horizon 6

If you instead wanted to evaluate a trained model's performance on forecasting pedestrians, you can execute a one of the following.

Model Command
Base python evaluate.py --model models/vel_ee --checkpoint=12 --data ../processed/nuScenes_test_full.pkl --output_path results --output_tag vel_ee_ped --node_type PEDESTRIAN --prediction_horizon 6
+Dynamics Integration, Maps python evaluate.py --model models/int_ee_me --checkpoint=12 --data ../processed/nuScenes_test_full.pkl --output_path results --output_tag int_ee_me_ped --node_type PEDESTRIAN --prediction_horizon 6

These scripts will produce csv files in the results directory which can then be analyzed in the NuScenes Quantitative.ipynb notebook.

Online Execution

As of December 2020, this repository includes an "online" running capability. In addition to the regular batched mode for training and testing, Trajectron++ can now be executed online on streaming data!

The trajectron/test_online.py script shows how to use it, and can be run as follows (depending on the desired model).

Model Command File Changes
Base python test_online.py --log_dir=../experiments/nuScenes/models --data_dir=../experiments/processed --conf=config.json --eval_data_dict=nuScenes_test_mini_full.pkl Line 110: 'vel_ee'
+Dynamics Integration python test_online.py --log_dir=../experiments/nuScenes/models --data_dir=../experiments/processed --conf=config.json --eval_data_dict=nuScenes_test_mini_full.pkl Line 110: 'int_ee'
+Dynamics Integration, Maps python test_online.py --log_dir=../experiments/nuScenes/models --data_dir=../experiments/processed --conf=config.json --eval_data_dict=nuScenes_test_mini_full.pkl --map_encoding Line 110: 'int_ee_me'
+Dynamics Integration, Maps, Robot Future python test_online.py --log_dir=../experiments/nuScenes/models --data_dir=../experiments/processed --conf=config.json --eval_data_dict=nuScenes_test_mini_full.pkl --map_encoding --incl_robot_node Line 110: 'robot'

Further, lines 145-151 can be changed to choose different scenes and starting timesteps.

During running, each prediction will be iteratively visualized and saved in a pred_figs/ folder within the specified model folder. For example, if the script loads the int_ee version of Trajectron++ then generated figures will be saved to experiments/nuScenes/models/int_ee/pred_figs/.

Datasets

ETH and UCY Pedestrian Datasets

Preprocessed ETH and UCY datasets are available in this repository, under experiments/pedestrians/raw (e.g., raw/eth/train). The train/validation/test splits are the same as those found in Social GAN.

If you want the original ETH or UCY datasets, you can find them here: ETH Dataset and UCY Dataset.

nuScenes Dataset

If you only want to evaluate models (e.g., produce trajectories and plot them), then the nuScenes mini dataset should be fine. If you want to train a model, then the full nuScenes dataset is required. In either case, you can find them on the dataset website.

More Repositories

1

AA203-Notes

Course notes for AA203
TeX
143
star
2

neural-network-lyapunov

Synthesizing neural-network Lyapunov functions (and controllers) as stability certificate.
Python
139
star
3

Trajectron

Code accompanying "The Trajectron: Probabilistic Multi-Agent Trajectory Modeling with Dynamic Spatiotemporal Graphs" by Boris Ivanovic and Marco Pavone.
Jupyter Notebook
134
star
4

hj_reachability

Hamilton-Jacobi reachability analysis in JAX.
Python
100
star
5

LearnedSamplingDistributions

Jupyter Notebook
67
star
6

stlcg

Jupyter Notebook
60
star
7

GuSTO.jl

Guaranteed Sequential Trajectory Optimization (GuSTO), using sequential convex programming for trajectory optimization with strong theoretical guarantees
Julia
56
star
8

Adaptive-Control-Oriented-Meta-Learning

Adaptive control-oriented meta-learning for nonlinear systems
Python
53
star
9

RobustMP

Robust Online Motion Planning using Contraction Theory
MATLAB
53
star
10

ALPaCA

Code for "Meta-Learning Priors for Efficient Online Bayesian Regression" by James Harrison, Apoorva Sharma, and Marco Pavone
Jupyter Notebook
53
star
11

AA203-Examples

Examples shown in class and recitation from AA203: Optimal and Learning-Based Control.
Jupyter Notebook
47
star
12

TrafficWeavingCVAE

Jupyter Notebook
37
star
13

MATS

Code accompanying the CoRL 2020 paper "MATS: An Interpretable Trajectory Forecasting Representation for Planning and Control" by Boris Ivanovic, Amine Elhafsi, Guy Rosman, Adrien Gaidon, and Marco Pavone.
Jupyter Notebook
37
star
14

CoCo

Jupyter Notebook
35
star
15

moca

Python
31
star
16

asl_turtlebot

Python
29
star
17

vtd_interface

Python
26
star
18

soft-robot-control

Implementation of reduced-order optimal control schemes for finite element models of Soft Robots
Python
26
star
19

KinoFMT

MATLAB
24
star
20

AA203-Homework

Starter code accompanying homework assignments from AA203: Optimal and Learning-Based Control.
Python
23
star
21

ccscp

Chance-Constrained Sequential Convex Programming for Robust Trajectory Optimization
Python
23
star
22

SCOD

Code accompanying "Sketching Curvature for Efficient Out-of-Distribution Detection for Deep Neural Networks"
Python
21
star
23

unbalanced-opf-toolkit

A general code base to formulate and solve unbalanced optimal power flow (OPF) problems written in MATLAB.
MATLAB
21
star
24

AA274_lecture_notes

Compiled lecture notes for AA274
TeX
20
star
25

SNDL

Stabilizable Nonlinear Dynamics Learning
MATLAB
20
star
26

LSBMP

Jupyter Notebook
19
star
27

GMT

The Group Marching Tree Algorithm, presented at IRC 2017
Mercury
19
star
28

PandaRobot.jl

URDF and meshes for the Franka Emika Panda robot
Julia
19
star
29

PBDS.jl

Julia implementation of Pullback Bundle Dynamical Systems (PBDS) framework for geometrically-consistent, multi-task reactive control on manifolds
Julia
18
star
30

Pigeon.jl

MPC trajectory tracking + reachability-based collision avoidance for pairwise vehicle interactions
Julia
17
star
31

rompc

Reduced Order Model Predictive Control
MATLAB
17
star
32

safe_traffic_weaving

On Infusing Reachability-Based Safety Assurance within Probabilistic Planning Frameworks for Human-Robot Vehicle Interactions
Python
16
star
33

NHumanModeling

Contains the code for "Generative Modeling of Multimodal Multi-Human Behavior" by Boris Ivanovic, Edward Schmerling, Karen Leung, and Marco Pavone.
Jupyter Notebook
15
star
34

RiskAverseTrajOpt

Risk-averse trajectory optimization
Python
14
star
35

pmpc

High-level Python Particle Sequential Convex Programming Model Predictive Control (SCP PMPC) interface
Jupyter Notebook
13
star
36

stlhj

Code for โ€œSignal Temporal Logic meets Hamilton-Jacobi Reachability: Connections and Applicationsโ€ by Mo Chen, Qizhan Tam, Scott C. Livingston, and Marco Pavone.
C++
13
star
37

matsim-AMoD

A fork of MATSIM's DVRP module for rebalancing of self-driving vehicles in an Autonomous Mobility on Demand (AMoD) framework
Jupyter Notebook
12
star
38

BaRC

Contains the code for "BaRC: Backward Reachability Curriculum for Robotic Reinforcement Learning" by Boris Ivanovic, James Harrison, Apoorva Sharma, Mo Chen, Marco Pavone.
Python
12
star
39

asl_fixedwing

Fixed Wing Aircraft Control
C++
11
star
40

RSIRL

Risk-sensitive Inverse Reinforcement Learning
MATLAB
10
star
41

heterogeneous-task-allocation

MATLAB
10
star
42

pamod

Coordination Algorithms for the interaction between Autonomous Mobility-on-Demand systems and the power network.
Jupyter Notebook
10
star
43

NASA_ULI_Xplane_Simulator

Dataset and Simulator for the NASA ULI Project
Python
10
star
44

StanfordASL.github.io

TeX
9
star
45

stochasticSCP

Sequential Convex Programming For Non-Linear Stochastic Optimal Control
Julia
9
star
46

UP

Sampling-based Reachability Analysis: A Random Set Theory Approach with Adversarial Sampling
Jupyter Notebook
9
star
47

SSMR-for-control

MATLAB
9
star
48

Pi-MPC

Code accompanying "Perfecting Periodic Trajectory Tracking: Model Predictive Control with a Periodic Observer."
Jupyter Notebook
9
star
49

cloud_robotics

Python
8
star
50

AMoD-toolkit

A reference implementation of the time-varying, charge-aware network flow model for AMoD systems.
MATLAB
8
star
51

chreach

Convex hulls of reachable sets
Python
8
star
52

Principles-of-Robot-Autonomy

Principles of Robot Autonomy
TeX
7
star
53

RandUP_RRT

Robust-RRT: Probabilistically-Complete Motion Planning for Uncertain Nonlinear Systems
Python
7
star
54

stochastic-prog

Sample Average Approximation for Stochastic Programming with Equality Constraints
Python
7
star
55

Janson.Ichter.Pavone.IJRR15

Deterministic Sampling-Based Motion Planning: Optimality, Complexity, and Performance
MATLAB
7
star
56

Second-OrderSensitivityAnalysisForBilevelOptimization

Python
7
star
57

graph-rl-for-eamod

Official implementation of "Real-time Control of Electric Autonomous Mobility-on-Demand Systems via Graph Reinforcement Learning"
Python
7
star
58

RAMCP

Robust Adaptive Monte Carlo Planning
Jupyter Notebook
6
star
59

ASL-X-Plane-11-Platform-Deprecated

Jupyter Notebook
6
star
60

freeflyer2

Python
6
star
61

data-lifecycle-management

Code accompanying the AI4Space 2022 paper "Data Lifecycle Management in Evolving Input Distributions for Learning-based Aerospace Applications" by Somrita Banerjee, Apoorva Sharma, Edward Schmerling, Max Spolaor, Michael Nemerouf, and Marco Pavone.
Jupyter Notebook
5
star
62

RandUP

A Simple and Efficient Sampling-based Algorithm for General Reachability Analysis
Python
5
star
63

RL4AMOD

Python
5
star
64

online-tolls

Code accompanying the paper "Online Learning for Traffic Routing under Unknown Preferences"
Python
4
star
65

jlSCP

Analysis of Theoretical and Numerical Properties of Sequential Convex Programming for Continuous-Time Optimal Control
Jupyter Notebook
4
star
66

UASEncounter

Unmanned Aerial System encounter simulation and MDP solution julia code
Jupyter Notebook
4
star
67

frank-wolfe-traffic

Frank-Wolfe for Traffic Assignment
C++
3
star
68

robotics_seminar

HTML
3
star
69

rover-meta-learning

Python
3
star
70

fair-routing

Jupyter Notebook
3
star
71

PSU-TF

Code for "Propagating State Uncertainty through Trajectory Forecasting"
3
star
72

stlcg_ctrl_syn

Synthesizing a controller that satisfies stl specifications
Python
3
star
73

PUMP

Repository of code for the Parallel Uncertainty-aware Multiobjective Planning algorithm presented at ICRA '17.
Cuda
3
star
74

PerceptionConstrArmPlanning

Code for "Perception-Constrained Robot Manipulator Planning for Satellite Servicing," by Tariq Zahroof, Andrew Bylard, Hesham Shageer, and Marco Pavone.
3
star
75

convex-hull-estimation

Estimating the convex hull of the image of a set with smooth boundary
Python
2
star
76

Model-Mismatch

MATLAB
2
star
77

nnGuSTO

Jupyter Notebook
2
star
78

GuSTO_quad_astrobee

Simplified implementation of GuSTO in Julia, with quadrotor and Astrobee examples.
Jupyter Notebook
2
star
79

copositive-cutting-plane-max-clique

Jupyter Notebook
1
star
80

AA274_HW1

AA274 Homework 1 Code
Python
1
star
81

AstrobeeRobot.jl

URDF and meshes for the Astrobee free-flying robot
Julia
1
star
82

ASL-X-Plane-11-Platform

Jupyter Notebook
1
star
83

AA274_SECTION

Public-facing section materials for AA 274A
TeX
1
star
84

reachbot_manipulation

Code for "Task-Driven Manipulation with Reconfigurable Parallel Robots"
Python
1
star
85

BulletCollision.jl

Julia package for collision-related queries using the Bullet Physics engine
Julia
1
star
86

AA274_HW3

AA274 Homework 3 Code
OpenEdge ABL
1
star
87

idwithtasks

Python
1
star
88

scod-module

Standalone implementation of SCOD
Python
1
star