Skip to content

Commit 3a7f3c5

Browse files
committed
code clean up for lgtm
1 parent 8dcc6f0 commit 3a7f3c5

File tree

18 files changed

+69
-80
lines changed

18 files changed

+69
-80
lines changed

ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class NLinkArm(object):
210210

211211
def __init__(self, link_lengths, joint_angles):
212212
self.n_links = len(link_lengths)
213-
if self.n_links is not len(joint_angles):
213+
if self.n_links != len(joint_angles):
214214
raise ValueError()
215215

216216
self.link_lengths = np.array(link_lengths)

ArmNavigation/n_joint_arm_to_point_control/NLinkArm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class NLinkArm(object):
1212
def __init__(self, link_lengths, joint_angles, goal, show_animation):
1313
self.show_animation = show_animation
1414
self.n_links = len(link_lengths)
15-
if self.n_links is not len(joint_angles):
15+
if self.n_links != len(joint_angles):
1616
raise ValueError()
1717

1818
self.link_lengths = np.array(link_lengths)

ArmNavigation/n_joint_arm_to_point_control/n_joint_arm_to_point_control.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def main():
5151
elif solution_found:
5252
state = MOVING_TO_GOAL
5353
elif state is MOVING_TO_GOAL:
54-
if distance > 0.1 and (old_goal is goal_pos):
54+
if distance > 0.1 and (old_goal == goal_pos).all():
5555
joint_angles = joint_angles + Kp * \
5656
ang_diff(joint_goal_angles, joint_angles) * dt
5757
else:
@@ -111,7 +111,7 @@ def animation():
111111
elif solution_found:
112112
state = MOVING_TO_GOAL
113113
elif state is MOVING_TO_GOAL:
114-
if distance > 0.1 and (old_goal is goal_pos):
114+
if distance > 0.1 and (old_goal == goal_pos).all():
115115
joint_angles = joint_angles + Kp * \
116116
ang_diff(joint_goal_angles, joint_angles) * dt
117117
else:

PathPlanning/BatchInformedRRTStar/batch_informed_rrtstar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def add_vertex_to_edge_queue(self, vid, currCoord):
474474
for v, edges in self.tree.vertices.items():
475475
if v != vid and (v, vid) not in self.edge_queue and (vid, v) not in self.edge_queue:
476476
vcoord = self.tree.nodeIdToRealWorldCoord(v)
477-
if(np.linalg.norm(vcoord - currCoord, 2) <= self.r and v != vid):
477+
if(np.linalg.norm(vcoord - currCoord, 2) <= self.r):
478478
neigbors.append((vid, vcoord))
479479

480480
for neighbor in neigbors:

PathPlanning/ClosedLoopRRTStar/closed_loop_rrt_star_car.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -427,34 +427,33 @@ def main():
427427
if not flag:
428428
print("cannot find feasible path")
429429

430-
# flg, ax = plt.subplots(1)
431430
# Draw final path
432431
if show_animation:
433432
rrt.DrawGraph()
434433
plt.plot(x, y, '-r')
435434
plt.grid(True)
436435
plt.pause(0.001)
437436

438-
flg, ax = plt.subplots(1)
437+
plt.subplots(1)
439438
plt.plot(t, [np.rad2deg(iyaw) for iyaw in yaw[:-1]], '-r')
440439
plt.xlabel("time[s]")
441440
plt.ylabel("Yaw[deg]")
442441
plt.grid(True)
443442

444-
flg, ax = plt.subplots(1)
443+
plt.subplots(1)
445444
plt.plot(t, [iv * 3.6 for iv in v], '-r')
446445

447446
plt.xlabel("time[s]")
448447
plt.ylabel("velocity[km/h]")
449448
plt.grid(True)
450449

451-
flg, ax = plt.subplots(1)
450+
plt.subplots(1)
452451
plt.plot(t, a, '-r')
453452
plt.xlabel("time[s]")
454453
plt.ylabel("accel[m/ss]")
455454
plt.grid(True)
456455

457-
flg, ax = plt.subplots(1)
456+
plt.subplots(1)
458457
plt.plot(t, [np.rad2deg(td) for td in d], '-r')
459458
plt.xlabel("time[s]")
460459
plt.ylabel("Steering angle[deg]")

PathPlanning/ClosedLoopRRTStar/pure_pursuit.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#! /usr/bin/python
2-
# -*- coding: utf-8 -*-
3-
u"""
1+
"""
42
53
Path tracking simulation with pure pursuit steering control and PID speed control.
64
@@ -251,7 +249,7 @@ def main():
251249

