-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample_usage.py
More file actions
50 lines (40 loc) · 1.3 KB
/
example_usage.py
File metadata and controls
50 lines (40 loc) · 1.3 KB
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
import argparse
import numpy as np
# Import the MultiDroneEnvironment class and the MultiDrone POMDP model components
from multi_drone_environment import MultiDroneEnvironment
from models.multi_drone_model import (
MultiDroneTransitionModel,
MultiDroneObservationModel,
MultiDroneInitialBelief,
MultiDroneTask
)
# Setup argparse to load a YAML file from the command line
parser = argparse.ArgumentParser()
parser.add_argument('--config', type=str, required=True, help="Path to the yaml configuration file")
args = parser.parse_args()
# Instantiate the POMDP model components
transition_model = MultiDroneTransitionModel()
observation_model = MultiDroneObservationModel()
initial_belief_model = MultiDroneInitialBelief()
task_model = MultiDroneTask()
# Instantiate the MultiDroneEnvironment
env = MultiDroneEnvironment(
args.config,
transition_model,
observation_model,
initial_belief_model,
task_model,
)
# Reset environment
state = env.reset()
done = False
while not done:
# Pick a random action
action = np.random.choice(env.num_actions())
# Apply action to the environment and step it forward
next_state, observation, reward, done, info = env.step(action)
# Update visualization
env.update_plot()
print("Done!")
# Enter interactive 3D viewer
env.show()