Skip to content

Commit

Permalink
Successful, not fined tuned HoverAviary training
Browse files Browse the repository at this point in the history
  • Loading branch information
JacopoPan committed Nov 26, 2023
1 parent 0407760 commit 2348440
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 0 additions & 1 deletion gym_pybullet_drones/envs/BaseRLAviary.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def __init__(self,
vision_attributes = True if obs == ObservationType.RGB else False
self.OBS_TYPE = obs
self.ACT_TYPE = act
self.EPISODE_LEN_SEC = 5
#### Create integrated controllers #########################
if act in [ActionType.PID, ActionType.VEL, ActionType.ONE_D_PID]:
os.environ['KMP_DUPLICATE_LIB_OK']='True'
Expand Down
3 changes: 2 additions & 1 deletion gym_pybullet_drones/envs/HoverAviary.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(self,
"""
self.TARGET_POS = np.array([0,0,1])
self.EPISODE_LEN_SEC = 8
super().__init__(drone_model=drone_model,
num_drones=1,
initial_xyzs=initial_xyzs,
Expand All @@ -74,7 +75,7 @@ def _computeReward(self):
"""
state = self._getDroneStateVector(0)
ret = max(0, 10 - np.linalg.norm(self.TARGET_POS-state[0:3])**4)
ret = max(0, 2 - np.linalg.norm(self.TARGET_POS-state[0:3])**4)
return ret

################################################################################
Expand Down
1 change: 1 addition & 0 deletions gym_pybullet_drones/envs/LeaderFollowerAviary.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def __init__(self,
"""
self.TARGET_POS = np.array([0,0,1])
self.EPISODE_LEN_SEC = 5
super().__init__(drone_model=drone_model,
num_drones=num_drones,
neighbourhood_radius=neighbourhood_radius,
Expand Down
8 changes: 6 additions & 2 deletions gym_pybullet_drones/examples/learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ def run(multiagent=DEFAULT_MA, output_folder=DEFAULT_OUTPUT_FOLDER, gui=DEFAULT_
eval_freq=int(2000),
deterministic=True,
render=False)
model.learn(total_timesteps=int(1e6),
if not multiagent:
steps = 2 * int(1e5)
else:
steps = int(1e6)
model.learn(total_timesteps=steps,
callback=eval_callback,
log_interval=100)

Expand Down Expand Up @@ -140,7 +144,7 @@ def run(multiagent=DEFAULT_MA, output_folder=DEFAULT_OUTPUT_FOLDER, gui=DEFAULT_

obs, info = test_env.reset(seed=42, options={})
start = time.time()
for i in range(3*test_env.CTRL_FREQ):
for i in range((test_env.EPISODE_LEN_SEC+2)*test_env.CTRL_FREQ):
action, _states = model.predict(obs,
deterministic=True
)
Expand Down

0 comments on commit 2348440

Please sign in to comment.