Skip to content

Commit 20f206c

Browse files
committed
add gif
1 parent 3c4d1c4 commit 20f206c

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed
216 KB
Loading

Mapping/circle_fitting/circle_fitting.py

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

9-
109
import matplotlib.pyplot as plt
1110
import math
1211
import random
@@ -53,12 +52,12 @@ def circle_fitting(x, y):
5352
def get_sample_points(cx, cy, cr, angle_reso):
5453
x, y, angle, r = [], [], [], []
5554

55+
# points sampling
5656
for theta in np.arange(0.0, 2.0 * math.pi, angle_reso):
57-
rn = cr * random.uniform(0.9, 1.1) # add noize
58-
nx = cx + rn * math.cos(theta)
59-
ny = cy + rn * math.sin(theta)
57+
nx = cx + cr * math.cos(theta)
58+
ny = cy + cr * math.sin(theta)
6059
nangle = math.atan2(ny, nx)
61-
nr = math.hypot(nx, ny)
60+
nr = math.hypot(nx, ny) * random.uniform(0.95, 1.05)
6261

6362
x.append(nx)
6463
y.append(ny)
@@ -84,7 +83,7 @@ def ray_casting_filter(xl, yl, thetal, rangel, angle_reso):
8483

8584
for i in range(len(rangedb)):
8685
t = i * angle_reso
87-
if rangedb[i] <= 1000.0:
86+
if rangedb[i] != float("inf"):
8887
rx.append(rangedb[i] * math.cos(t))
8988
ry.append(rangedb[i] * math.sin(t))
9089

@@ -101,14 +100,15 @@ def plot_circle(x, y, size, color="-b"):
101100

102101
def main():
103102

104-
simtime = 10.0
105-
dt = 1.0
103+
# simulation parameters
104+
simtime = 15.0 # simulation time
105+
dt = 1.0 # time tick
106106

107-
cx = -2.0
108-
cy = -8.0
109-
cr = 1.0
110-
theta = math.radians(30.0)
111-
angle_reso = math.radians(3.0)
107+
cx = -2.0 # initial x position of obstacle
108+
cy = -8.0 # initial y position of obstacle
109+
cr = 1.0 # obstacle radious
110+
theta = math.radians(30.0) # obstacle moving direction
111+
angle_reso = math.radians(3.0) # sensor angle resolution
112112

113113
time = 0.0
114114
while time <= simtime:

0 commit comments

Comments
 (0)