Skip to content

Commit

Permalink
clean up the repo further
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanganVR committed Sep 27, 2018
1 parent 21233e0 commit 6e1a200
Show file tree
Hide file tree
Showing 22 changed files with 129 additions and 512 deletions.
56 changes: 6 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,24 @@ pip install -r requirements.txt

## Getting started
This repository are organized in two parts: gym_crowd/ folder contains the simulation environment and
crowd_nav/ folder contains codes for training and testing the policies. All the commands
below should be run inside the crowd_nav/ folder.
crowd_nav/ folder contains codes for training and testing the policies. Details of the simulation framework can be found
[here](crowd_sim/README.md). Below are the instructions for training and testing policies, and they should be executed
inside the crowd_nav/ folder.


1. Train a policy.
```
python train.py --policy om-sarl
python train.py --policy sarl
```
2. Test policies with 500 test cases.
```
python test.py --policy orca --phase test
python test.py --policy om-sarl --model_dir data/output --phase test
python test.py --policy sarl --model_dir data/output --phase test
```
3. Run policy for one episode and visualize the result.
```
python test.py --policy orca --phase test --visualize --test_case 0
python test.py --policy om-sarl --model_dir data/output --phase test --visualize --test_case 0
python test.py --policy sarl --model_dir data/output --phase test --visualize --test_case 0
```
4. Plot training curve
```
Expand All @@ -73,48 +74,3 @@ SARL | OM-SARL
<img src="https://i.imgur.com/rUtAGVP.gif" width="400" />|<img src="https://i.imgur.com/UXhcvZL.gif" width="400" />


## Simulation Framework
### Environment
The environment contains n+1 agents. N of them are humans controlled by certain unknown
policy. The other is robot and it's controlled by one known policy.
The environment is built on top of OpenAI gym library, and has implemented two abstract methods.
* reset(): the environment will reset positions for all the agents and return observation
for robot. Observation for one agent is the observable states of all other agents.
* step(action): taking action of the robot as input, the environment computes observation
for each agent and call agent.act(observation) to get actions of agents. Then environment detects
whether there is a collision between agents. If not, the states of agents will be updated. Then
observation, reward, done will be returned.


### Agent
Agent is a base class, and has two derived class of human and robot. Agent class holds
all the physical properties of an agent, including position, velocity, orientation, policy and etc.
* visibility: humans are always visible, but robot can be set to be visible or invisible
* sensor: can be either visual input or coordinate input
* kinematics: can be either holonomic (move in any direction) or unicycle (has rotation constraints)
* act(observation): transform observation to state and pass it to policy


### Policy
Policy takes state as input and output an action. Current available policies:
* ORCA: compute collision-free velocity under the reciprocal assumption
* CADRL: learn a value network to predict the value of a state and during inference it predicts action for the most important human
* LSTM-RL: use lstm to encode the human states into one fixed-length vector
* SARL: use pairwise interaction module to model human-robot interaction and use self-attention to aggregate humans' information
* OM-SARL: extend SARL by encoding intra-human interaction with a local map


### State
There are multiple definition of states in different cases. The state of an agent representing all
the knowledge of environments is defined as JointState, and it's different from the state of the whole environment.
* ObservableState: position, velocity, radius of one agent
* FullState: position, velocity, radius, goal position, preferred velocity, rotation
* DualState: concatenation of one agent's full state and one another agent's observable state
* JoinState: concatenation of one agent's full state and all other agents' observable states


### Action
There are two types of actions depending on what kinematics constraint the agent has.
* ActionXY: (vx, vy) if kinematics == 'holonomic'
* ActionRot: (velocity, rotation angle) if kinematics == 'unicycle'

4 changes: 2 additions & 2 deletions crowd_nav/configs/env.config
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ discomfort_penalty_factor = 0.5


[sim]
train_val_sim = mixed
test_sim = mixed
train_val_sim = circle_crossing
test_sim = circle_crossing
square_width = 10
circle_radius = 4
human_num = 5
Expand Down
2 changes: 0 additions & 2 deletions crowd_nav/policy/policy_factory.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from crowd_sim.envs.policy.policy_factory import policy_factory
from crowd_nav.policy.cadrl import CADRL
from crowd_nav.policy.lstm_rl import LstmRL
from crowd_nav.policy.srl import SRL
from crowd_nav.policy.sarl import SARL

policy_factory['cadrl'] = CADRL
policy_factory['lstm_rl'] = LstmRL
policy_factory['srl'] = SRL
policy_factory['sarl'] = SARL
42 changes: 0 additions & 42 deletions crowd_nav/policy/srl.py

This file was deleted.

16 changes: 0 additions & 16 deletions crowd_nav/scripts/cadrl.sh

This file was deleted.

16 changes: 0 additions & 16 deletions crowd_nav/scripts/lstm_rl.sh

This file was deleted.

4 changes: 0 additions & 4 deletions crowd_nav/scripts/plot_invisible_traj.sh

This file was deleted.

4 changes: 0 additions & 4 deletions crowd_nav/scripts/plot_visible_traj.sh

This file was deleted.

16 changes: 0 additions & 16 deletions crowd_nav/scripts/run_all.sh

This file was deleted.

16 changes: 0 additions & 16 deletions crowd_nav/scripts/sarl.sh

This file was deleted.

16 changes: 0 additions & 16 deletions crowd_nav/scripts/srl.sh

This file was deleted.

2 changes: 1 addition & 1 deletion crowd_nav/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
import gym
import os
from crowd_nav.utils.robot import Robot
from crowd_sim.envs.utils.robot import Robot
from crowd_nav.utils.explorer import Explorer
from crowd_nav.policy.policy_factory import policy_factory
from crowd_sim.envs.policy.orca import ORCA
Expand Down
131 changes: 0 additions & 131 deletions crowd_nav/tests/test_orca.py

This file was deleted.

18 changes: 0 additions & 18 deletions crowd_nav/tests/test_value_network.py

This file was deleted.

Loading

0 comments on commit 6e1a200

Please sign in to comment.