Skip to content

Commit

Permalink
20feb experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
strakam committed Feb 20, 2024
1 parent fdd384b commit f0b1c70
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 6 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions agents/C_trajectory_following.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
###### INFRASTRUCTURE PARAMS #######
GUI = True
RECORD_VIDEO = False
OUTPUT_FOLDER = 'checkpointed_models'
OUTPUT_FOLDER = '20feb_experiments/'
COLAB = False
####################################

Expand All @@ -35,14 +35,14 @@
###### ENVIRONMENT PARAMS ##########
TIMESTEPS = 2.5e6
N_ENVS = 20
EPISODE_LEN_SEC = 20
EPISODE_LEN_SEC = 14
####################################

###### HYPERPARAMS #################
WAYPOINT_BUFFER_SIZE = 2
K_P = 5
K_WP = 8
K_S = 0.05
K_S = 0.01
MAX_REWARD_DISTANCE = 0.0
WAYPOINT_DIST_TOL = 0.05
####################################
Expand Down
14 changes: 13 additions & 1 deletion aviaries/UZHAviary.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ def __init__(self,
self.NUM_DRONES = 1
self.INIT_XYZS = initial_xyzs

self.k_p = k_p
self.k_s = k_s
self.k_wp = k_wp
self.max_reward_distance = max_reward_distance
self.waypoint_dist_tol = waypoint_dist_tol

# FOR DEVELOPMENT
self.one_traj = one_traj
Expand Down Expand Up @@ -112,7 +117,14 @@ def reset_vars(self):
self.rewards.reached_distance = 0
self.current_projection = self.trajectory[0]
self.self_trajectory = self.set_trajectory()
self.rewards.reset(self.self_trajectory)
self.rewards = Rewards(
trajectory=self.trajectory,
k_p=self.k_p,
k_wp=self.k_wp,
k_s=self.k_s,
max_reward_distance=self.max_reward_distance,
dist_tol=self.waypoint_dist_tol
)

def set_trajectory(self):
if self.one_traj:
Expand Down
10 changes: 8 additions & 2 deletions aviaries/rewards/uzh_trajectory_reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def __init__(self,
self.k_wp = k_wp
self.k_s = k_s
self.k_w = k_w
print(f'k_p: {k_p}; k_wp: {k_wp}; k_s: {k_s}; k_w: {k_w}')

self.wp_rewards = np.zeros(len(self.trajectory))
self.max_reward_distance = max_reward_distance
Expand All @@ -57,6 +56,13 @@ def reset(self, trajectory):
self.cur_reward = RewardDict()
self.trajectory = trajectory
self.wp_rewards = np.zeros(len(self.trajectory))
self.p1 = self.trajectory[:-1]
self.p2 = self.trajectory[1:]
self.diffs = self.p2 - self.p1
self.distances = np.linalg.norm(self.p1 - self.p2, axis=1)
self.reached_distance = 0
self.current_projection_distance = 0
self.current_projection = self.trajectory[0]

def get_projections(self, position: np.ndarray):
"""
Expand Down Expand Up @@ -135,7 +141,7 @@ def compute_reward(self, drone_state: np.ndarray, reached_distance: np.ndarray,
velocity = drone_state[10:13]
velocity_norm = np.linalg.norm(velocity)
min_vel = 0.2
max_vel = 1.0
max_vel = 1.5
s_vmax = (5**(max_vel - velocity_norm)) if velocity_norm > max_vel else 1
s_min = (5**(velocity_norm - min_vel)) if velocity_norm < min_vel else 1
s_gd = np.exp(2*(self.max_reward_distance - projection_distance)) if projection_distance > self.max_reward_distance else 1
Expand Down

0 comments on commit f0b1c70

Please sign in to comment.