Skip to content

Commit a164faa

Browse files
committed
replace math.radians to np.deg2rad
1 parent 15e044d commit a164faa

File tree

30 files changed

+108
-107
lines changed

30 files changed

+108
-107
lines changed

Localization/extended_kalman_filter/extended_kalman_filter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
import matplotlib.pyplot as plt
1212

1313
# Estimation parameter of EKF
14-
Q = np.diag([0.1, 0.1, math.radians(1.0), 1.0])**2
15-
R = np.diag([1.0, math.radians(40.0)])**2
14+
Q = np.diag([0.1, 0.1, np.deg2rad(1.0), 1.0])**2
15+
R = np.diag([1.0, np.deg2rad(40.0)])**2
1616

1717
# Simulation parameter
1818
Qsim = np.diag([0.5, 0.5])**2
19-
Rsim = np.diag([1.0, math.radians(30.0)])**2
19+
Rsim = np.diag([1.0, np.deg2rad(30.0)])**2
2020

2121
DT = 0.1 # time tick [s]
2222
SIM_TIME = 50.0 # simulation time [s]

Localization/particle_filter/particle_filter.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
# Estimation parameter of PF
1414
Q = np.diag([0.1])**2 # range error
15-
R = np.diag([1.0, math.radians(40.0)])**2 # input error
15+
R = np.diag([1.0, np.deg2rad(40.0)])**2 # input error
1616

1717
# Simulation parameter
1818
Qsim = np.diag([0.2])**2
19-
Rsim = np.diag([1.0, math.radians(30.0)])**2
19+
Rsim = np.diag([1.0, np.deg2rad(30.0)])**2
2020

2121
DT = 0.1 # time tick [s]
2222
SIM_TIME = 50.0 # simulation time [s]
@@ -170,13 +170,17 @@ def plot_covariance_ellipse(xEst, PEst):
170170

171171
t = np.arange(0, 2 * math.pi + 0.1, 0.1)
172172

173-
#eigval[bigind] or eiqval[smallind] were occassionally negative numbers extremely
174-
#close to 0 (~10^-20), catch these cases and set the respective variable to 0
175-
try: a = math.sqrt(eigval[bigind])
176-
except ValueError: a = 0
177-
178-
try: b = math.sqrt(eigval[smallind])
179-
except ValueError: b = 0
173+
# eigval[bigind] or eiqval[smallind] were occassionally negative numbers extremely
174+
# close to 0 (~10^-20), catch these cases and set the respective variable to 0
175+
try:
176+
a = math.sqrt(eigval[bigind])
177+
except ValueError:
178+
a = 0
179+
180+
try:
181+
b = math.sqrt(eigval[smallind])
182+
except ValueError:
183+
b = 0
180184

181185
x = [a * math.cos(it) for it in t]
182186
y = [b * math.sin(it) for it in t]

Localization/unscented_kalman_filter/unscented_kalman_filter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
import matplotlib.pyplot as plt
1313

1414
# Estimation parameter of UKF
15-
Q = np.diag([0.1, 0.1, math.radians(1.0), 1.0])**2
16-
R = np.diag([1.0, math.radians(40.0)])**2
15+
Q = np.diag([0.1, 0.1, np.deg2rad(1.0), 1.0])**2
16+
R = np.diag([1.0, np.deg2rad(40.0)])**2
1717

1818
# Simulation parameter
1919
Qsim = np.diag([0.5, 0.5])**2
20-
Rsim = np.diag([1.0, math.radians(30.0)])**2
20+
Rsim = np.diag([1.0, np.deg2rad(30.0)])**2
2121

2222
DT = 0.1 # time tick [s]
2323
SIM_TIME = 50.0 # simulation time [s]

Mapping/circle_fitting/circle_fitting.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ def ray_casting_filter(xl, yl, thetal, rangel, angle_reso):
9393
def plot_circle(x, y, size, color="-b"):
9494
deg = list(range(0, 360, 5))
9595
deg.append(0)
96-
xl = [x + size * math.cos(math.radians(d)) for d in deg]
97-
yl = [y + size * math.sin(math.radians(d)) for d in deg]
96+
xl = [x + size * math.cos(np.deg2rad(d)) for d in deg]
97+
yl = [y + size * math.sin(np.deg2rad(d)) for d in deg]
9898
plt.plot(xl, yl, color)
9999

