Skip to content

Commit a4a8591

Browse files
committed
fix test and code clean up for lgtm
1 parent 404cc79 commit a4a8591

File tree

11 files changed

+54
-56
lines changed

11 files changed

+54
-56
lines changed

AerialNavigation/drone_3d_trajectory_following/Quadrotor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from math import cos, sin
88
import numpy as np
99
import matplotlib.pyplot as plt
10-
from mpl_toolkits.mplot3d import Axes3D
1110

1211

1312
class Quadrotor():

AerialNavigation/drone_3d_trajectory_following/drone_3d_trajectory_following.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import numpy as np
99
from Quadrotor import Quadrotor
1010
from TrajectoryGenerator import TrajectoryGenerator
11+
from mpl_toolkits.mplot3d import Axes3D
1112

1213
show_animation = True
1314

@@ -69,8 +70,8 @@ def quad_sim(x_c, y_c, z_c):
6970

7071
while True:
7172
while t <= T:
72-
des_x_pos = calculate_position(x_c[i], t)
73-
des_y_pos = calculate_position(y_c[i], t)
73+
# des_x_pos = calculate_position(x_c[i], t)
74+
# des_y_pos = calculate_position(y_c[i], t)
7475
des_z_pos = calculate_position(z_c[i], t)
7576
des_x_vel = calculate_velocity(x_c[i], t)
7677
des_y_vel = calculate_velocity(y_c[i], t)

