def update_stats(self, sim): # This function is overly simple; it assumes that the robots are in the convoy # in the same order in which they are stored (0th is leader, 1st is first follower, etc) for r in range(len(self.robots) - 1): pose0 = sim.get_pose2d(self.robots[r].name) pose1 = sim.get_pose2d(self.robots[r + 1].name) self.dist_sum = self.dist_sum + Basic_Manager._dist(pose0[1], pose0[2], pose1[1], pose1[2]) self.dist_count = self.dist_count + 1 return
def final_stats(self, sim): dists = Basic_Manager.getDistances(self.robots, sim) ret_str = "\tAvg_Dist: " + str(self.dist_sum / self.dist_count) for dist in range(len(dists)): ret_str = ret_str + "\tdist_" + str(dist) + ": " + str(dists[dist]) # reset other stats self.dist_sum = 0 self.dist_count = 0 return ret_str