-
Notifications
You must be signed in to change notification settings - Fork 0
/
traj_tracker.py
78 lines (64 loc) · 2.21 KB
/
traj_tracker.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import time
import math
import random
from traj_planner_utils import *
TIME_STEP_SIZE = 0.01 #s
LOOK_AHEAD_TIME = 1.0 #s
MIN_DIST_TO_POINT = 0.15 #m
MIN_ANG_TO_POINT = 0.15 #rad
class TrajectoryTracker():
""" A class to hold the functionality for tracking trajectories.
Arguments:
traj (list of lists): A list of traj points Time, X, Y, Theta (s, m, m, rad).
"""
current_point_to_track = 0
traj_tracked = False
traj = []
def __init__(self, traj):
self.current_point_to_track = 0
self.traj = traj
self.traj_tracked = False
def get_traj_point_to_track(self, current_state):
""" Determine which point of the traj should be tracked at the current time.
Arguments:
current_state (list of floats): The current Time, X, Y, Theta (s, m, m, rad).
Returns:
desired_state (list of floats: The desired state to track - Time, X, Y, Theta (s, m, m, rad).
"""
# Add code here.
return self.traj[0]
def print_traj(self):
""" Print the trajectory points.
"""
print("Traj:")
for i in range(len(self.traj)):
print(i,self.traj[i])
def is_traj_tracked(self):
""" Return true if the traj is tracked.
Returns:
traj_tracked (boolean): True if traj has been tracked.
"""
return self.traj_tracked
class PointTracker():
""" A class to determine actions (motor control signals) for driving a robot to a position.
"""
def __init__(self):
pass
def get_dummy_action(self, x_des, x):
""" Return a dummy action for now
"""
action = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
return action
def point_tracking_control(self, desired_state, current_state):
""" Return the motor control signals as actions to drive a robot to a desired configuration
Arguments:
desired_state (list of floats): The desired Time, X, Y, Theta (s, m, m, rad).
current_state (lis5t of floats): The current Time, X, Y, Theta (s, m, m, rad).
"""
# zero all of action
action = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
# Add code here.
# Set the control vector U
action[0] = 0
action[1] = 0
return action