-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrajectory.py
58 lines (48 loc) · 1.42 KB
/
trajectory.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import numpy as np
class Trajectory(object):
"""
A class representing a trajectory.
Attributes:
debug (bool): A flag indicating whether debug mode is enabled.
time (float): The current time of the trajectory.
dof (int): The number of degrees of freedom.
trajectory (list): The list of trajectory functions for each degree of freedom.
Methods:
__call__(time): Evaluates the trajectory at a given time and returns the corresponding point.
"""
def __init__(self, debug=True):
self._debug = debug
self._trajectory = None
self._time = 0
self._dof = 0
self._p_logged = 0
@property
def debug(self):
return self._debug
@debug.setter
def debug(self, v):
self._debug = v
@property
def time(self):
return self._time
@time.setter
def time(self, v):
self._time = v
@property
def dof(self):
return self._dof
@dof.setter
def dof(self, v):
self._dof = v
@property
def trajectory(self):
return self._trajectory
@trajectory.setter
def trajectory(self, v):
self._trajectory = v
def __call__(self, time):
point = np.zeros((self.dof, 3), dtype=np.float32)
for t, dof in zip(self.trajectory, range(self.dof)):
dof_point = t(time)
np.put(point[dof], range(3), dof_point)
return point