got processing of expert demonstrations functional
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -136,6 +136,7 @@ dmypy.json
|
|||||||
|
|
||||||
# Datasets
|
# Datasets
|
||||||
datasets/
|
datasets/
|
||||||
|
expert_data/
|
||||||
|
|
||||||
# Results
|
# Results
|
||||||
experiments/results/
|
experiments/results/
|
||||||
|
|||||||
15
README.md
15
README.md
@@ -19,6 +19,21 @@ The INTERACTION dataset contains a two folders which should be copied into a fol
|
|||||||
- the contents of `recorded_trackfiles` should be copied to `./InteractionSimulator/datasets/trackfiles`
|
- the contents of `recorded_trackfiles` should be copied to `./InteractionSimulator/datasets/trackfiles`
|
||||||
- the contents of `maps` should be copied to `./InteractionSimulator/datasets/maps`
|
- the contents of `maps` should be copied to `./InteractionSimulator/datasets/maps`
|
||||||
|
|
||||||
|
## Processing, saving, and loading expert demos
|
||||||
|
Once the repository has been set up, you can process and save expert track demonstrations with:
|
||||||
|
```
|
||||||
|
python src/expert_data.py --loc [LOCNUM] --track [TRACKNUM]
|
||||||
|
```
|
||||||
|
|
||||||
|
You can then load the experts actions and observations using
|
||||||
|
```
|
||||||
|
from src import expert_data
|
||||||
|
observations, actions = expert_data.load_expert_data(loc = [LOCNUM], track = [TRACKNUM])
|
||||||
|
for (s, a) in zip (observations, actions):
|
||||||
|
# do some imitation learning
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Package Structure
|
## Package Structure
|
||||||
```
|
```
|
||||||
InteractionImitation
|
InteractionImitation
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import gym
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
import intersim
|
import intersim
|
||||||
from intersim.utils import get_map_path, get_svt, SVT_to_sim_stateactions
|
from intersim.utils import get_map_path, get_svt, SVT_to_stateactions
|
||||||
from intersim import collisions
|
from intersim import collisions
|
||||||
import os
|
import os
|
||||||
opj = os.path.join
|
opj = os.path.join
|
||||||
@@ -28,7 +28,7 @@ def generate_expert_data(path: str='expert_data', loc: int = 0, track:int = 0, *
|
|||||||
osm = get_map_path(base='InteractionSimulator', loc=loc)
|
osm = get_map_path(base='InteractionSimulator', loc=loc)
|
||||||
print('SVT path: {}'.format(svt_path))
|
print('SVT path: {}'.format(svt_path))
|
||||||
print('Map path: {}'.format(osm))
|
print('Map path: {}'.format(osm))
|
||||||
states, actions = SVT_to_sim_stateactions(svt)
|
states, actions = SVT_to_stateactions(svt)
|
||||||
|
|
||||||
# animate from environment
|
# animate from environment
|
||||||
env = gym.make('intersim:intersim-v0', svt=svt, map_path=osm, **kwargs,
|
env = gym.make('intersim:intersim-v0', svt=svt, map_path=osm, **kwargs,
|
||||||
@@ -44,10 +44,9 @@ def generate_expert_data(path: str='expert_data', loc: int = 0, track:int = 0, *
|
|||||||
nni = ~torch.isnan(env_state[:,0])
|
nni = ~torch.isnan(env_state[:,0])
|
||||||
norms = torch.norm(env_state[nni,:2]-states[i,nni,:2], dim=1)
|
norms = torch.norm(env_state[nni,:2]-states[i,nni,:2], dim=1)
|
||||||
max_devs.append(norms.max())
|
max_devs.append(norms.max())
|
||||||
# print("Step: %04i, Maximum Deviation: %f m" %(i, max_devs[-1]))
|
|
||||||
|
|
||||||
# propagate environment
|
# propagate environment
|
||||||
ob, r, done, info = env.step(actions[i])
|
ob, r, done, info = env.step(env.target_state(svt.simstate[i+1]))
|
||||||
obs.append(ob)
|
obs.append(ob)
|
||||||
actions_taken.append(info['action_taken'])
|
actions_taken.append(info['action_taken'])
|
||||||
i += 1
|
i += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user