use matrix calculation

This commit is contained in:
Zhengyu Peng
2021-12-10 22:10:00 -05:00
parent 246f7a22cd
commit e812db544c
2 changed files with 32 additions and 45 deletions

View File

@ -89,24 +89,25 @@ def gen_fastbackward_path(standby_coordinate,
return path+np.tile(standby_coordinate, (g_steps, 1, 1))
def gen_leftturn_path(standby_coordinate):
g_steps = 20
g_radius = 25
def gen_leftturn_path(standby_coordinate,
g_steps = 20,
g_radius = 25):
assert (g_steps % 4) == 0
halfsteps = int(g_steps/2)
path = semicircle_generator(g_radius, g_steps)
mir_path = np.roll(path, halfsteps, axis=0)
path = np.zeros((g_steps, 6, 3))
leftturn = np.zeros((g_steps, 6, 3))
leftturn[:, 0, :] = np.array(path_rotate_z(path, 45))
leftturn[:, 1, :] = np.array(path_rotate_z(mir_path, 0))
leftturn[:, 2, :] = np.array(path_rotate_z(path, 315))
leftturn[:, 3, :] = np.array(path_rotate_z(mir_path, 225))
leftturn[:, 4, :] = np.array(path_rotate_z(path, 180))
leftturn[:, 5, :] = np.array(path_rotate_z(mir_path, 135))
semi_circle = semicircle_generator(g_radius, g_steps)
mir_path = np.roll(semi_circle, halfsteps, axis=0)
return leftturn+np.tile(standby_coordinate, (g_steps, 1, 1))
path[:, 0, :] = path_rotate_z(semi_circle, 45)
path[:, 1, :] = path_rotate_z(mir_path, 0)
path[:, 2, :] = path_rotate_z(semi_circle, 315)
path[:, 3, :] = path_rotate_z(mir_path, 225)
path[:, 4, :] = path_rotate_z(semi_circle, 180)
path[:, 5, :] = path_rotate_z(mir_path, 135)
return path+np.tile(standby_coordinate, (g_steps, 1, 1))
def gen_rightturn_path(standby_coordinate):
@ -119,12 +120,12 @@ def gen_rightturn_path(standby_coordinate):
mir_path = np.roll(path, halfsteps, axis=0)
rightturn = np.zeros((g_steps, 6, 3))
rightturn[:, 0, :] = np.array(path_rotate_z(path, 45+180))
rightturn[:, 1, :] = np.array(path_rotate_z(mir_path, 0+180))
rightturn[:, 2, :] = np.array(path_rotate_z(path, 315+180))
rightturn[:, 3, :] = np.array(path_rotate_z(mir_path, 225+180))
rightturn[:, 4, :] = np.array(path_rotate_z(path, 180+180))
rightturn[:, 5, :] = np.array(path_rotate_z(mir_path, 135+180))
rightturn[:, 0, :] = path_rotate_z(path, 45+180)
rightturn[:, 1, :] = path_rotate_z(mir_path, 0+180)
rightturn[:, 2, :] = path_rotate_z(path, 315+180)
rightturn[:, 3, :] = path_rotate_z(mir_path, 225+180)
rightturn[:, 4, :] = path_rotate_z(path, 180+180)
rightturn[:, 5, :] = path_rotate_z(mir_path, 135+180)
return rightturn+np.tile(standby_coordinate, (g_steps, 1, 1))