-
Notifications
You must be signed in to change notification settings - Fork 0
/
traj_utils.py
41 lines (29 loc) · 1.06 KB
/
traj_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import numpy as np
class Trajectory:
def __init__(self, Ts, T):
self.T = T
self.Ts = Ts
self.samples = int(T/Ts)
self.x_traj = np.zeros(self.samples)
self.y_traj = np.zeros(self.samples)
self.z_traj = np.zeros(self.samples)
self.times = np.linspace(0, T, num=self.samples)
def CircularTraj(self, R, theta):
omega = 90/(np.pi*self.T)
self.z_traj = R*np.sin(omega*self.times)
self.x_traj = np.cos(theta)*R*np.cos(omega*self.times)
self.y_traj = np.sin(theta)*R*np.cos(omega*self.times)
def LinearTraj(self, m):
self.x_traj = m*self.times
self.y_traj = m*self.times
self.z_traj = m*self.times
pass
def EightTraj(self, Ts, T):
pass
def getReferences(self, N, t_step):
R = np.zeros((12, N))
start_index = int(t_step)
R[0, :] = self.x_traj[start_index:start_index + N]
R[1, :] = self.y_traj[start_index:start_index + N]
R[2, :] = self.z_traj[start_index:start_index + N]
return R