100100

@@ -107,8 +107,8 @@ def main():
107107
cx = -2.0 # initial x position of obstacle
108108
cy = -8.0 # initial y position of obstacle
109109
cr = 1.0 # obstacle radious
110-
theta = math.radians(30.0) # obstacle moving direction
111-
angle_reso = math.radians(3.0) # sensor angle resolution
110+
theta = np.deg2rad(30.0) # obstacle moving direction
111+
angle_reso = np.deg2rad(3.0) # sensor angle resolution
112112

113113
time = 0.0
114114
while time <= simtime:

Mapping/raycasting_grid_map/raycasting_grid_map.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def main():
114114
print(__file__ + " start!!")
115115

116116
xyreso = 0.25 # x-y grid resolution [m]
117-
yawreso = math.radians(10.0) # yaw angle resolution [rad]
117+
yawreso = np.deg2rad(10.0) # yaw angle resolution [rad]
118118

119119
for i in range(5):
120120
ox = (np.random.rand(4) - 0.5) * 10.0

Mapping/rectangle_fitting/rectangle_fitting.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ def ray_casting_filter(xl, yl, thetal, rangel, angle_reso):
9393
def plot_circle(x, y, size, color="-b"):
9494
deg = list(range(0, 360, 5))
9595
deg.append(0)
96-
xl = [x + size * math.cos(math.radians(d)) for d in deg]
97-
yl = [y + size * math.sin(math.radians(d)) for d in deg]
96+
xl = [x + size * math.cos(np.deg2rad(d)) for d in deg]
97+
yl = [y + size * math.sin(np.deg2rad(d)) for d in deg]
9898
plt.plot(xl, yl, color)
9999

100100

@@ -107,8 +107,8 @@ def main():
107107
cx = -2.0 # initial x position of obstacle
108108
cy = -8.0 # initial y position of obstacle
109109
cr = 1.0 # obstacle radious
110-
theta = math.radians(30.0) # obstacle moving direction
111-
angle_reso = math.radians(3.0) # sensor angle resolution
110+
theta = np.deg2rad(30.0) # obstacle moving direction
111+
angle_reso = np.deg2rad(3.0) # sensor angle resolution
112112

113113
time = 0.0
114114
while time <= simtime:

PathPlanning/ClosedLoopRRTStar/closed_loop_rrt_star_car.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,8 @@ def choose_parent(self, newNode, nearinds):
221221

222222
return newNode
223223

224-
225224
def pi_2_pi(self, angle):
226-
return (angle + math.pi) % (2*math.pi) - math.pi
227-
225+
return (angle + math.pi) % (2 * math.pi) - math.pi
228226

229227
def steer(self, rnd, nind):
230228
# print(rnd)
@@ -265,7 +263,7 @@ def get_random_point(self):
265263
def get_best_last_indexs(self):
266264
# print("get_best_last_index")
267265

268-
YAWTH = math.radians(1.0)
266+
YAWTH = np.deg2rad(1.0)
269267
XYTH = 0.5
270268

271269
goalinds = []
@@ -420,8 +418,8 @@ def main():
420418
] # [x,y,size(radius)]
421419

422420
# Set Initial parameters
423-
start = [0.0, 0.0, math.radians(0.0)]
424-
goal = [6.0, 7.0, math.radians(90.0)]
421+
start = [0.0, 0.0, np.deg2rad(0.0)]
422+
goal = [6.0, 7.0, np.deg2rad(90.0)]
425423

426424
rrt = RRT(start, goal, randArea=[-2.0, 20.0], obstacleList=obstacleList)
427425
flag, x, y, yaw, v, t, a, d = rrt.Planning(animation=show_animation)

