Skip to content

Commit

Permalink
fix coordinate
Browse files Browse the repository at this point in the history
  • Loading branch information
strakam committed Jan 23, 2024
1 parent 6ecc319 commit 4e49452
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion agents/follower.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
DEFAULT_ACT = ActionType('rpm') # 'rpm' or 'pid' or 'vel' or 'one_d_rpm' or 'one_d_pid'
DEFAULT_AGENTS = 1
DEFAULT_MA = False
DEFAULT_TIMESTEPS = 8e5
DEFAULT_TIMESTEPS = 1.3e6

def run(multiagent=DEFAULT_MA, output_folder=DEFAULT_OUTPUT_FOLDER,
gui=DEFAULT_GUI, plot=True, colab=DEFAULT_COLAB,
Expand Down
6 changes: 3 additions & 3 deletions aviaries/FollowerAviary.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ def __init__(self,
self.NUM_DRONES = 1

self.INIT_XYZS = initial_xyzs
self.trajectory = target_trajectory
self.trajectory = [x.coordinate for x in target_trajectory]

self.n_waypoints = len(self.trajectory)
self.WAYPOINT_BUFFER_SIZE = 3 # how many steps into future to interpolate
self.current_waypoint_idx = 0
assert self.WAYPOINT_BUFFER_SIZE < self.n_waypoints, "Buffer size should be smaller than the number of waypoints"

self.waypoint_buffer = np.array(
[self.trajectory[i].coordinate for i in range(self.WAYPOINT_BUFFER_SIZE)]
[self.trajectory[i] for i in range(self.WAYPOINT_BUFFER_SIZE)]
)

super().__init__(
Expand Down Expand Up @@ -205,7 +205,7 @@ def update_waypoints(self):
if np.linalg.norm(drone_position - current_waypoint) < .001:
# replace reached waypoint with the waypoint that follows after all waypoints in the buffer
next_waypoint_idx = int(self.current_waypoint_idx + len(self.waypoint_buffer)) % len(self.trajectory)
next_waypoint = self.trajectory[next_waypoint_idx].coordinate
next_waypoint = self.trajectory[next_waypoint_idx]
self.waypoint_buffer[self.current_waypoint_idx] = next_waypoint
# set next waypoint
self.current_waypoint_idx = (self.current_waypoint_idx + 1) % self.WAYPOINT_BUFFER_SIZE
Expand Down

0 comments on commit 4e49452

Please sign in to comment.