@@ -59,12 +59,10 @@ def longitudinal_plan_milestone(path : Path, acceleration : float, deceleration
5959 yarange = [point [1 ]]* len (xarange )
6060 else :
6161 yarange = np .arange (point [1 ], next_point [1 ], (next_point [1 ] - point [1 ])/ factor )
62- print (yarange )
6362 for x , y in zip (xarange , yarange ):
6463 new_points .append ((x , y ))
6564 new_points .append (path .points [- 1 ])
6665
67- print ("new points" , new_points )
6866 path = Path (path .frame , new_points )
6967
7068 path_normalized = path .arc_length_parameterize ()
@@ -92,27 +90,20 @@ def longitudinal_plan_milestone(path : Path, acceleration : float, deceleration
9290
9391 while current_speed > 0 or cur_index == 0 :
9492 # we want to iterate through all the points and add them
95- # to the new points. However, we also want to add "critical points"
93+ # to the new points. However, we also want to add "switch points"
9694 # where we reach top speed, begin decelerating, and stop
9795 new_points .append (cur_point )
9896 new_times .append (cur_time )
9997 velocities .append (current_speed )
100- # print("=====================================")
101- # print("new points: ", new_points)
102- # print("current index: ", cur_index)
103- # print("current speed: ", current_speed)
104- # print("current position: ", cur_point)
10598
10699 # Information we will need:
107- # Calculate how much time it would take to stop
108- # Calculate how much distance it would take to stop
100+ # Calculate how much time it would take to stop
101+ # Calculate how much distance it would take to stop
109102 min_delta_t_stop = current_speed / deceleration
110103 min_delta_x_stop = current_speed * min_delta_t_stop - 0.5 * deceleration * min_delta_t_stop ** 2
111104 # print(min_delta_x_stop)
112105 assert min_delta_x_stop >= 0
113106
114- # Check if we are done
115-
116107 # If we cannot stop before or stop exactly at the final position requested
117108 if cur_point [0 ] + min_delta_x_stop >= points [- 1 ][0 ]:
118109 # put on the breaks
@@ -147,7 +138,6 @@ def longitudinal_plan_milestone(path : Path, acceleration : float, deceleration
147138 # because the first if-statement covers for when we decelerating,
148139 # the only time current_speed < max_speed is when we are accelerating
149140 elif current_speed < max_speed :
150- # print("In case two")
151141 # next point
152142 next_point = points [cur_index + 1 ]
153143 # accelerate to max speed
@@ -168,7 +158,7 @@ def longitudinal_plan_milestone(path : Path, acceleration : float, deceleration
168158 # just move to the next point and update the current speed and time
169159 if next_point [0 ] + delta_x_to_stop_from_next_point < points [- 1 ][0 ] and \
170160 cur_point [0 ] + delta_x_to_max_speed >= next_point [0 ]:
171- # (" go to next point")
161+ # go to next point
172162 # accelerate to max speed
173163 delta_t_to_next_x = compute_time_to_x (cur_point [0 ], next_point [0 ], current_speed , acceleration )
174164 cur_time += delta_t_to_next_x
@@ -179,13 +169,8 @@ def longitudinal_plan_milestone(path : Path, acceleration : float, deceleration
179169 # This is the case where we would need to start breaking before reaching
180170 # top speed and before the next point (i.e. triangle shape velocity)
181171 elif cur_point [0 ] + delta_x_to_max_speed + delta_x_to_stop_from_max_speed >= points [- 1 ][0 ]:
182- # print(delta_x_to_max_speed)
183- # print(delta_x_to_stop_from_max_speed)
184172 # Add a new point at the point where we should start breaking
185- # print("Adding new point to start breaking")
186173 delta_t_to_next_x = compute_time_triangle (cur_point [0 ], points [- 1 ][0 ], current_speed , 0 , acceleration , deceleration )
187- # print(delta_t_to_next_x)
188- #delta_t_to_next_x = compute_time_to_x(cur_point[0], points[-1][0] - min_delta_x_stop, current_speed, acceleration)
189174 next_x = cur_point [0 ] + current_speed * delta_t_to_next_x + 0.5 * acceleration * delta_t_to_next_x ** 2
190175 cur_time += delta_t_to_next_x
191176 cur_point = [next_x , 0 ]
@@ -194,7 +179,6 @@ def longitudinal_plan_milestone(path : Path, acceleration : float, deceleration
194179 # this is the case where we would reach max speed before the next point
195180 # we need to create a new point where we would reach max speed
196181 else :
197- # print("adding new point")
198182 # we would need to add a new point at max speed
199183 cur_time += delta_t_to_max_speed
200184 cur_point = [cur_point [0 ] + delta_x_to_max_speed , 0 ]
@@ -207,17 +191,14 @@ def longitudinal_plan_milestone(path : Path, acceleration : float, deceleration
207191 elif current_speed == max_speed :
208192 next_point = points [cur_index + 1 ]
209193 # continue on with max speed
210- # print("In case three")
211194
212195 # add point to start decelerating
213196 if next_point [0 ] + min_delta_x_stop >= points [- 1 ][0 ]:
214- # print("Adding new point to start decelerating")
215197 cur_time += (points [- 1 ][0 ] - min_delta_x_stop - cur_point [0 ])/ current_speed
216198 cur_point = [points [- 1 ][0 ] - min_delta_x_stop ,0 ]
217199 current_speed = max_speed
218200 else :
219201 # Continue on to next point
220- # print("Continuing on to next point")
221202 cur_time += (next_point [0 ] - cur_point [0 ])/ current_speed
222203 cur_point = next_point
223204 cur_index += 1
@@ -228,7 +209,6 @@ def longitudinal_plan_milestone(path : Path, acceleration : float, deceleration
228209 # We need to hit the breaks
229210
230211 next_point = points [cur_index + 1 ]
231- # print("In case four")
232212 # slow down to max speed
233213 delta_t_to_max_speed = (current_speed - max_speed )/ deceleration
234214 delta_x_to_max_speed = current_speed * delta_t_to_max_speed - 0.5 * deceleration * delta_t_to_max_speed ** 2
0 commit comments