Exemple #1
0
 def draw_rotate_rec(x, y, a, l, w, color, linestyle='-'):
     RU_x, RU_y, _ = rotate_coordination(l / 2, w / 2, 0, -a)
     RD_x, RD_y, _ = rotate_coordination(l / 2, -w / 2, 0, -a)
     LU_x, LU_y, _ = rotate_coordination(-l / 2, w / 2, 0, -a)
     LD_x, LD_y, _ = rotate_coordination(-l / 2, -w / 2, 0, -a)
     ax.plot([RU_x + x, RD_x + x], [RU_y + y, RD_y + y], color=color, linestyle=linestyle)
     ax.plot([RU_x + x, LU_x + x], [RU_y + y, LU_y + y], color=color, linestyle=linestyle)
     ax.plot([LD_x + x, RD_x + x], [LD_y + y, RD_y + y], color=color, linestyle=linestyle)
     ax.plot([LD_x + x, LU_x + x], [LD_y + y, LU_y + y], color=color, linestyle=linestyle)
Exemple #2
0
 def recover_orig_position_fn(self, transformed_x, transformed_y, x, y,
                              d):  # x, y, d are used to transform
     # coordination
     transformed_x, transformed_y, _ = rotate_coordination(
         transformed_x, transformed_y, 0, -d)
     orig_x, orig_y = shift_coordination(transformed_x, transformed_y, -x,
                                         -y)
     return orig_x, orig_y
Exemple #3
0
 def draw_rotate_rec(x, y, a, l, w, c):
     bottom_left_x, bottom_left_y, _ = rotate_coordination(
         -l / 2, w / 2, 0, -a)
     ax.add_patch(
         plt.Rectangle((x + bottom_left_x, y + bottom_left_y),
                       w,
                       l,
                       edgecolor=c,
                       facecolor='white',
                       angle=-(90 - a),
                       zorder=50))
Exemple #4
0
 def reset(self):
     self.multiego.reset(copy.deepcopy(self.init_n_ego_dict))
     self.traffic.init_traffic(copy.deepcopy(self.init_n_ego_dict))
     self.traffic.sim_step()
     n_ego_traj = {egoID: self.multiego.mpp.generate_path(NAME2TASK[egoID[:2]]) for egoID in
                   self.multiego.n_ego_dynamics.keys()}
     self.n_ego_traj_trans = {}
     for egoID, ego_traj in n_ego_traj.items():
         traj_list = []
         for item in ego_traj:
             temp = np.array([rotate_coordination(x, y, 0, -ROTATE_ANGLE[egoID[0]])[0] for x, y in
                              zip(item.path[0], item.path[1])]), \
                    np.array([rotate_coordination(x, y, 0, -ROTATE_ANGLE[egoID[0]])[1] for x, y in
                              zip(item.path[0], item.path[1])])
             traj_list.append(temp)
         self.n_ego_traj_trans[egoID] = traj_list
     self.hist_posi = {egoID: [] for egoID in self.init_n_ego_dict.keys()}
     if self.logdir is not None:
         self.episode_counter += 1
         self.step_counter = -1
         os.makedirs(self.logdir + '/episode{}/figs'.format(self.episode_counter))
         if self.episode_counter >= 1:
             select_and_rename_snapshots_of_an_episode(self.logdir, self.episode_counter - 1, 12)