ArmNavigation/n_joint_arm_to_point_control/n_joint_arm_to_point_control.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
Author: Daniel Ingram (daniel-s-ingram)
55
Atsushi Sakai (@Atsushi_twi)
66
"""
7-
import matplotlib.pyplot as plt
87
import numpy as np
98

109
from NLinkArm import NLinkArm
@@ -34,8 +33,8 @@ def main():
3433
state = WAIT_FOR_NEW_GOAL
3534
solution_found = False
3635
while True:
37-
old_goal = np.ndarray(goal_pos)
38-
goal_pos = arm.goal
36+
old_goal = np.array(goal_pos)
37+
goal_pos = np.array(arm.goal)
3938
end_effector = arm.end_effector
4039
errors, distance = distance_to_goal(end_effector, goal_pos)
4140

@@ -160,5 +159,5 @@ def ang_diff(theta1, theta2):
160159

161160

162161
if __name__ == '__main__':
163-
# main()
164-
animation()
162+
main()
163+
# animation()

PathPlanning/BatchInformedRRTStar/batch_informed_rrtstar.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ def expandVertex(self, vid):
459459
# add an edge to the edge queue is the path might improve the solution
460460
for neighbor in neigbors:
461461
sid = neighbor[0]
462-
scoord = neighbor[1]
463462
estimated_f_score = self.computeDistanceCost(
464463
self.startId, vid) + self.computeHeuristicCost(sid, self.goalId) + self.computeDistanceCost(vid, sid)
465464
if estimated_f_score < self.g_scores[self.goalId]:

PathPlanning/ClosedLoopRRTStar/pure_pursuit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def main():
269269
# plt.pause(0.1)
270270
# input()
271271

272-
flg, ax = plt.subplots(1)
272+
plt.subplots(1)
273273
plt.plot(cx, cy, ".r", label="course")
274274
plt.plot(x, y, "-b", label="trajectory")
275275
plt.legend()
@@ -278,7 +278,7 @@ def main():
278278
plt.axis("equal")
279279
plt.grid(True)
280280

281-
flg, ax = plt.subplots(1)
281+
subplots(1)
282282
plt.plot(t, [iv * 3.6 for iv in v], "-r")
283283
plt.xlabel("Time[s]")
284284
plt.ylabel("Speed[km/h]")
@@ -304,7 +304,7 @@ def main2():
304304
t, x, y, yaw, v, a, d, flag = closed_loop_prediction(
305305
cx, cy, cyaw, speed_profile, goal)
306306

307-
flg, ax = plt.subplots(1)
307+
plt.subplots(1)
308308
plt.plot(cx, cy, ".r", label="course")
309309
plt.plot(x, y, "-b", label="trajectory")
310310
plt.plot(goal[0], goal[1], "xg", label="goal")
@@ -314,7 +314,7 @@ def main2():
314314
plt.axis("equal")
315315
plt.grid(True)
316316

317-
flg, ax = plt.subplots(1)
317+
plt.subplots(1)
318318
plt.plot(t, [iv * 3.6 for iv in v], "-r")
319319
plt.xlabel("Time[s]")
320320
plt.ylabel("Speed[km/h]")

PathPlanning/Eta3SplinePath/eta3_spline_path.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,9 @@ def __init__(self, start_pose, end_pose, eta=None, kappa=None):
152152
+ (10. * eta[1] - 2. * eta[3] + 1. / 6 * eta[5]) * sb \
153153
- (2. * eta[1]**2 * kappa[2] - 1. / 6 * eta[1]**3 *
154154
kappa[3] - 1. / 2 * eta[1] * eta[3] * kappa[2]) * cb
155-
156-
s_dot = lambda u : np.linalg.norm(self.coeffs[:, 1:].dot(np.array([1, 2.*u, 3.*u**2, 4.*u**3, 5.*u**4, 6.*u**5, 7.*u**6])))
155+
156+
def s_dot(u): return np.linalg.norm(self.coeffs[:, 1:].dot(
157+
np.array([1, 2. * u, 3. * u**2, 4. * u**3, 5. * u**4, 6. * u**5, 7. * u**6])))
157158
self.segment_length = quad(lambda u: s_dot(u), 0, 1)[0]
158159

159160
"""
@@ -164,6 +165,7 @@ def __init__(self, start_pose, end_pose, eta=None, kappa=None):
164165
returns
165166
(x,y) of point along the segment
166167
"""
168+
167169
def calc_point(self, u):
168170
assert(u >= 0 and u <= 1)
169171
return self.coeffs.dot(np.array([1, u, u**2, u**3, u**4, u**5, u**6, u**7]))
@@ -187,8 +189,8 @@ def test1():
187189
# interpolate at several points along the path
188190
ui = np.linspace(0, len(path_segments), 1001)
189191
pos = np.empty((2, ui.size))
190-
for i, u in enumerate(ui):
191-
pos[:, i] = path.calc_path_point(u)
192+
for j, u in enumerate(ui):
193+
pos[:, j] = path.calc_path_point(u)
192194

193195
if show_animation:
194196
# plot the path
@@ -217,8 +219,8 @@ def test2():
217219
# interpolate at several points along the path
218220
ui = np.linspace(0, len(path_segments), 1001)
219221
pos = np.empty((2, ui.size))
220-
for i, u in enumerate(ui):
221-
pos[:, i] = path.calc_path_point(u)
222+
for j, u in enumerate(ui):
223+
pos[:, j] = path.calc_path_point(u)
222224

223225
if show_animation:
224226
# plot the path

PathPlanning/HybridAStar/hybrid_a_star.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import numpy as np
1414
import scipy.spatial
1515
import matplotlib.pyplot as plt
16-
import reeds_shepp_path_planning as rs
16+
# import reeds_shepp_path_planning as rs
1717
import heapq
1818

1919
EXTEND_AREA = 5.0 # [m]
@@ -118,40 +118,40 @@ def hybrid_a_star_planning(start, goal, ox, oy, xyreso, yawreso):
118118
yawreso: yaw angle resolution [rad]
119119
"""
120120

121-
start[2], goal[2] = rs.pi_2_pi(start[2]), rs.pi_2_pi(goal[2])
122-
tox, toy = ox[:], oy[:]
121+
# start[2], goal[2] = rs.pi_2_pi(start[2]), rs.pi_2_pi(goal[2])
122+
# tox, toy = ox[:], oy[:]
123123

124-
obkdtree = KDTree(np.vstack((tox, toy)).T)
124+
# obkdtree = KDTree(np.vstack((tox, toy)).T)
125125

126-
c = Config(tox, toy, xyreso, yawreso)
126+
# c = Config(tox, toy, xyreso, yawreso)
127127

128-
nstart = Node(int(start[0] / xyreso), int(start[1] / xyreso), int(start[2] / yawreso),
129-
True, [start[0]], [start[1]], [start[2]], [True], 0.0, 0.0, -1)
130-
ngoal = Node(int(goal[0] / xyreso), int(goal[1] / xyreso), int(goal[2] / yawreso),
131-
True, [goal[0]], [goal[1]], [goal[2]], [True], 0.0, 0.0, -1)
128+
# nstart = Node(int(start[0] / xyreso), int(start[1] / xyreso), int(start[2] / yawreso),
129+
# True, [start[0]], [start[1]], [start[2]], [True], 0.0, 0.0, -1)
130+
# ngoal = Node(int(goal[0] / xyreso), int(goal[1] / xyreso), int(goal[2] / yawreso),
131+
# True, [goal[0]], [goal[1]], [goal[2]], [True], 0.0, 0.0, -1)
132132