PathPlanning/ClosedLoopRRTStar/pure_pursuit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ def main():
236236
# state = unicycle_model.State(x=-1.0, y=-5.0, yaw=0.0, v=-30.0 / 3.6)
237237
# state = unicycle_model.State(x=10.0, y=5.0, yaw=0.0, v=-30.0 / 3.6)
238238
# state = unicycle_model.State(
239-
# x=3.0, y=5.0, yaw=math.radians(-40.0), v=-10.0 / 3.6)
239+
# x=3.0, y=5.0, yaw=np.deg2rad(-40.0), v=-10.0 / 3.6)
240240
# state = unicycle_model.State(
241-
# x=3.0, y=5.0, yaw=math.radians(40.0), v=50.0 / 3.6)
241+
# x=3.0, y=5.0, yaw=np.deg2rad(40.0), v=50.0 / 3.6)
242242

243243
lastIndex = len(cx) - 1
244244
time = 0.0

PathPlanning/ClosedLoopRRTStar/unicycle_model.py

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

1111
dt = 0.05 # [s]
1212
L = 0.9 # [m]
13-
steer_max = math.radians(40.0)
13+
steer_max = np.deg2rad(40.0)
1414
curvature_max = math.tan(steer_max) / L
1515
curvature_max = 1.0 / curvature_max + 1.0
1616

@@ -38,7 +38,7 @@ def update(state, a, delta):
3838

3939

4040
def pi_2_pi(angle):
41-
return (angle + math.pi) % (2*math.pi) - math.pi
41+
return (angle + math.pi) % (2 * math.pi) - math.pi
4242

4343

4444
if __name__ == '__main__':
@@ -47,7 +47,7 @@ def pi_2_pi(angle):
4747

4848
T = 100
4949
a = [1.0] * T
50-
delta = [math.radians(1.0)] * T
50+
delta = [np.deg2rad(1.0)] * T
5151
# print(delta)
5252
# print(a, delta)
5353

PathPlanning/DubinsPath/dubins_path_planning.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def mod2pi(theta):
1717

1818

1919
def pi_2_pi(angle):
20-
return (angle + math.pi) % (2*math.pi) - math.pi
20+
return (angle + math.pi) % (2 * math.pi) - math.pi
2121

2222

2323
def LSL(alpha, beta, d):
@@ -221,7 +221,7 @@ def generate_course(length, mode, c):
221221
if m is "S":
222222
d = 1.0 * c
223223
else: # turning couse
224-
d = math.radians(3.0)
224+
d = np.deg2rad(3.0)
225225

226226
while pd < abs(l - d):
227227
# print(pd, l)
@@ -270,11 +270,11 @@ def main():
270270

271271
start_x = 1.0 # [m]
272272
start_y = 1.0 # [m]
273-
start_yaw = math.radians(45.0) # [rad]
273+
start_yaw = np.deg2rad(45.0) # [rad]
274274

275275
end_x = -3.0 # [m]
276276
end_y = -3.0 # [m]
277-
end_yaw = math.radians(-45.0) # [rad]
277+
end_yaw = np.deg2rad(-45.0) # [rad]
278278

279279
curvature = 1.0
280280

@@ -304,11 +304,11 @@ def test():
304304
for i in range(NTEST):
305305
start_x = (np.random.rand() - 0.5) * 10.0 # [m]
306306
start_y = (np.random.rand() - 0.5) * 10.0 # [m]
307-
start_yaw = math.radians((np.random.rand() - 0.5) * 180.0) # [rad]
307+
start_yaw = np.deg2rad((np.random.rand() - 0.5) * 180.0) # [rad]
308308

309309
end_x = (np.random.rand() - 0.5) * 10.0 # [m]
310310
end_y = (np.random.rand() - 0.5) * 10.0 # [m]
311-
end_yaw = math.radians((np.random.rand() - 0.5) * 180.0) # [rad]
311+
end_yaw = np.deg2rad((np.random.rand() - 0.5) * 180.0) # [rad]
312312

313313
curvature = 1.0 / (np.random.rand() * 5.0)
314314

0 commit comments

Comments
 (0)