Skip to content

Commit 489ee5c

Browse files
authoredJan 26, 2023
fix github scanning alerts (#784)
1 parent 15ab196 commit 489ee5c

File tree

8 files changed

+12
-14
lines changed

8 files changed

+12
-14
lines changed
 

‎ArmNavigation/two_joint_arm_to_point_control/two_joint_arm_to_point_control.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def two_joint_arm(GOAL_TH=0.0, theta1=0.0, theta2=0.0):
4545
if x is not None and y is not None:
4646
x_prev = x
4747
y_prev = y
48-
if np.sqrt(x**2 + y**2) > (l1 + l2):
48+
if np.hypot(x, y) > (l1 + l2):
4949
theta2_goal = 0
5050
else:
5151
theta2_goal = np.arccos(

‎Bipedal/bipedal_planner/bipedal_planner.py

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ def walk(self, t_sup=0.8, z_c=0.8, a=10, b=1, plot=False):
4747
return
4848

4949
# set up plotter
50-
com_trajectory_for_plot, ax = None, None
5150
if plot:
5251
fig = plt.figure()
5352
ax = Axes3D(fig)

‎PathPlanning/HybridAStar/dynamic_programming_heuristic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def calc_obstacle_map(ox, oy, resolution, vr):
150150
y = iy + min_y
151151
# print(x, y)
152152
for iox, ioy in zip(ox, oy):
153-
d = math.sqrt((iox - x) ** 2 + (ioy - y) ** 2)
153+
d = math.hypot(iox - x, ioy - y)
154154
if d <= vr / resolution:
155155
obstacle_map[ix][iy] = True
156156
break

‎PathPlanning/InformedRRTStar/informed_rrt_star.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def get_path_len(path):
192192

193193
@staticmethod
194194
def line_cost(node1, node2):
195-
return math.sqrt((node1.x - node2.x) ** 2 + (node1.y - node2.y) ** 2)
195+
return math.hypot(node1.x - node2.x, node1.y - node2.y)
196196

197197
@staticmethod
198198
def get_nearest_list_index(nodes, rnd):
@@ -222,8 +222,7 @@ def rewire(self, newNode, nearInds):
222222
for i in nearInds:
223223
nearNode = self.node_list[i]
224224

225-
d = math.sqrt((nearNode.x - newNode.x) ** 2
226-
+ (nearNode.y - newNode.y) ** 2)
225+
d = math.hypot(nearNode.x - newNode.x, nearNode.y - newNode.y)
227226

228227
s_cost = newNode.cost + d
229228

‎PathPlanning/LQRPlanner/lqr_planner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def lqr_planning(self, sx, sy, gx, gy, show_animation=True):
4747
rx.append(x[0, 0] + gx)
4848
ry.append(x[1, 0] + gy)
4949

50-
d = math.sqrt((gx - rx[-1]) ** 2 + (gy - ry[-1]) ** 2)
50+
d = math.hypot(gx - rx[-1], gy - ry[-1])
5151
if d <= self.GOAL_DIST:
5252
found_path = True
5353
break

‎PathPlanning/LQRRRTStar/lqr_rrt_star.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def sample_path(self, wx, wy, step):
179179
dx = np.diff(px)
180180
dy = np.diff(py)
181181

182-
clen = [math.sqrt(idx ** 2 + idy ** 2) for (idx, idy) in zip(dx, dy)]
182+
clen = [math.hypot(idx, idy) for (idx, idy) in zip(dx, dy)]
183183

184184
return px, py, clen
185185

‎PathPlanning/RRT/rrt_with_pathsmoothing.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get_path_length(path):
2323
for i in range(len(path) - 1):
2424
dx = path[i + 1][0] - path[i][0]
2525
dy = path[i + 1][1] - path[i][1]
26-
d = math.sqrt(dx * dx + dy * dy)
26+
d = math.hypot(dx, dy)
2727
le += d
2828

2929
return le
@@ -36,7 +36,7 @@ def get_target_point(path, targetL):
3636
for i in range(len(path) - 1):
3737
dx = path[i + 1][0] - path[i][0]
3838
dy = path[i + 1][1] - path[i][1]
39-
d = math.sqrt(dx * dx + dy * dy)
39+
d = math.hypot(dx, dy)
4040
le += d
4141
if le >= targetL:
4242
ti = i - 1
@@ -67,7 +67,7 @@ def line_collision_check(first, second, obstacleList):
6767
return False
6868

6969
for (ox, oy, size) in obstacleList:
70-
d = abs(a * ox + b * oy + c) / (math.sqrt(a * a + b * b))
70+
d = abs(a * ox + b * oy + c) / (math.hypot(a, b))
7171
if d <= size:
7272
return False
7373

‎PathPlanning/ReedsSheppPath/reeds_shepp_path_planning.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ def straight_left_straight(x, y, phi):
5757
xd = - y / math.tan(phi) + x
5858
t = xd - math.tan(phi / 2.0)
5959
u = phi
60-
v = math.sqrt((x - xd) ** 2 + y ** 2) - math.tan(phi / 2.0)
60+
v = math.hypot(x - xd, y) - math.tan(phi / 2.0)
6161
return True, t, u, v
6262
elif y < 0.0 < phi < math.pi * 0.99:
6363
xd = - y / math.tan(phi) + x
6464
t = xd - math.tan(phi / 2.0)
6565
u = phi
66-
v = -math.sqrt((x - xd) ** 2 + y ** 2) - math.tan(phi / 2.0)
66+
v = -math.hypot(x - xd, y) - math.tan(phi / 2.0)
6767
return True, t, u, v
6868

6969
return False, 0.0, 0.0, 0.0
@@ -103,7 +103,7 @@ def straight_curve_straight(x, y, phi, paths, step_size):
103103

104104

105105
def polar(x, y):
106-
r = math.sqrt(x ** 2 + y ** 2)
106+
r = math.hypot(x, y)
107107
theta = math.atan2(y, x)
108108
return r, theta
109109

0 commit comments

Comments
 (0)
Please sign in to comment.