133-
openList, closedList = {}, {}
134-
h = []
135-
# goalqueue = queue.PriorityQueue()
136-
pq = []
137-
openList[calc_index(nstart, c)] = nstart
138-
heapq.heappush(pq, (calc_index(nstart, c), calc_cost(nstart, h, ngoal, c)))
133+
# openList, closedList = {}, {}
134+
# h = []
135+
# # goalqueue = queue.PriorityQueue()
136+
# pq = []
137+
# openList[calc_index(nstart, c)] = nstart
138+
# heapq.heappush(pq, (calc_index(nstart, c), calc_cost(nstart, h, ngoal, c)))
139139

140-
while True:
141-
if not openList:
142-
print("Error: Cannot find path, No open set")
143-
return [], [], []
140+
# while True:
141+
# if not openList:
142+
# print("Error: Cannot find path, No open set")
143+
# return [], [], []
144144

145-
c_id, cost = heapq.heappop(pq)
146-
current = openList.pop(c_id)
147-
closedList[c_id] = current
145+
# c_id, cost = heapq.heappop(pq)
146+
# current = openList.pop(c_id)
147+
# closedList[c_id] = current
148148

149-
isupdated, fpath = analytic_expantion(
150-
current, ngoal, c, ox, oy, obkdtree)
149+
# isupdated, fpath = analytic_expantion(
150+
# current, ngoal, c, ox, oy, obkdtree)
151151

152-
# print(current)
152+
# # print(current)
153153

154-
# rx, ry, ryaw = [], [], []
154+
rx, ry, ryaw = [], [], []
155155

156156
return rx, ry, ryaw
157157

@@ -208,8 +208,8 @@ def main():
208208
start, goal, ox, oy, xyreso, yawreso)
209209

210210
plt.plot(ox, oy, ".k")
211-
rs.plot_arrow(start[0], start[1], start[2])
212-
rs.plot_arrow(goal[0], goal[1], goal[2])
211+
# rs.plot_arrow(start[0], start[1], start[2])
212+
# rs.plot_arrow(goal[0], goal[1], goal[2])
213213

214214
plt.grid(True)
215215
plt.axis("equal")

PathPlanning/PotentialFieldPlanning/potential_field_planning.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ def main():
160160
rx, ry = potential_field_planning(
161161
sx, sy, gx, gy, ox, oy, grid_size, robot_radius)
162162

163+
print(rx)
164+
print(ry)
165+
163166
if show_animation:
164167
plt.show()
165168

PathPlanning/RRTStarDubins/dubins_path_planning.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
"""
88
import math
9+
import matplotlib.pyplot as plt
910

1011

1112
def mod2pi(theta):
@@ -260,7 +261,6 @@ def plot_arrow(x, y, yaw, length=1.0, width=0.5, fc="r", ec="k"):
260261
u"""
261262
Plot arrow
262263
"""
263-
import matplotlib.pyplot as plt
264264

265265
if not isinstance(x, float):
266266
for (ix, iy, iyaw) in zip(x, y, yaw):
@@ -273,7 +273,6 @@ def plot_arrow(x, y, yaw, length=1.0, width=0.5, fc="r", ec="k"):
273273

274274
if __name__ == '__main__':
275275
print("Dubins path planner sample start!!")
276-
import matplotlib.pyplot as plt
277276

278277
start_x = 1.0 # [m]
279278
start_y = 1.0 # [m]

PathPlanning/ReedsSheppPath/reeds_shepp_path_planning.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,6 @@ def generate_local_course(L, lengths, mode, maxc, step_size):
285285
else:
286286
directions[0] = -1
287287

288-
if lengths[0] > 0.0:
289-
d = step_size
290-
else:
291-
d = -step_size
292-
293288
ll = 0.0
294289

295290
for (m, l, i) in zip(mode, lengths, range(len(mode))):

0 commit comments

Comments
 (0)