add backward move

master
Zhengyu Peng 3 years ago
parent 09b9ba609d
commit 5c26cd09ca

@ -11,7 +11,7 @@ from leg import Leg
import numpy as np import numpy as np
import time import time
import json import json
from path_generator import forward_path from path_generator import forward_path, backward_path
SIN30 = 0.5 SIN30 = 0.5
@ -93,6 +93,11 @@ class Hexapod:
for mm in range(0, 30): for mm in range(0, 30):
self.move(full_path, 0.005) self.move(full_path, 0.005)
full_path = backward_path()
for mm in range(0, 30):
self.move(full_path, 0.005)
def move(self, path, interval): def move(self, path, interval):
for p_idx in range(0, np.shape(path)[0]): for p_idx in range(0, np.shape(path)[0]):
dest = path[p_idx, :, :]+self.standby_coordinate dest = path[p_idx, :, :]+self.standby_coordinate

@ -20,3 +20,23 @@ def forward_path():
path[:, 5, :] = mir_path path[:, 5, :] = mir_path
return path return path
def backward_path():
# assert (g_steps % 4) == 0
g_steps = 20
g_radius = 25
halfsteps = int(g_steps/2)
path = np.zeros((g_steps, 6, 3))
path[:, 0, :] = semicircle_generator(g_radius, g_steps, reverse=True)
mir_path = np.roll(path[:, 0, :], halfsteps, axis=0)
path[:, 2, :] = path[:, 0, :]
path[:, 4, :] = path[:, 0, :]
path[:, 1, :] = mir_path
path[:, 3, :] = mir_path
path[:, 5, :] = mir_path
return path

Loading…
Cancel
Save