252250
while T >= time and lastIndex > target_ind:
253251
ai = PIDControl(target_speed, state.v)
254-
di, target_ind = pure_pursuit_control(state, cx, cy, target_ind)
252+
di, target_ind, _ = pure_pursuit_control(state, cx, cy, target_ind)
255253
state = unicycle_model.update(state, ai, di)
256254

257255
time = time + unicycle_model.dt

PathPlanning/ClosedLoopRRTStar/unicycle_model.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"""
88

99
import math
10+
import numpy as np
1011

1112
dt = 0.05 # [s]
1213
L = 0.9 # [m]
@@ -66,12 +67,12 @@ def pi_2_pi(angle):
6667
yaw.append(state.yaw)
6768
v.append(state.v)
6869

69-
flg, ax = plt.subplots(1)
70+
plt.subplots(1)
7071
plt.plot(x, y)
7172
plt.axis("equal")
7273
plt.grid(True)
7374

74-
flg, ax = plt.subplots(1)
75+
plt.subplots(1)
7576
plt.plot(v)
7677
plt.grid(True)
7778

PathPlanning/CubicSpline/cubic_spline_planner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def main():
209209
ryaw.append(sp.calc_yaw(i_s))
210210
rk.append(sp.calc_curvature(i_s))
211211

212-
flg, ax = plt.subplots(1)
212+
plt.subplots(1)
213213
plt.plot(x, y, "xb", label="input")
214214
plt.plot(rx, ry, "-r", label="spline")
215215
plt.grid(True)
@@ -218,14 +218,14 @@ def main():
218218
plt.ylabel("y[m]")
219219
plt.legend()
220220

221-
flg, ax = plt.subplots(1)
221+
plt.subplots(1)
222222
plt.plot(s, [np.rad2deg(iyaw) for iyaw in ryaw], "-r", label="yaw")
223223
plt.grid(True)
224224
plt.legend()
225225
plt.xlabel("line length[m]")
226226
plt.ylabel("yaw angle[deg]")
227227

228-
flg, ax = plt.subplots(1)
228+
plt.subplots(1)
229229
plt.plot(s, rk, "-r", label="curvature")
230230
plt.grid(True)
231231
plt.legend()

PathPlanning/DubinsPath/dubins_path_planning.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,18 @@ def generate_course(length, mode, c):
235235
elif m is "R": # right turn
236236
pyaw.append(pyaw[-1] - d)
237237
pd += d
238-
else:
239-
d = l - pd
240-
px.append(px[-1] + d / c * math.cos(pyaw[-1]))
241-
py.append(py[-1] + d / c * math.sin(pyaw[-1]))
242238

243-
if m is "L": # left turn
244-
pyaw.append(pyaw[-1] + d)
245-
elif m is "S": # Straight
246-
pyaw.append(pyaw[-1])
247-
elif m is "R": # right turn
248-
pyaw.append(pyaw[-1] - d)
249-
pd += d
239+
d = l - pd
240+
px.append(px[-1] + d / c * math.cos(pyaw[-1]))
241+
py.append(py[-1] + d / c * math.sin(pyaw[-1]))
242+
243+
if m is "L": # left turn
244+
pyaw.append(pyaw[-1] + d)
245+
elif m is "S": # Straight
246+
pyaw.append(pyaw[-1])
247+
elif m is "R": # right turn
248+
pyaw.append(pyaw[-1] - d)
249+
pd += d
250250

251251
return px, py, pyaw
252252

PathPlanning/FrenetOptimalTrajectory/cubic_spline_planner.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
class Spline:
13-
u"""
13+
"""
1414
Cubic Spline class
1515
"""
1616

@@ -209,7 +209,7 @@ def main():
209209
ryaw.append(sp.calc_yaw(i_s))
210210
rk.append(sp.calc_curvature(i_s))
211211

212-
flg, ax = plt.subplots(1)
212+
plt.subplots(1)
213213
plt.plot(x, y, "xb", label="input")
214214
plt.plot(rx, ry, "-r", label="spline")
215215
plt.grid(True)
@@ -218,14 +218,14 @@ def main():
218218
plt.ylabel("y[m]")
219219
plt.legend()
220220

221-
flg, ax = plt.subplots(1)
221+
plt.subplots(1)
222222
plt.plot(s, [np.rad2deg(iyaw) for iyaw in ryaw], "-r", label="yaw")
223223
plt.grid(True)
224224
plt.legend()
225225
plt.xlabel("line length[m]")
226226
plt.ylabel("yaw angle[deg]")
227227

228-
flg, ax = plt.subplots(1)
228+
plt.subplots(1)
229229
plt.plot(s, rk, "-r", label="curvature")
230230
plt.grid(True)
231231
plt.legend()

0 commit comments

Comments
 (0)