nwo stringlengths 10 28 | sha stringlengths 40 40 | path stringlengths 11 97 | identifier stringlengths 1 64 | parameters stringlengths 2 2.24k | return_statement stringlengths 0 2.17k | docstring stringlengths 0 5.45k | docstring_summary stringlengths 0 3.83k | func_begin int64 1 13.4k | func_end int64 2 13.4k | function stringlengths 28 56.4k | url stringlengths 106 209 | project int64 1 48 | executed_lines list | executed_lines_pc float64 0 153 | missing_lines list | missing_lines_pc float64 0 100 | covered bool 2
classes | filecoverage float64 2.53 100 | function_lines int64 2 1.46k | mccabe int64 1 253 | coverage float64 0 100 | docstring_lines int64 0 112 | function_nodoc stringlengths 9 56.4k | id int64 0 29.8k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
lorien/grab | 2d170c31a3335c2e29578b42a5d62ef3efc5d7ee | grab/util/cookies.py | MockRequest.origin_req_host | (self) | return self.get_origin_req_host() | 102 | 103 | def origin_req_host(self) -> str:
return self.get_origin_req_host() | https://github.com/lorien/grab/blob/2d170c31a3335c2e29578b42a5d62ef3efc5d7ee/project1/grab/util/cookies.py#L102-L103 | 1 | [
0,
1
] | 100 | [] | 0 | true | 81.927711 | 2 | 1 | 100 | 0 | def origin_req_host(self) -> str:
return self.get_origin_req_host() | 216 | ||
lorien/grab | 2d170c31a3335c2e29578b42a5d62ef3efc5d7ee | grab/util/cookies.py | MockRequest.host | (self) | return self.get_host() | 106 | 107 | def host(self) -> str:
return self.get_host() | https://github.com/lorien/grab/blob/2d170c31a3335c2e29578b42a5d62ef3efc5d7ee/project1/grab/util/cookies.py#L106-L107 | 1 | [
0
] | 50 | [
1
] | 50 | false | 81.927711 | 2 | 1 | 50 | 0 | def host(self) -> str:
return self.get_host() | 217 | ||
lorien/grab | 2d170c31a3335c2e29578b42a5d62ef3efc5d7ee | grab/util/cookies.py | MockResponse.__init__ | (self, headers: HTTPMessage | HTTPHeaderDict) | Make a MockResponse for `cookielib` to read.
:param headers: a httplib.HTTPMessage or analogous carrying the headers | Make a MockResponse for `cookielib` to read. | 118 | 123 | def __init__(self, headers: HTTPMessage | HTTPHeaderDict) -> None:
"""Make a MockResponse for `cookielib` to read.
:param headers: a httplib.HTTPMessage or analogous carrying the headers
"""
self._headers = headers | https://github.com/lorien/grab/blob/2d170c31a3335c2e29578b42a5d62ef3efc5d7ee/project1/grab/util/cookies.py#L118-L123 | 1 | [
0,
1,
2,
3,
4,
5
] | 100 | [] | 0 | true | 81.927711 | 6 | 1 | 100 | 3 | def __init__(self, headers: HTTPMessage | HTTPHeaderDict) -> None:
self._headers = headers | 218 | |
lorien/grab | 2d170c31a3335c2e29578b42a5d62ef3efc5d7ee | grab/util/cookies.py | MockResponse.info | (self) | return self._headers | 125 | 126 | def info(self) -> HTTPMessage | HTTPHeaderDict:
return self._headers | https://github.com/lorien/grab/blob/2d170c31a3335c2e29578b42a5d62ef3efc5d7ee/project1/grab/util/cookies.py#L125-L126 | 1 | [
0,
1
] | 100 | [] | 0 | true | 81.927711 | 2 | 1 | 100 | 0 | def info(self) -> HTTPMessage | HTTPHeaderDict:
return self._headers | 219 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/raycasting_grid_map/raycasting_grid_map.py | calc_grid_map_config | (ox, oy, xyreso) | return minx, miny, maxx, maxy, xw, yw | 18 | 26 | def calc_grid_map_config(ox, oy, xyreso):
minx = round(min(ox) - EXTEND_AREA / 2.0)
miny = round(min(oy) - EXTEND_AREA / 2.0)
maxx = round(max(ox) + EXTEND_AREA / 2.0)
maxy = round(max(oy) + EXTEND_AREA / 2.0)
xw = int(round((maxx - minx) / xyreso))
yw = int(round((maxy - miny) / xyreso))
r... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/raycasting_grid_map/raycasting_grid_map.py#L18-L26 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 100 | [] | 0 | true | 93.421053 | 9 | 1 | 100 | 0 | def calc_grid_map_config(ox, oy, xyreso):
minx = round(min(ox) - EXTEND_AREA / 2.0)
miny = round(min(oy) - EXTEND_AREA / 2.0)
maxx = round(max(ox) + EXTEND_AREA / 2.0)
maxy = round(max(oy) + EXTEND_AREA / 2.0)
xw = int(round((maxx - minx) / xyreso))
yw = int(round((maxy - miny) / xyreso))
r... | 440 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/raycasting_grid_map/raycasting_grid_map.py | atan_zero_to_twopi | (y, x) | return angle | 43 | 48 | def atan_zero_to_twopi(y, x):
angle = math.atan2(y, x)
if angle < 0.0:
angle += math.pi * 2.0
return angle | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/raycasting_grid_map/raycasting_grid_map.py#L43-L48 | 2 | [
0,
1,
2,
3,
4,
5
] | 100 | [] | 0 | true | 93.421053 | 6 | 2 | 100 | 0 | def atan_zero_to_twopi(y, x):
angle = math.atan2(y, x)
if angle < 0.0:
angle += math.pi * 2.0
return angle | 441 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/raycasting_grid_map/raycasting_grid_map.py | precasting | (minx, miny, xw, yw, xyreso, yawreso) | return precast | 51 | 75 | def precasting(minx, miny, xw, yw, xyreso, yawreso):
precast = [[] for i in range(int(round((math.pi * 2.0) / yawreso)) + 1)]
for ix in range(xw):
for iy in range(yw):
px = ix * xyreso + minx
py = iy * xyreso + miny
d = math.hypot(px, py)
angle = atan_z... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/raycasting_grid_map/raycasting_grid_map.py#L51-L75 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24
] | 100 | [] | 0 | true | 93.421053 | 25 | 4 | 100 | 0 | def precasting(minx, miny, xw, yw, xyreso, yawreso):
precast = [[] for i in range(int(round((math.pi * 2.0) / yawreso)) + 1)]
for ix in range(xw):
for iy in range(yw):
px = ix * xyreso + minx
py = iy * xyreso + miny
d = math.hypot(px, py)
angle = atan_z... | 442 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/raycasting_grid_map/raycasting_grid_map.py | generate_ray_casting_grid_map | (ox, oy, xyreso, yawreso) | return pmap, minx, maxx, miny, maxy, xyreso | 78 | 103 | def generate_ray_casting_grid_map(ox, oy, xyreso, yawreso):
minx, miny, maxx, maxy, xw, yw = calc_grid_map_config(ox, oy, xyreso)
pmap = [[0.0 for i in range(yw)] for i in range(xw)]
precast = precasting(minx, miny, xw, yw, xyreso, yawreso)
for (x, y) in zip(ox, oy):
d = math.hypot(x, y)
... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/raycasting_grid_map/raycasting_grid_map.py#L78-L103 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25
] | 100 | [] | 0 | true | 93.421053 | 26 | 6 | 100 | 0 | def generate_ray_casting_grid_map(ox, oy, xyreso, yawreso):
minx, miny, maxx, maxy, xw, yw = calc_grid_map_config(ox, oy, xyreso)
pmap = [[0.0 for i in range(yw)] for i in range(xw)]
precast = precasting(minx, miny, xw, yw, xyreso, yawreso)
for (x, y) in zip(ox, oy):
d = math.hypot(x, y)
... | 443 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/raycasting_grid_map/raycasting_grid_map.py | draw_heatmap | (data, minx, maxx, miny, maxy, xyreso) | 106 | 110 | def draw_heatmap(data, minx, maxx, miny, maxy, xyreso):
x, y = np.mgrid[slice(minx - xyreso / 2.0, maxx + xyreso / 2.0, xyreso),
slice(miny - xyreso / 2.0, maxy + xyreso / 2.0, xyreso)]
plt.pcolor(x, y, data, vmax=1.0, cmap=plt.cm.Blues)
plt.axis("equal") | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/raycasting_grid_map/raycasting_grid_map.py#L106-L110 | 2 | [
0
] | 20 | [
1,
3,
4
] | 60 | false | 93.421053 | 5 | 1 | 40 | 0 | def draw_heatmap(data, minx, maxx, miny, maxy, xyreso):
x, y = np.mgrid[slice(minx - xyreso / 2.0, maxx + xyreso / 2.0, xyreso),
slice(miny - xyreso / 2.0, maxy + xyreso / 2.0, xyreso)]
plt.pcolor(x, y, data, vmax=1.0, cmap=plt.cm.Blues)
plt.axis("equal") | 444 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/raycasting_grid_map/raycasting_grid_map.py | main | () | 113 | 133 | def main():
print(__file__ + " start!!")
xyreso = 0.25 # x-y grid resolution [m]
yawreso = np.deg2rad(10.0) # yaw angle resolution [rad]
for i in range(5):
ox = (np.random.rand(4) - 0.5) * 10.0
oy = (np.random.rand(4) - 0.5) * 10.0
pmap, minx, maxx, miny, maxy, xyreso = gener... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/raycasting_grid_map/raycasting_grid_map.py#L113-L133 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 71.428571 | [] | 0 | false | 93.421053 | 21 | 3 | 100 | 0 | def main():
print(__file__ + " start!!")
xyreso = 0.25 # x-y grid resolution [m]
yawreso = np.deg2rad(10.0) # yaw angle resolution [rad]
for i in range(5):
ox = (np.random.rand(4) - 0.5) * 10.0
oy = (np.random.rand(4) - 0.5) * 10.0
pmap, minx, maxx, miny, maxy, xyreso = gener... | 445 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/raycasting_grid_map/raycasting_grid_map.py | precastDB.__init__ | (self) | 31 | 37 | def __init__(self):
self.px = 0.0
self.py = 0.0
self.d = 0.0
self.angle = 0.0
self.ix = 0
self.iy = 0 | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/raycasting_grid_map/raycasting_grid_map.py#L31-L37 | 2 | [
0,
1,
2,
3,
4,
5,
6
] | 100 | [] | 0 | true | 93.421053 | 7 | 1 | 100 | 0 | def __init__(self):
self.px = 0.0
self.py = 0.0
self.d = 0.0
self.angle = 0.0
self.ix = 0
self.iy = 0 | 446 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/raycasting_grid_map/raycasting_grid_map.py | precastDB.__str__ | (self) | return str(self.px) + "," + str(self.py) + "," + str(self.d) + "," + str(self.angle) | 39 | 40 | def __str__(self):
return str(self.px) + "," + str(self.py) + "," + str(self.d) + "," + str(self.angle) | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/raycasting_grid_map/raycasting_grid_map.py#L39-L40 | 2 | [
0
] | 50 | [
1
] | 50 | false | 93.421053 | 2 | 1 | 50 | 0 | def __str__(self):
return str(self.px) + "," + str(self.py) + "," + str(self.d) + "," + str(self.angle) | 447 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/kmeans_clustering/kmeans_clustering.py | kmeans_clustering | (rx, ry, nc) | return clusters | 19 | 34 | def kmeans_clustering(rx, ry, nc):
clusters = Clusters(rx, ry, nc)
clusters.calc_centroid()
pre_cost = float("inf")
for loop in range(MAX_LOOP):
print("loop:", loop)
cost = clusters.update_clusters()
clusters.calc_centroid()
d_cost = abs(cost - pre_cost)
if d_co... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/kmeans_clustering/kmeans_clustering.py#L19-L34 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15
] | 100 | [] | 0 | true | 95.604396 | 16 | 3 | 100 | 0 | def kmeans_clustering(rx, ry, nc):
clusters = Clusters(rx, ry, nc)
clusters.calc_centroid()
pre_cost = float("inf")
for loop in range(MAX_LOOP):
print("loop:", loop)
cost = clusters.update_clusters()
clusters.calc_centroid()
d_cost = abs(cost - pre_cost)
if d_co... | 448 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/kmeans_clustering/kmeans_clustering.py | calc_raw_data | (cx, cy, n_points, rand_d) | return rx, ry | 85 | 93 | def calc_raw_data(cx, cy, n_points, rand_d):
rx, ry = [], []
for (icx, icy) in zip(cx, cy):
for _ in range(n_points):
rx.append(icx + rand_d * (random.random() - 0.5))
ry.append(icy + rand_d * (random.random() - 0.5))
return rx, ry | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/kmeans_clustering/kmeans_clustering.py#L85-L93 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 100 | [] | 0 | true | 95.604396 | 9 | 3 | 100 | 0 | def calc_raw_data(cx, cy, n_points, rand_d):
rx, ry = [], []
for (icx, icy) in zip(cx, cy):
for _ in range(n_points):
rx.append(icx + rand_d * (random.random() - 0.5))
ry.append(icy + rand_d * (random.random() - 0.5))
return rx, ry | 449 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/kmeans_clustering/kmeans_clustering.py | update_positions | (cx, cy) | return cx, cy | 96 | 108 | def update_positions(cx, cy):
# object moving parameters
DX1 = 0.4
DY1 = 0.5
DX2 = -0.3
DY2 = -0.5
cx[0] += DX1
cy[0] += DY1
cx[1] += DX2
cy[1] += DY2
return cx, cy | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/kmeans_clustering/kmeans_clustering.py#L96-L108 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12
] | 100 | [] | 0 | true | 95.604396 | 13 | 1 | 100 | 0 | def update_positions(cx, cy):
# object moving parameters
DX1 = 0.4
DY1 = 0.5
DX2 = -0.3
DY2 = -0.5
cx[0] += DX1
cy[0] += DY1
cx[1] += DX2
cy[1] += DY2
return cx, cy | 450 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/kmeans_clustering/kmeans_clustering.py | main | () | 111 | 145 | def main():
print(__file__ + " start!!")
cx = [0.0, 8.0]
cy = [0.0, 8.0]
n_points = 10
rand_d = 3.0
n_cluster = 2
sim_time = 15.0
dt = 1.0
time = 0.0
while time <= sim_time:
print("Time:", time)
time += dt
# objects moving simulation
cx, cy = up... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/kmeans_clustering/kmeans_clustering.py#L111-L145 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
33,
34
] | 92.592593 | [] | 0 | false | 95.604396 | 35 | 3 | 100 | 0 | def main():
print(__file__ + " start!!")
cx = [0.0, 8.0]
cy = [0.0, 8.0]
n_points = 10
rand_d = 3.0
n_cluster = 2
sim_time = 15.0
dt = 1.0
time = 0.0
while time <= sim_time:
print("Time:", time)
time += dt
# objects moving simulation
cx, cy = up... | 451 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/kmeans_clustering/kmeans_clustering.py | Clusters.__init__ | (self, x, y, n_label) | 39 | 47 | def __init__(self, x, y, n_label):
self.x = x
self.y = y
self.n_data = len(self.x)
self.n_label = n_label
self.labels = [random.randint(0, n_label - 1)
for _ in range(self.n_data)]
self.center_x = [0.0 for _ in range(n_label)]
self.center_y ... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/kmeans_clustering/kmeans_clustering.py#L39-L47 | 2 | [
0,
1,
2,
3,
4,
5,
7,
8
] | 88.888889 | [] | 0 | false | 95.604396 | 9 | 4 | 100 | 0 | def __init__(self, x, y, n_label):
self.x = x
self.y = y
self.n_data = len(self.x)
self.n_label = n_label
self.labels = [random.randint(0, n_label - 1)
for _ in range(self.n_data)]
self.center_x = [0.0 for _ in range(n_label)]
self.center_y ... | 452 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/kmeans_clustering/kmeans_clustering.py | Clusters.plot_cluster | (self) | 49 | 52 | def plot_cluster(self):
for label in set(self.labels):
x, y = self._get_labeled_x_y(label)
plt.plot(x, y, ".") | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/kmeans_clustering/kmeans_clustering.py#L49-L52 | 2 | [
0
] | 25 | [
1,
2,
3
] | 75 | false | 95.604396 | 4 | 2 | 25 | 0 | def plot_cluster(self):
for label in set(self.labels):
x, y = self._get_labeled_x_y(label)
plt.plot(x, y, ".") | 453 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/kmeans_clustering/kmeans_clustering.py | Clusters.calc_centroid | (self) | 54 | 59 | def calc_centroid(self):
for label in set(self.labels):
x, y = self._get_labeled_x_y(label)
n_data = len(x)
self.center_x[label] = sum(x) / n_data
self.center_y[label] = sum(y) / n_data | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/kmeans_clustering/kmeans_clustering.py#L54-L59 | 2 | [
0,
1,
2,
3,
4,
5
] | 100 | [] | 0 | true | 95.604396 | 6 | 2 | 100 | 0 | def calc_centroid(self):
for label in set(self.labels):
x, y = self._get_labeled_x_y(label)
n_data = len(x)
self.center_x[label] = sum(x) / n_data
self.center_y[label] = sum(y) / n_data | 454 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/kmeans_clustering/kmeans_clustering.py | Clusters.update_clusters | (self) | return cost | 61 | 77 | def update_clusters(self):
cost = 0.0
for ip in range(self.n_data):
px = self.x[ip]
py = self.y[ip]
dx = [icx - px for icx in self.center_x]
dy = [icy - py for icy in self.center_y]
dist_list = [math.hypot(idx, idy) for (idx, idy) in zip(dx,... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/kmeans_clustering/kmeans_clustering.py#L61-L77 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16
] | 100 | [] | 0 | true | 95.604396 | 17 | 5 | 100 | 0 | def update_clusters(self):
cost = 0.0
for ip in range(self.n_data):
px = self.x[ip]
py = self.y[ip]
dx = [icx - px for icx in self.center_x]
dy = [icy - py for icy in self.center_y]
dist_list = [math.hypot(idx, idy) for (idx, idy) in zip(dx,... | 455 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/kmeans_clustering/kmeans_clustering.py | Clusters._get_labeled_x_y | (self, target_label) | return x, y | 79 | 82 | def _get_labeled_x_y(self, target_label):
x = [self.x[i] for i, label in enumerate(self.labels) if label == target_label]
y = [self.y[i] for i, label in enumerate(self.labels) if label == target_label]
return x, y | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/kmeans_clustering/kmeans_clustering.py#L79-L82 | 2 | [
0,
1,
2,
3
] | 100 | [] | 0 | true | 95.604396 | 4 | 3 | 100 | 0 | def _get_labeled_x_y(self, target_label):
x = [self.x[i] for i, label in enumerate(self.labels) if label == target_label]
y = [self.y[i] for i, label in enumerate(self.labels) if label == target_label]
return x, y | 456 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/grid_map_lib/grid_map_lib.py | main | () | 255 | 263 | def main():
print("start!!")
test_position_set()
test_polygon_set()
plt.show()
print("done!!") | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/grid_map_lib/grid_map_lib.py#L255-L263 | 2 | [
0
] | 11.111111 | [
1,
3,
4,
6,
8
] | 55.555556 | false | 77.037037 | 9 | 1 | 44.444444 | 0 | def main():
print("start!!")
test_position_set()
test_polygon_set()
plt.show()
print("done!!") | 457 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/grid_map_lib/grid_map_lib.py | GridMap.__init__ | (self, width, height, resolution,
center_x, center_y, init_val=0.0) | __init__
:param width: number of grid for width
:param height: number of grid for heigt
:param resolution: grid resolution [m]
:param center_x: center x position [m]
:param center_y: center y position [m]
:param init_val: initial value for all grid | __init__ | 18 | 39 | def __init__(self, width, height, resolution,
center_x, center_y, init_val=0.0):
"""__init__
:param width: number of grid for width
:param height: number of grid for heigt
:param resolution: grid resolution [m]
:param center_x: center x position [m]
:pa... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/grid_map_lib/grid_map_lib.py#L18-L39 | 2 | [
0,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21
] | 59.090909 | [] | 0 | false | 77.037037 | 22 | 1 | 100 | 8 | def __init__(self, width, height, resolution,
center_x, center_y, init_val=0.0):
self.width = width
self.height = height
self.resolution = resolution
self.center_x = center_x
self.center_y = center_y
self.left_lower_x = self.center_x - self.width / 2.0 *... | 458 | |
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/grid_map_lib/grid_map_lib.py | GridMap.get_value_from_xy_index | (self, x_ind, y_ind) | get_value_from_xy_index
when the index is out of grid map area, return None
:param x_ind: x index
:param y_ind: y index | get_value_from_xy_index | 41 | 55 | def get_value_from_xy_index(self, x_ind, y_ind):
"""get_value_from_xy_index
when the index is out of grid map area, return None
:param x_ind: x index
:param y_ind: y index
"""
grid_ind = self.calc_grid_index_from_xy_index(x_ind, y_ind)
if 0 <= grid_ind < self.... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/grid_map_lib/grid_map_lib.py#L41-L55 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13
] | 93.333333 | [
14
] | 6.666667 | false | 77.037037 | 15 | 2 | 93.333333 | 6 | def get_value_from_xy_index(self, x_ind, y_ind):
grid_ind = self.calc_grid_index_from_xy_index(x_ind, y_ind)
if 0 <= grid_ind < self.ndata:
return self.data[grid_ind]
else:
return None | 459 | |
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/grid_map_lib/grid_map_lib.py | GridMap.get_xy_index_from_xy_pos | (self, x_pos, y_pos) | return x_ind, y_ind | get_xy_index_from_xy_pos
:param x_pos: x position [m]
:param y_pos: y position [m] | get_xy_index_from_xy_pos | 57 | 68 | def get_xy_index_from_xy_pos(self, x_pos, y_pos):
"""get_xy_index_from_xy_pos
:param x_pos: x position [m]
:param y_pos: y position [m]
"""
x_ind = self.calc_xy_index_from_position(
x_pos, self.left_lower_x, self.width)
y_ind = self.calc_xy_index_from_positio... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/grid_map_lib/grid_map_lib.py#L57-L68 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 | [] | 0 | true | 77.037037 | 12 | 1 | 100 | 4 | def get_xy_index_from_xy_pos(self, x_pos, y_pos):
x_ind = self.calc_xy_index_from_position(
x_pos, self.left_lower_x, self.width)
y_ind = self.calc_xy_index_from_position(
y_pos, self.left_lower_y, self.height)
return x_ind, y_ind | 460 |
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/grid_map_lib/grid_map_lib.py | GridMap.set_value_from_xy_pos | (self, x_pos, y_pos, val) | return flag | set_value_from_xy_pos
return bool flag, which means setting value is succeeded or not
:param x_pos: x position [m]
:param y_pos: y position [m]
:param val: grid value | set_value_from_xy_pos | 70 | 87 | def set_value_from_xy_pos(self, x_pos, y_pos, val):
"""set_value_from_xy_pos
return bool flag, which means setting value is succeeded or not
:param x_pos: x position [m]
:param y_pos: y position [m]
:param val: grid value
"""
x_ind, y_ind = self.get_xy_index_fr... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/grid_map_lib/grid_map_lib.py#L70-L87 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
14,
15,
16,
17
] | 94.444444 | [
13
] | 5.555556 | false | 77.037037 | 18 | 3 | 94.444444 | 7 | def set_value_from_xy_pos(self, x_pos, y_pos, val):
x_ind, y_ind = self.get_xy_index_from_xy_pos(x_pos, y_pos)
if (not x_ind) or (not y_ind):
return False # NG
flag = self.set_value_from_xy_index(x_ind, y_ind, val)
return flag | 461 |
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/grid_map_lib/grid_map_lib.py | GridMap.set_value_from_xy_index | (self, x_ind, y_ind, val) | set_value_from_xy_index
return bool flag, which means setting value is succeeded or not
:param x_ind: x index
:param y_ind: y index
:param val: grid value | set_value_from_xy_index | 89 | 108 | def set_value_from_xy_index(self, x_ind, y_ind, val):
"""set_value_from_xy_index
return bool flag, which means setting value is succeeded or not
:param x_ind: x index
:param y_ind: y index
:param val: grid value
"""
if (x_ind is None) or (y_ind is None):
... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/grid_map_lib/grid_map_lib.py#L89-L108 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
12,
13,
14,
15,
16,
17,
18,
19
] | 95 | [
11
] | 5 | false | 77.037037 | 20 | 4 | 95 | 7 | def set_value_from_xy_index(self, x_ind, y_ind, val):
if (x_ind is None) or (y_ind is None):
return False, False
grid_ind = int(y_ind * self.width + x_ind)
if 0 <= grid_ind < self.ndata:
self.data[grid_ind] = val
return True # OK
else:
... | 462 | |
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/grid_map_lib/grid_map_lib.py | GridMap.set_value_from_polygon | (self, pol_x, pol_y, val, inside=True) | set_value_from_polygon
Setting value inside or outside polygon
:param pol_x: x position list for a polygon
:param pol_y: y position list for a polygon
:param val: grid value
:param inside: setting data inside or outside | set_value_from_polygon | 110 | 135 | def set_value_from_polygon(self, pol_x, pol_y, val, inside=True):
"""set_value_from_polygon
Setting value inside or outside polygon
:param pol_x: x position list for a polygon
:param pol_y: y position list for a polygon
:param val: grid value
:param inside: setting data... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/grid_map_lib/grid_map_lib.py#L110-L135 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25
] | 100 | [] | 0 | true | 77.037037 | 26 | 6 | 100 | 8 | def set_value_from_polygon(self, pol_x, pol_y, val, inside=True):
# making ring polygon
if (pol_x[0] != pol_x[-1]) or (pol_y[0] != pol_y[-1]):
np.append(pol_x, pol_x[0])
np.append(pol_y, pol_y[0])
# setting value for all grid
for x_ind in range(self.width):
... | 463 | |
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/grid_map_lib/grid_map_lib.py | GridMap.calc_grid_index_from_xy_index | (self, x_ind, y_ind) | return grid_ind | 137 | 139 | def calc_grid_index_from_xy_index(self, x_ind, y_ind):
grid_ind = int(y_ind * self.width + x_ind)
return grid_ind | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/grid_map_lib/grid_map_lib.py#L137-L139 | 2 | [
0,
1,
2
] | 100 | [] | 0 | true | 77.037037 | 3 | 1 | 100 | 0 | def calc_grid_index_from_xy_index(self, x_ind, y_ind):
grid_ind = int(y_ind * self.width + x_ind)
return grid_ind | 464 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/grid_map_lib/grid_map_lib.py | GridMap.calc_grid_central_xy_position_from_xy_index | (self, x_ind, y_ind) | return x_pos, y_pos | 141 | 147 | def calc_grid_central_xy_position_from_xy_index(self, x_ind, y_ind):
x_pos = self.calc_grid_central_xy_position_from_index(
x_ind, self.left_lower_x)
y_pos = self.calc_grid_central_xy_position_from_index(
y_ind, self.left_lower_y)
return x_pos, y_pos | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/grid_map_lib/grid_map_lib.py#L141-L147 | 2 | [
0,
1,
3,
5,
6
] | 71.428571 | [] | 0 | false | 77.037037 | 7 | 1 | 100 | 0 | def calc_grid_central_xy_position_from_xy_index(self, x_ind, y_ind):
x_pos = self.calc_grid_central_xy_position_from_index(
x_ind, self.left_lower_x)
y_pos = self.calc_grid_central_xy_position_from_index(
y_ind, self.left_lower_y)
return x_pos, y_pos | 465 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/grid_map_lib/grid_map_lib.py | GridMap.calc_grid_central_xy_position_from_index | (self, index, lower_pos) | return lower_pos + index * self.resolution + self.resolution / 2.0 | 149 | 150 | def calc_grid_central_xy_position_from_index(self, index, lower_pos):
return lower_pos + index * self.resolution + self.resolution / 2.0 | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/grid_map_lib/grid_map_lib.py#L149-L150 | 2 | [
0,
1
] | 100 | [] | 0 | true | 77.037037 | 2 | 1 | 100 | 0 | def calc_grid_central_xy_position_from_index(self, index, lower_pos):
return lower_pos + index * self.resolution + self.resolution / 2.0 | 466 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/grid_map_lib/grid_map_lib.py | GridMap.calc_xy_index_from_position | (self, pos, lower_pos, max_index) | 152 | 157 | def calc_xy_index_from_position(self, pos, lower_pos, max_index):
ind = int(np.floor((pos - lower_pos) / self.resolution))
if 0 <= ind <= max_index:
return ind
else:
return None | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/grid_map_lib/grid_map_lib.py#L152-L157 | 2 | [
0,
1,
2,
3
] | 66.666667 | [
5
] | 16.666667 | false | 77.037037 | 6 | 2 | 83.333333 | 0 | def calc_xy_index_from_position(self, pos, lower_pos, max_index):
ind = int(np.floor((pos - lower_pos) / self.resolution))
if 0 <= ind <= max_index:
return ind
else:
return None | 467 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/grid_map_lib/grid_map_lib.py | GridMap.check_occupied_from_xy_index | (self, xind, yind, occupied_val=1.0) | 159 | 166 | def check_occupied_from_xy_index(self, xind, yind, occupied_val=1.0):
val = self.get_value_from_xy_index(xind, yind)
if val is None or val >= occupied_val:
return True
else:
return False | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/grid_map_lib/grid_map_lib.py#L159-L166 | 2 | [
0,
1,
2,
3,
4,
5,
7
] | 87.5 | [] | 0 | false | 77.037037 | 8 | 3 | 100 | 0 | def check_occupied_from_xy_index(self, xind, yind, occupied_val=1.0):
val = self.get_value_from_xy_index(xind, yind)
if val is None or val >= occupied_val:
return True
else:
return False | 468 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/grid_map_lib/grid_map_lib.py | GridMap.expand_grid | (self) | 168 | 183 | def expand_grid(self):
xinds, yinds = [], []
for ix in range(self.width):
for iy in range(self.height):
if self.check_occupied_from_xy_index(ix, iy):
xinds.append(ix)
yinds.append(iy)
for (ix, iy) in zip(xinds, yinds):
... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/grid_map_lib/grid_map_lib.py#L168-L183 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15
] | 100 | [] | 0 | true | 77.037037 | 16 | 5 | 100 | 0 | def expand_grid(self):
xinds, yinds = [], []
for ix in range(self.width):
for iy in range(self.height):
if self.check_occupied_from_xy_index(ix, iy):
xinds.append(ix)
yinds.append(iy)
for (ix, iy) in zip(xinds, yinds):
... | 469 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/grid_map_lib/grid_map_lib.py | GridMap.check_inside_polygon | (iox, ioy, x, y) | return inside | 186 | 204 | def check_inside_polygon(iox, ioy, x, y):
npoint = len(x) - 1
inside = False
for i1 in range(npoint):
i2 = (i1 + 1) % (npoint + 1)
if x[i1] >= x[i2]:
min_x, max_x = x[i2], x[i1]
else:
min_x, max_x = x[i1], x[i2]
if... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/grid_map_lib/grid_map_lib.py#L186-L204 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
10,
11,
12,
13,
14,
15,
16,
17,
18
] | 94.736842 | [] | 0 | false | 77.037037 | 19 | 5 | 100 | 0 | def check_inside_polygon(iox, ioy, x, y):
npoint = len(x) - 1
inside = False
for i1 in range(npoint):
i2 = (i1 + 1) % (npoint + 1)
if x[i1] >= x[i2]:
min_x, max_x = x[i2], x[i1]
else:
min_x, max_x = x[i1], x[i2]
if... | 470 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/grid_map_lib/grid_map_lib.py | GridMap.print_grid_map_info | (self) | 206 | 214 | def print_grid_map_info(self):
print("width:", self.width)
print("height:", self.height)
print("resolution:", self.resolution)
print("center_x:", self.center_x)
print("center_y:", self.center_y)
print("left_lower_x:", self.left_lower_x)
print("left_lower_y:", self... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/grid_map_lib/grid_map_lib.py#L206-L214 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 100 | [] | 0 | true | 77.037037 | 9 | 1 | 100 | 0 | def print_grid_map_info(self):
print("width:", self.width)
print("height:", self.height)
print("resolution:", self.resolution)
print("center_x:", self.center_x)
print("center_y:", self.center_y)
print("left_lower_x:", self.left_lower_x)
print("left_lower_y:", self... | 471 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/grid_map_lib/grid_map_lib.py | GridMap.plot_grid_map | (self, ax=None) | return heat_map | 216 | 225 | def plot_grid_map(self, ax=None):
grid_data = np.reshape(np.array(self.data), (self.height, self.width))
if not ax:
fig, ax = plt.subplots()
heat_map = ax.pcolor(grid_data, cmap="Blues", vmin=0.0, vmax=1.0)
plt.axis("equal")
# plt.show()
return heat_map | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/grid_map_lib/grid_map_lib.py#L216-L225 | 2 | [
0,
1
] | 20 | [
2,
3,
4,
5,
6,
9
] | 60 | false | 77.037037 | 10 | 2 | 40 | 0 | def plot_grid_map(self, ax=None):
grid_data = np.reshape(np.array(self.data), (self.height, self.width))
if not ax:
fig, ax = plt.subplots()
heat_map = ax.pcolor(grid_data, cmap="Blues", vmin=0.0, vmax=1.0)
plt.axis("equal")
# plt.show()
return heat_map | 472 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/point_cloud_sampling/point_cloud_sampling.py | voxel_point_sampling | (original_points: npt.NDArray, voxel_size: float) | return points | Voxel Point Sampling function.
This function sample N-dimensional points with voxel grid.
Points in a same voxel grid will be merged by mean operation for sampling.
Parameters
----------
original_points : (M, N) N-dimensional points for sampling.
The number of points is M.
... | Voxel Point Sampling function.
This function sample N-dimensional points with voxel grid.
Points in a same voxel grid will be merged by mean operation for sampling. | 16 | 38 | def voxel_point_sampling(original_points: npt.NDArray, voxel_size: float):
"""
Voxel Point Sampling function.
This function sample N-dimensional points with voxel grid.
Points in a same voxel grid will be merged by mean operation for sampling.
Parameters
----------
original_points : (M, N)... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/point_cloud_sampling/point_cloud_sampling.py#L16-L38 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22
] | 100 | [] | 0 | true | 83.950617 | 23 | 3 | 100 | 13 | def voxel_point_sampling(original_points: npt.NDArray, voxel_size: float):
voxel_dict = defaultdict(list)
for i in range(original_points.shape[0]):
xyz = original_points[i, :]
xyz_index = tuple(xyz // voxel_size)
voxel_dict[xyz_index].append(xyz)
points = np.vstack([np.mean(v, axis=0... | 481 |
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/point_cloud_sampling/point_cloud_sampling.py | farthest_point_sampling | (orig_points: npt.NDArray,
n_points: int, seed: int) | return orig_points[selected_ids, :] | Farthest point sampling function
This function sample N-dimensional points with the farthest point policy.
Parameters
----------
orig_points : (M, N) N-dimensional points for sampling.
The number of points is M.
n_points : number of points for sampling
seed : random seed nu... | Farthest point sampling function
This function sample N-dimensional points with the farthest point policy. | 41 | 74 | def farthest_point_sampling(orig_points: npt.NDArray,
n_points: int, seed: int):
"""
Farthest point sampling function
This function sample N-dimensional points with the farthest point policy.
Parameters
----------
orig_points : (M, N) N-dimensional points for sampli... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/point_cloud_sampling/point_cloud_sampling.py#L41-L74 | 2 | [
0,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33
] | 52.941176 | [] | 0 | false | 83.950617 | 34 | 4 | 100 | 13 | def farthest_point_sampling(orig_points: npt.NDArray,
n_points: int, seed: int):
rng = np.random.default_rng(seed)
n_orig_points = orig_points.shape[0]
first_point_id = rng.choice(range(n_orig_points))
min_distances = np.ones(n_orig_points) * float("inf")
selected_ids = [... | 482 |
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/point_cloud_sampling/point_cloud_sampling.py | poisson_disk_sampling | (orig_points: npt.NDArray, n_points: int,
min_distance: float, seed: int, MAX_ITER=1000) | return orig_points[selected_ids, :] | Poisson disk sampling function
This function sample N-dimensional points randomly until the number of
points keeping minimum distance between selected points.
Parameters
----------
orig_points : (M, N) N-dimensional points for sampling.
The number of points is M.
n_points :... | Poisson disk sampling function
This function sample N-dimensional points randomly until the number of
points keeping minimum distance between selected points. | 77 | 113 | def poisson_disk_sampling(orig_points: npt.NDArray, n_points: int,
min_distance: float, seed: int, MAX_ITER=1000):
"""
Poisson disk sampling function
This function sample N-dimensional points randomly until the number of
points keeping minimum distance between selected points.
... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/point_cloud_sampling/point_cloud_sampling.py#L77-L113 | 2 | [
0,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
35,
36
] | 48.648649 | [
34
] | 2.702703 | false | 83.950617 | 37 | 5 | 97.297297 | 16 | def poisson_disk_sampling(orig_points: npt.NDArray, n_points: int,
min_distance: float, seed: int, MAX_ITER=1000):
rng = np.random.default_rng(seed)
selected_id = rng.choice(range(orig_points.shape[0]))
selected_ids = [selected_id]
loop = 0
while len(selected_ids) < n_point... | 483 |
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/point_cloud_sampling/point_cloud_sampling.py | plot_sampled_points | (original_points, sampled_points, method_name) | 116 | 126 | def plot_sampled_points(original_points, sampled_points, method_name):
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
ax.scatter(original_points[:, 0], original_points[:, 1],
original_points[:, 2], marker=".", label="Original points")
ax.scatter(sampled_points[:, 0], sampled_poi... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/point_cloud_sampling/point_cloud_sampling.py#L116-L126 | 2 | [
0
] | 9.090909 | [
1,
2,
3,
5,
8,
9,
10
] | 63.636364 | false | 83.950617 | 11 | 1 | 36.363636 | 0 | def plot_sampled_points(original_points, sampled_points, method_name):
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
ax.scatter(original_points[:, 0], original_points[:, 1],
original_points[:, 2], marker=".", label="Original points")
ax.scatter(sampled_points[:, 0], sampled_poi... | 484 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/gaussian_grid_map/gaussian_grid_map.py | generate_gaussian_grid_map | (ox, oy, xyreso, std) | return gmap, minx, maxx, miny, maxy | 19 | 41 | def generate_gaussian_grid_map(ox, oy, xyreso, std):
minx, miny, maxx, maxy, xw, yw = calc_grid_map_config(ox, oy, xyreso)
gmap = [[0.0 for i in range(yw)] for i in range(xw)]
for ix in range(xw):
for iy in range(yw):
x = ix * xyreso + minx
y = iy * xyreso + miny
... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/gaussian_grid_map/gaussian_grid_map.py#L19-L41 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22
] | 100 | [] | 0 | true | 90.697674 | 23 | 7 | 100 | 0 | def generate_gaussian_grid_map(ox, oy, xyreso, std):
minx, miny, maxx, maxy, xw, yw = calc_grid_map_config(ox, oy, xyreso)
gmap = [[0.0 for i in range(yw)] for i in range(xw)]
for ix in range(xw):
for iy in range(yw):
x = ix * xyreso + minx
y = iy * xyreso + miny
... | 485 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/gaussian_grid_map/gaussian_grid_map.py | calc_grid_map_config | (ox, oy, xyreso) | return minx, miny, maxx, maxy, xw, yw | 44 | 52 | def calc_grid_map_config(ox, oy, xyreso):
minx = round(min(ox) - EXTEND_AREA / 2.0)
miny = round(min(oy) - EXTEND_AREA / 2.0)
maxx = round(max(ox) + EXTEND_AREA / 2.0)
maxy = round(max(oy) + EXTEND_AREA / 2.0)
xw = int(round((maxx - minx) / xyreso))
yw = int(round((maxy - miny) / xyreso))
r... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/gaussian_grid_map/gaussian_grid_map.py#L44-L52 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 100 | [] | 0 | true | 90.697674 | 9 | 1 | 100 | 0 | def calc_grid_map_config(ox, oy, xyreso):
minx = round(min(ox) - EXTEND_AREA / 2.0)
miny = round(min(oy) - EXTEND_AREA / 2.0)
maxx = round(max(ox) + EXTEND_AREA / 2.0)
maxy = round(max(oy) + EXTEND_AREA / 2.0)
xw = int(round((maxx - minx) / xyreso))
yw = int(round((maxy - miny) / xyreso))
r... | 486 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/gaussian_grid_map/gaussian_grid_map.py | draw_heatmap | (data, minx, maxx, miny, maxy, xyreso) | 55 | 59 | def draw_heatmap(data, minx, maxx, miny, maxy, xyreso):
x, y = np.mgrid[slice(minx - xyreso / 2.0, maxx + xyreso / 2.0, xyreso),
slice(miny - xyreso / 2.0, maxy + xyreso / 2.0, xyreso)]
plt.pcolor(x, y, data, vmax=1.0, cmap=plt.cm.Blues)
plt.axis("equal") | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/gaussian_grid_map/gaussian_grid_map.py#L55-L59 | 2 | [
0
] | 20 | [
1,
3,
4
] | 60 | false | 90.697674 | 5 | 1 | 40 | 0 | def draw_heatmap(data, minx, maxx, miny, maxy, xyreso):
x, y = np.mgrid[slice(minx - xyreso / 2.0, maxx + xyreso / 2.0, xyreso),
slice(miny - xyreso / 2.0, maxy + xyreso / 2.0, xyreso)]
plt.pcolor(x, y, data, vmax=1.0, cmap=plt.cm.Blues)
plt.axis("equal") | 487 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/gaussian_grid_map/gaussian_grid_map.py | main | () | 62 | 82 | def main():
print(__file__ + " start!!")
xyreso = 0.5 # xy grid resolution
STD = 5.0 # standard diviation for gaussian distribution
for i in range(5):
ox = (np.random.rand(4) - 0.5) * 10.0
oy = (np.random.rand(4) - 0.5) * 10.0
gmap, minx, maxx, miny, maxy = generate_gaussian_... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/gaussian_grid_map/gaussian_grid_map.py#L62-L82 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 71.428571 | [] | 0 | false | 90.697674 | 21 | 3 | 100 | 0 | def main():
print(__file__ + " start!!")
xyreso = 0.5 # xy grid resolution
STD = 5.0 # standard diviation for gaussian distribution
for i in range(5):
ox = (np.random.rand(4) - 0.5) * 10.0
oy = (np.random.rand(4) - 0.5) * 10.0
gmap, minx, maxx, miny, maxy = generate_gaussian_... | 488 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/rectangle_fitting.py | main | () | 211 | 265 | def main():
# simulation parameters
sim_time = 30.0 # simulation time
dt = 0.2 # time tick
angle_resolution = np.deg2rad(3.0) # sensor angle resolution
v1 = VehicleSimulator(-10.0, 0.0, np.deg2rad(90.0),
0.0, 50.0 / 3.6, 3.0, 5.0)
v2 = VehicleSimulator(20.0, 10.0,... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/rectangle_fitting.py#L211-L265 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
10,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
53,
54
] | 69.230769 | [] | 0 | false | 81.935484 | 55 | 10 | 100 | 0 | def main():
# simulation parameters
sim_time = 30.0 # simulation time
dt = 0.2 # time tick
angle_resolution = np.deg2rad(3.0) # sensor angle resolution
v1 = VehicleSimulator(-10.0, 0.0, np.deg2rad(90.0),
0.0, 50.0 / 3.6, 3.0, 5.0)
v2 = VehicleSimulator(20.0, 10.0,... | 489 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/rectangle_fitting.py | LShapeFitting.__init__ | (self) | 39 | 45 | def __init__(self):
# Parameters
self.criteria = self.Criteria.VARIANCE
self.min_dist_of_closeness_criteria = 0.01 # [m]
self.d_theta_deg_for_search = 1.0 # [deg]
self.R0 = 3.0 # [m] range segmentation param
self.Rd = 0.001 | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/rectangle_fitting.py#L39-L45 | 2 | [
0,
1,
2,
3,
4,
5,
6
] | 100 | [] | 0 | true | 81.935484 | 7 | 1 | 100 | 0 | def __init__(self):
# Parameters
self.criteria = self.Criteria.VARIANCE
self.min_dist_of_closeness_criteria = 0.01 # [m]
self.d_theta_deg_for_search = 1.0 # [deg]
self.R0 = 3.0 # [m] range segmentation param
self.Rd = 0.001 | 490 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/rectangle_fitting.py | LShapeFitting.fitting | (self, ox, oy) | return rects, id_sets | 47 | 59 | def fitting(self, ox, oy):
# step1: Adaptive Range Segmentation
id_sets = self._adoptive_range_segmentation(ox, oy)
# step2 Rectangle search
rects = []
for ids in id_sets: # for each cluster
cx = [ox[i] for i in range(len(ox)) if i in ids]
cy = [oy[i] f... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/rectangle_fitting.py#L47-L59 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12
] | 100 | [] | 0 | true | 81.935484 | 13 | 4 | 100 | 0 | def fitting(self, ox, oy):
# step1: Adaptive Range Segmentation
id_sets = self._adoptive_range_segmentation(ox, oy)
# step2 Rectangle search
rects = []
for ids in id_sets: # for each cluster
cx = [ox[i] for i in range(len(ox)) if i in ids]
cy = [oy[i] f... | 491 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/rectangle_fitting.py | LShapeFitting._calc_area_criterion | (c1, c2) | return alpha | 62 | 70 | def _calc_area_criterion(c1, c2):
c1_max = max(c1)
c2_max = max(c2)
c1_min = min(c1)
c2_min = min(c2)
alpha = -(c1_max - c1_min) * (c2_max - c2_min)
return alpha | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/rectangle_fitting.py#L62-L70 | 2 | [
0
] | 11.111111 | [
1,
2,
3,
4,
6,
8
] | 66.666667 | false | 81.935484 | 9 | 1 | 33.333333 | 0 | def _calc_area_criterion(c1, c2):
c1_max = max(c1)
c2_max = max(c2)
c1_min = min(c1)
c2_min = min(c2)
alpha = -(c1_max - c1_min) * (c2_max - c2_min)
return alpha | 492 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/rectangle_fitting.py | LShapeFitting._calc_closeness_criterion | (self, c1, c2) | return beta | 72 | 84 | def _calc_closeness_criterion(self, c1, c2):
c1_max = max(c1)
c2_max = max(c2)
c1_min = min(c1)
c2_min = min(c2)
# Vectorization
D1 = np.minimum(c1_max - c1, c1 - c1_min)
D2 = np.minimum(c2_max - c2, c2 - c2_min)
d = np.maximum(np.minimum(D1, D2), self.mi... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/rectangle_fitting.py#L72-L84 | 2 | [
0
] | 7.692308 | [
1,
2,
3,
4,
7,
8,
9,
10,
12
] | 69.230769 | false | 81.935484 | 13 | 1 | 30.769231 | 0 | def _calc_closeness_criterion(self, c1, c2):
c1_max = max(c1)
c2_max = max(c2)
c1_min = min(c1)
c2_min = min(c2)
# Vectorization
D1 = np.minimum(c1_max - c1, c1 - c1_min)
D2 = np.minimum(c2_max - c2, c2 - c2_min)
d = np.maximum(np.minimum(D1, D2), self.mi... | 493 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/rectangle_fitting.py | LShapeFitting._calc_variance_criterion | (c1, c2) | return gamma | 87 | 102 | def _calc_variance_criterion(c1, c2):
c1_max = max(c1)
c2_max = max(c2)
c1_min = min(c1)
c2_min = min(c2)
# Vectorization
D1 = np.minimum(c1_max - c1, c1 - c1_min)
D2 = np.minimum(c2_max - c2, c2 - c2_min)
E1 = D1[D1 < D2]
E2 = D2[D1 >= D2]
... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/rectangle_fitting.py#L87-L102 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15
] | 100 | [] | 0 | true | 81.935484 | 16 | 1 | 100 | 0 | def _calc_variance_criterion(c1, c2):
c1_max = max(c1)
c2_max = max(c2)
c1_min = min(c1)
c2_min = min(c2)
# Vectorization
D1 = np.minimum(c1_max - c1, c1 - c1_min)
D2 = np.minimum(c2_max - c2, c2 - c2_min)
E1 = D1[D1 < D2]
E2 = D2[D1 >= D2]
... | 494 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/rectangle_fitting.py | LShapeFitting._rectangle_search | (self, x, y) | return rect | 104 | 149 | def _rectangle_search(self, x, y):
X = np.array([x, y]).T
d_theta = np.deg2rad(self.d_theta_deg_for_search)
min_cost = (-float('inf'), None)
for theta in np.arange(0.0, np.pi / 2.0 - d_theta, d_theta):
c = X @ rot_mat_2d(theta)
c1 = c[:, 0]
c2 = c[:... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/rectangle_fitting.py#L104-L149 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
16,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45
] | 95.652174 | [
15,
17
] | 4.347826 | false | 81.935484 | 46 | 6 | 95.652174 | 0 | def _rectangle_search(self, x, y):
X = np.array([x, y]).T
d_theta = np.deg2rad(self.d_theta_deg_for_search)
min_cost = (-float('inf'), None)
for theta in np.arange(0.0, np.pi / 2.0 - d_theta, d_theta):
c = X @ rot_mat_2d(theta)
c1 = c[:, 0]
c2 = c[:... | 495 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/rectangle_fitting.py | LShapeFitting._adoptive_range_segmentation | (self, ox, oy) | return S | 151 | 175 | def _adoptive_range_segmentation(self, ox, oy):
# Setup initial cluster
S = []
for i, _ in enumerate(ox):
C = set()
R = self.R0 + self.Rd * np.linalg.norm([ox[i], oy[i]])
for j, _ in enumerate(ox):
d = np.hypot(ox[i] - ox[j], oy[i] - oy[j])
... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/rectangle_fitting.py#L151-L175 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24
] | 100 | [] | 0 | true | 81.935484 | 25 | 8 | 100 | 0 | def _adoptive_range_segmentation(self, ox, oy):
# Setup initial cluster
S = []
for i, _ in enumerate(ox):
C = set()
R = self.R0 + self.Rd * np.linalg.norm([ox[i], oy[i]])
for j, _ in enumerate(ox):
d = np.hypot(ox[i] - ox[j], oy[i] - oy[j])
... | 496 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/rectangle_fitting.py | RectangleData.__init__ | (self) | 180 | 186 | def __init__(self):
self.a = [None] * 4
self.b = [None] * 4
self.c = [None] * 4
self.rect_c_x = [None] * 5
self.rect_c_y = [None] * 5 | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/rectangle_fitting.py#L180-L186 | 2 | [
0,
1,
2,
3,
4,
5,
6
] | 100 | [] | 0 | true | 81.935484 | 7 | 1 | 100 | 0 | def __init__(self):
self.a = [None] * 4
self.b = [None] * 4
self.c = [None] * 4
self.rect_c_x = [None] * 5
self.rect_c_y = [None] * 5 | 497 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/rectangle_fitting.py | RectangleData.plot | (self) | 188 | 190 | def plot(self):
self.calc_rect_contour()
plt.plot(self.rect_c_x, self.rect_c_y, "-r") | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/rectangle_fitting.py#L188-L190 | 2 | [
0
] | 33.333333 | [
1,
2
] | 66.666667 | false | 81.935484 | 3 | 1 | 33.333333 | 0 | def plot(self):
self.calc_rect_contour()
plt.plot(self.rect_c_x, self.rect_c_y, "-r") | 498 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/rectangle_fitting.py | RectangleData.calc_rect_contour | (self) | 192 | 202 | def calc_rect_contour(self):
self.rect_c_x[0], self.rect_c_y[0] = self.calc_cross_point(
self.a[0:2], self.b[0:2], self.c[0:2])
self.rect_c_x[1], self.rect_c_y[1] = self.calc_cross_point(
self.a[1:3], self.b[1:3], self.c[1:3])
self.rect_c_x[2], self.rect_c_y[2] = self.ca... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/rectangle_fitting.py#L192-L202 | 2 | [
0,
1
] | 18.181818 | [
2,
4,
6,
8,
10
] | 45.454545 | false | 81.935484 | 11 | 1 | 54.545455 | 0 | def calc_rect_contour(self):
self.rect_c_x[0], self.rect_c_y[0] = self.calc_cross_point(
self.a[0:2], self.b[0:2], self.c[0:2])
self.rect_c_x[1], self.rect_c_y[1] = self.calc_cross_point(
self.a[1:3], self.b[1:3], self.c[1:3])
self.rect_c_x[2], self.rect_c_y[2] = self.ca... | 499 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/rectangle_fitting.py | RectangleData.calc_cross_point | (a, b, c) | return x, y | 205 | 208 | def calc_cross_point(a, b, c):
x = (b[0] * -c[1] - b[1] * -c[0]) / (a[0] * b[1] - a[1] * b[0])
y = (a[1] * -c[0] - a[0] * -c[1]) / (a[0] * b[1] - a[1] * b[0])
return x, y | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/rectangle_fitting.py#L205-L208 | 2 | [
0
] | 25 | [
1,
2,
3
] | 75 | false | 81.935484 | 4 | 1 | 25 | 0 | def calc_cross_point(a, b, c):
x = (b[0] * -c[1] - b[1] * -c[0]) / (a[0] * b[1] - a[1] * b[0])
y = (a[1] * -c[0] - a[0] * -c[1]) / (a[0] * b[1] - a[1] * b[0])
return x, y | 500 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/simulator.py | VehicleSimulator.__init__ | (self, i_x, i_y, i_yaw, i_v, max_v, w, L) | 22 | 30 | def __init__(self, i_x, i_y, i_yaw, i_v, max_v, w, L):
self.x = i_x
self.y = i_y
self.yaw = i_yaw
self.v = i_v
self.max_v = max_v
self.W = w
self.L = L
self._calc_vehicle_contour() | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/simulator.py#L22-L30 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 100 | [] | 0 | true | 95.454545 | 9 | 1 | 100 | 0 | def __init__(self, i_x, i_y, i_yaw, i_v, max_v, w, L):
self.x = i_x
self.y = i_y
self.yaw = i_yaw
self.v = i_v
self.max_v = max_v
self.W = w
self.L = L
self._calc_vehicle_contour() | 501 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/simulator.py | VehicleSimulator.update | (self, dt, a, omega) | 32 | 38 | def update(self, dt, a, omega):
self.x += self.v * np.cos(self.yaw) * dt
self.y += self.v * np.sin(self.yaw) * dt
self.yaw += omega * dt
self.v += a * dt
if self.v >= self.max_v:
self.v = self.max_v | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/simulator.py#L32-L38 | 2 | [
0,
1,
2,
3,
4,
5
] | 85.714286 | [
6
] | 14.285714 | false | 95.454545 | 7 | 2 | 85.714286 | 0 | def update(self, dt, a, omega):
self.x += self.v * np.cos(self.yaw) * dt
self.y += self.v * np.sin(self.yaw) * dt
self.yaw += omega * dt
self.v += a * dt
if self.v >= self.max_v:
self.v = self.max_v | 502 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/simulator.py | VehicleSimulator.plot | (self) | 40 | 45 | def plot(self):
plt.plot(self.x, self.y, ".b")
# convert global coordinate
gx, gy = self.calc_global_contour()
plt.plot(gx, gy, "--b") | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/simulator.py#L40-L45 | 2 | [
0
] | 16.666667 | [
1,
4,
5
] | 50 | false | 95.454545 | 6 | 1 | 50 | 0 | def plot(self):
plt.plot(self.x, self.y, ".b")
# convert global coordinate
gx, gy = self.calc_global_contour()
plt.plot(gx, gy, "--b") | 503 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/simulator.py | VehicleSimulator.calc_global_contour | (self) | return gx, gy | 47 | 52 | def calc_global_contour(self):
gxy = np.stack([self.vc_x, self.vc_y]).T @ rot_mat_2d(self.yaw)
gx = gxy[:, 0] + self.x
gy = gxy[:, 1] + self.y
return gx, gy | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/simulator.py#L47-L52 | 2 | [
0,
1,
2,
3,
4,
5
] | 100 | [] | 0 | true | 95.454545 | 6 | 1 | 100 | 0 | def calc_global_contour(self):
gxy = np.stack([self.vc_x, self.vc_y]).T @ rot_mat_2d(self.yaw)
gx = gxy[:, 0] + self.x
gy = gxy[:, 1] + self.y
return gx, gy | 504 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/simulator.py | VehicleSimulator._calc_vehicle_contour | (self) | 54 | 74 | def _calc_vehicle_contour(self):
self.vc_x = []
self.vc_y = []
self.vc_x.append(self.L / 2.0)
self.vc_y.append(self.W / 2.0)
self.vc_x.append(self.L / 2.0)
self.vc_y.append(-self.W / 2.0)
self.vc_x.append(-self.L / 2.0)
self.vc_y.append(-self.W / 2.0)
... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/simulator.py#L54-L74 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20
] | 100 | [] | 0 | true | 95.454545 | 21 | 1 | 100 | 0 | def _calc_vehicle_contour(self):
self.vc_x = []
self.vc_y = []
self.vc_x.append(self.L / 2.0)
self.vc_y.append(self.W / 2.0)
self.vc_x.append(self.L / 2.0)
self.vc_y.append(-self.W / 2.0)
self.vc_x.append(-self.L / 2.0)
self.vc_y.append(-self.W / 2.0)
... | 505 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/simulator.py | VehicleSimulator._interpolate | (x, y) | return rx, ry | 77 | 91 | def _interpolate(x, y):
rx, ry = [], []
d_theta = 0.05
for i in range(len(x) - 1):
rx.extend([(1.0 - theta) * x[i] + theta * x[i + 1]
for theta in np.arange(0.0, 1.0, d_theta)])
ry.extend([(1.0 - theta) * y[i] + theta * y[i + 1]
... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/simulator.py#L77-L91 | 2 | [
0,
1,
2,
3,
4,
6,
8,
9,
11,
13,
14
] | 73.333333 | [] | 0 | false | 95.454545 | 15 | 6 | 100 | 0 | def _interpolate(x, y):
rx, ry = [], []
d_theta = 0.05
for i in range(len(x) - 1):
rx.extend([(1.0 - theta) * x[i] + theta * x[i + 1]
for theta in np.arange(0.0, 1.0, d_theta)])
ry.extend([(1.0 - theta) * y[i] + theta * y[i + 1]
... | 506 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/simulator.py | LidarSimulator.__init__ | (self) | 96 | 97 | def __init__(self):
self.range_noise = 0.01 | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/simulator.py#L96-L97 | 2 | [
0,
1
] | 100 | [] | 0 | true | 95.454545 | 2 | 1 | 100 | 0 | def __init__(self):
self.range_noise = 0.01 | 507 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/simulator.py | LidarSimulator.get_observation_points | (self, v_list, angle_resolution) | return rx, ry | 99 | 120 | def get_observation_points(self, v_list, angle_resolution):
x, y, angle, r = [], [], [], []
# store all points
for v in v_list:
gx, gy = v.calc_global_contour()
for vx, vy in zip(gx, gy):
v_angle = math.atan2(vy, vx)
vr = np.hypot(vx, vy... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/simulator.py#L99-L120 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21
] | 95.454545 | [] | 0 | false | 95.454545 | 22 | 3 | 100 | 0 | def get_observation_points(self, v_list, angle_resolution):
x, y, angle, r = [], [], [], []
# store all points
for v in v_list:
gx, gy = v.calc_global_contour()
for vx, vy in zip(gx, gy):
v_angle = math.atan2(vy, vx)
vr = np.hypot(vx, vy... | 508 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/rectangle_fitting/simulator.py | LidarSimulator.ray_casting_filter | (theta_l, range_l, angle_resolution) | return rx, ry | 123 | 140 | def ray_casting_filter(theta_l, range_l, angle_resolution):
rx, ry = [], []
range_db = [float("inf") for _ in range(
int(np.floor((np.pi * 2.0) / angle_resolution)) + 1)]
for i in range(len(theta_l)):
angle_id = int(round(theta_l[i] / angle_resolution))
if r... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/rectangle_fitting/simulator.py#L123-L140 | 2 | [
0,
1,
2,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17
] | 94.444444 | [] | 0 | false | 95.454545 | 18 | 6 | 100 | 0 | def ray_casting_filter(theta_l, range_l, angle_resolution):
rx, ry = [], []
range_db = [float("inf") for _ in range(
int(np.floor((np.pi * 2.0) / angle_resolution)) + 1)]
for i in range(len(theta_l)):
angle_id = int(round(theta_l[i] / angle_resolution))
if r... | 509 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/circle_fitting/circle_fitting.py | circle_fitting | (x, y) | return (cxe, cye, re, error) | Circle Fitting with least squared
input: point x-y positions
output cxe x center position
cye y center position
re radius of circle
error: prediction error | Circle Fitting with least squared
input: point x-y positions
output cxe x center position
cye y center position
re radius of circle
error: prediction error | 17 | 49 | def circle_fitting(x, y):
"""
Circle Fitting with least squared
input: point x-y positions
output cxe x center position
cye y center position
re radius of circle
error: prediction error
"""
sumx = sum(x)
sumy = sum(y)
sumx2 = sum... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/circle_fitting/circle_fitting.py#L17-L49 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32
] | 100 | [] | 0 | true | 98.4375 | 33 | 8 | 100 | 6 | def circle_fitting(x, y):
sumx = sum(x)
sumy = sum(y)
sumx2 = sum([ix ** 2 for ix in x])
sumy2 = sum([iy ** 2 for iy in y])
sumxy = sum([ix * iy for (ix, iy) in zip(x, y)])
F = np.array([[sumx2, sumxy, sumx],
[sumxy, sumy2, sumy],
[sumx, sumy, len(x)]])
... | 510 |
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/circle_fitting/circle_fitting.py | get_sample_points | (cx, cy, cr, angle_reso) | return rx, ry | 52 | 70 | def get_sample_points(cx, cy, cr, angle_reso):
x, y, angle, r = [], [], [], []
# points sampling
for theta in np.arange(0.0, 2.0 * math.pi, angle_reso):
nx = cx + cr * math.cos(theta)
ny = cy + cr * math.sin(theta)
nangle = math.atan2(ny, nx)
nr = math.hypot(nx, ny) * random... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/circle_fitting/circle_fitting.py#L52-L70 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18
] | 100 | [] | 0 | true | 98.4375 | 19 | 2 | 100 | 0 | def get_sample_points(cx, cy, cr, angle_reso):
x, y, angle, r = [], [], [], []
# points sampling
for theta in np.arange(0.0, 2.0 * math.pi, angle_reso):
nx = cx + cr * math.cos(theta)
ny = cy + cr * math.sin(theta)
nangle = math.atan2(ny, nx)
nr = math.hypot(nx, ny) * random... | 511 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/circle_fitting/circle_fitting.py | ray_casting_filter | (xl, yl, thetal, rangel, angle_reso) | return rx, ry | 73 | 90 | def ray_casting_filter(xl, yl, thetal, rangel, angle_reso):
rx, ry = [], []
rangedb = [float("inf") for _ in range(
int(math.floor((math.pi * 2.0) / angle_reso)) + 1)]
for i, _ in enumerate(thetal):
angleid = math.floor(thetal[i] / angle_reso)
if rangedb[angleid] > rangel[i]:
... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/circle_fitting/circle_fitting.py#L73-L90 | 2 | [
0,
1,
2,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17
] | 94.444444 | [] | 0 | false | 98.4375 | 18 | 6 | 100 | 0 | def ray_casting_filter(xl, yl, thetal, rangel, angle_reso):
rx, ry = [], []
rangedb = [float("inf") for _ in range(
int(math.floor((math.pi * 2.0) / angle_reso)) + 1)]
for i, _ in enumerate(thetal):
angleid = math.floor(thetal[i] / angle_reso)
if rangedb[angleid] > rangel[i]:
... | 512 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/circle_fitting/circle_fitting.py | plot_circle | (x, y, size, color="-b") | 93 | 98 | def plot_circle(x, y, size, color="-b"): # pragma: no cover
deg = list(range(0, 360, 5))
deg.append(0)
xl = [x + size * math.cos(np.deg2rad(d)) for d in deg]
yl = [y + size * math.sin(np.deg2rad(d)) for d in deg]
plt.plot(xl, yl, color) | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/circle_fitting/circle_fitting.py#L93-L98 | 2 | [] | 0 | [] | 0 | false | 98.4375 | 6 | 3 | 100 | 0 | def plot_circle(x, y, size, color="-b"): # pragma: no cover
deg = list(range(0, 360, 5))
deg.append(0)
xl = [x + size * math.cos(np.deg2rad(d)) for d in deg]
yl = [y + size * math.sin(np.deg2rad(d)) for d in deg]
plt.plot(xl, yl, color) | 513 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Mapping/circle_fitting/circle_fitting.py | main | () | 101 | 137 | def main():
# simulation parameters
simtime = 15.0 # simulation time
dt = 1.0 # time tick
cx = -2.0 # initial x position of obstacle
cy = -8.0 # initial y position of obstacle
cr = 1.0 # obstacle radious
theta = np.deg2rad(30.0) # obstacle moving direction
angle_reso = np.deg2rad... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Mapping/circle_fitting/circle_fitting.py#L101-L137 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
35,
36
] | 92.857143 | [] | 0 | false | 98.4375 | 37 | 3 | 100 | 0 | def main():
# simulation parameters
simtime = 15.0 # simulation time
dt = 1.0 # time tick
cx = -2.0 # initial x position of obstacle
cy = -8.0 # initial y position of obstacle
cr = 1.0 # obstacle radious
theta = np.deg2rad(30.0) # obstacle moving direction
angle_reso = np.deg2rad... | 514 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/extended_kalman_filter/extended_kalman_filter.py | calc_input | () | return u | 37 | 41 | def calc_input():
v = 1.0 # [m/s]
yawrate = 0.1 # [rad/s]
u = np.array([[v], [yawrate]])
return u | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/extended_kalman_filter/extended_kalman_filter.py#L37-L41 | 2 | [
0,
1,
2,
3,
4
] | 100 | [] | 0 | true | 87.356322 | 5 | 1 | 100 | 0 | def calc_input():
v = 1.0 # [m/s]
yawrate = 0.1 # [rad/s]
u = np.array([[v], [yawrate]])
return u | 515 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/extended_kalman_filter/extended_kalman_filter.py | observation | (xTrue, xd, u) | return xTrue, z, xd, ud | 44 | 55 | def observation(xTrue, xd, u):
xTrue = motion_model(xTrue, u)
# add noise to gps x-y
z = observation_model(xTrue) + GPS_NOISE @ np.random.randn(2, 1)
# add noise to input
ud = u + INPUT_NOISE @ np.random.randn(2, 1)
xd = motion_model(xd, ud)
return xTrue, z, xd, ud | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/extended_kalman_filter/extended_kalman_filter.py#L44-L55 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 | [] | 0 | true | 87.356322 | 12 | 1 | 100 | 0 | def observation(xTrue, xd, u):
xTrue = motion_model(xTrue, u)
# add noise to gps x-y
z = observation_model(xTrue) + GPS_NOISE @ np.random.randn(2, 1)
# add noise to input
ud = u + INPUT_NOISE @ np.random.randn(2, 1)
xd = motion_model(xd, ud)
return xTrue, z, xd, ud | 516 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/extended_kalman_filter/extended_kalman_filter.py | motion_model | (x, u) | return x | 58 | 71 | def motion_model(x, u):
F = np.array([[1.0, 0, 0, 0],
[0, 1.0, 0, 0],
[0, 0, 1.0, 0],
[0, 0, 0, 0]])
B = np.array([[DT * math.cos(x[2, 0]), 0],
[DT * math.sin(x[2, 0]), 0],
[0.0, DT],
[1.0, 0.0]])
x... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/extended_kalman_filter/extended_kalman_filter.py#L58-L71 | 2 | [
0,
1,
5,
6,
10,
11,
12,
13
] | 57.142857 | [] | 0 | false | 87.356322 | 14 | 1 | 100 | 0 | def motion_model(x, u):
F = np.array([[1.0, 0, 0, 0],
[0, 1.0, 0, 0],
[0, 0, 1.0, 0],
[0, 0, 0, 0]])
B = np.array([[DT * math.cos(x[2, 0]), 0],
[DT * math.sin(x[2, 0]), 0],
[0.0, DT],
[1.0, 0.0]])
x... | 517 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/extended_kalman_filter/extended_kalman_filter.py | observation_model | (x) | return z | 74 | 82 | def observation_model(x):
H = np.array([
[1, 0, 0, 0],
[0, 1, 0, 0]
])
z = H @ x
return z | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/extended_kalman_filter/extended_kalman_filter.py#L74-L82 | 2 | [
0,
1,
5,
6,
7,
8
] | 66.666667 | [] | 0 | false | 87.356322 | 9 | 1 | 100 | 0 | def observation_model(x):
H = np.array([
[1, 0, 0, 0],
[0, 1, 0, 0]
])
z = H @ x
return z | 518 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/extended_kalman_filter/extended_kalman_filter.py | jacob_f | (x, u) | return jF | Jacobian of Motion Model
motion model
x_{t+1} = x_t+v*dt*cos(yaw)
y_{t+1} = y_t+v*dt*sin(yaw)
yaw_{t+1} = yaw_t+omega*dt
v_{t+1} = v{t}
so
dx/dyaw = -v*dt*sin(yaw)
dx/dv = dt*cos(yaw)
dy/dyaw = v*dt*cos(yaw)
dy/dv = dt*sin(yaw) | Jacobian of Motion Model | 85 | 108 | def jacob_f(x, u):
"""
Jacobian of Motion Model
motion model
x_{t+1} = x_t+v*dt*cos(yaw)
y_{t+1} = y_t+v*dt*sin(yaw)
yaw_{t+1} = yaw_t+omega*dt
v_{t+1} = v{t}
so
dx/dyaw = -v*dt*sin(yaw)
dx/dv = dt*cos(yaw)
dy/dyaw = v*dt*cos(yaw)
dy/dv = dt*sin(yaw)
"""
yaw = x[... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/extended_kalman_filter/extended_kalman_filter.py#L85-L108 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23
] | 100 | [] | 0 | true | 87.356322 | 24 | 1 | 100 | 12 | def jacob_f(x, u):
yaw = x[2, 0]
v = u[0, 0]
jF = np.array([
[1.0, 0.0, -DT * v * math.sin(yaw), DT * math.cos(yaw)],
[0.0, 1.0, DT * v * math.cos(yaw), DT * math.sin(yaw)],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0]])
return jF | 519 |
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/extended_kalman_filter/extended_kalman_filter.py | jacob_h | () | return jH | 111 | 118 | def jacob_h():
# Jacobian of Observation Model
jH = np.array([
[1, 0, 0, 0],
[0, 1, 0, 0]
])
return jH | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/extended_kalman_filter/extended_kalman_filter.py#L111-L118 | 2 | [
0,
1,
2,
6,
7
] | 62.5 | [] | 0 | false | 87.356322 | 8 | 1 | 100 | 0 | def jacob_h():
# Jacobian of Observation Model
jH = np.array([
[1, 0, 0, 0],
[0, 1, 0, 0]
])
return jH | 520 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/extended_kalman_filter/extended_kalman_filter.py | ekf_estimation | (xEst, PEst, z, u) | return xEst, PEst | 121 | 135 | def ekf_estimation(xEst, PEst, z, u):
# Predict
xPred = motion_model(xEst, u)
jF = jacob_f(xEst, u)
PPred = jF @ PEst @ jF.T + Q
# Update
jH = jacob_h()
zPred = observation_model(xPred)
y = z - zPred
S = jH @ PPred @ jH.T + R
K = PPred @ jH.T @ np.linalg.inv(S)
xEst = xPre... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/extended_kalman_filter/extended_kalman_filter.py#L121-L135 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14
] | 100 | [] | 0 | true | 87.356322 | 15 | 1 | 100 | 0 | def ekf_estimation(xEst, PEst, z, u):
# Predict
xPred = motion_model(xEst, u)
jF = jacob_f(xEst, u)
PPred = jF @ PEst @ jF.T + Q
# Update
jH = jacob_h()
zPred = observation_model(xPred)
y = z - zPred
S = jH @ PPred @ jH.T + R
K = PPred @ jH.T @ np.linalg.inv(S)
xEst = xPre... | 521 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/extended_kalman_filter/extended_kalman_filter.py | plot_covariance_ellipse | (xEst, PEst) | 138 | 158 | def plot_covariance_ellipse(xEst, PEst): # pragma: no cover
Pxy = PEst[0:2, 0:2]
eigval, eigvec = np.linalg.eig(Pxy)
if eigval[0] >= eigval[1]:
bigind = 0
smallind = 1
else:
bigind = 1
smallind = 0
t = np.arange(0, 2 * math.pi + 0.1, 0.1)
a = math.sqrt(eigval[b... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/extended_kalman_filter/extended_kalman_filter.py#L138-L158 | 2 | [] | 0 | [] | 0 | false | 87.356322 | 21 | 4 | 100 | 0 | def plot_covariance_ellipse(xEst, PEst): # pragma: no cover
Pxy = PEst[0:2, 0:2]
eigval, eigvec = np.linalg.eig(Pxy)
if eigval[0] >= eigval[1]:
bigind = 0
smallind = 1
else:
bigind = 1
smallind = 0
t = np.arange(0, 2 * math.pi + 0.1, 0.1)
a = math.sqrt(eigval[b... | 522 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/extended_kalman_filter/extended_kalman_filter.py | main | () | 161 | 208 | def main():
print(__file__ + " start!!")
time = 0.0
# State Vector [x y yaw v]'
xEst = np.zeros((4, 1))
xTrue = np.zeros((4, 1))
PEst = np.eye(4)
xDR = np.zeros((4, 1)) # Dead reckoning
# history
hxEst = xEst
hxTrue = xTrue
hxDR = xTrue
hz = np.zeros((2, 1))
whi... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/extended_kalman_filter/extended_kalman_filter.py#L161-L208 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32
] | 68.75 | [
33,
35,
37,
38,
40,
42,
44,
45,
46,
47
] | 20.833333 | false | 87.356322 | 48 | 3 | 79.166667 | 0 | def main():
print(__file__ + " start!!")
time = 0.0
# State Vector [x y yaw v]'
xEst = np.zeros((4, 1))
xTrue = np.zeros((4, 1))
PEst = np.eye(4)
xDR = np.zeros((4, 1)) # Dead reckoning
# history
hxEst = xEst
hxTrue = xTrue
hxDR = xTrue
hz = np.zeros((2, 1))
whi... | 523 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/cubature_kalman_filter/cubature_kalman_filter.py | cubature_kalman_filter | (x_est, p_est, z) | return x_upd, p_upd | 88 | 91 | def cubature_kalman_filter(x_est, p_est, z):
x_pred, p_pred = cubature_prediction(x_est, p_est)
x_upd, p_upd = cubature_update(x_pred, p_pred, z)
return x_upd, p_upd | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/cubature_kalman_filter/cubature_kalman_filter.py#L88-L91 | 2 | [
0,
1,
2,
3
] | 100 | [] | 0 | true | 72.727273 | 4 | 1 | 100 | 0 | def cubature_kalman_filter(x_est, p_est, z):
x_pred, p_pred = cubature_prediction(x_est, p_est)
x_upd, p_upd = cubature_update(x_pred, p_pred, z)
return x_upd, p_upd | 524 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/cubature_kalman_filter/cubature_kalman_filter.py | f | (x) | return x | Motion Model
References:
http://fusion.isif.org/proceedings/fusion08CD/papers/1569107835.pdf
https://github.com/balzer82/Kalman | Motion Model
References:
http://fusion.isif.org/proceedings/fusion08CD/papers/1569107835.pdf
https://github.com/balzer82/Kalman | 94 | 106 | def f(x):
"""
Motion Model
References:
http://fusion.isif.org/proceedings/fusion08CD/papers/1569107835.pdf
https://github.com/balzer82/Kalman
"""
x[0] = x[0] + (x[3]/x[4]) * (np.sin(x[4] * dt + x[2]) - np.sin(x[2]))
x[1] = x[1] + (x[3]/x[4]) * (- np.cos(x[4] * dt + x[2]) + np.cos(x[2]))
... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/cubature_kalman_filter/cubature_kalman_filter.py#L94-L106 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12
] | 100 | [] | 0 | true | 72.727273 | 13 | 1 | 100 | 4 | def f(x):
x[0] = x[0] + (x[3]/x[4]) * (np.sin(x[4] * dt + x[2]) - np.sin(x[2]))
x[1] = x[1] + (x[3]/x[4]) * (- np.cos(x[4] * dt + x[2]) + np.cos(x[2]))
x[2] = x[2] + x[4] * dt
x[3] = x[3]
x[4] = x[4]
return x | 525 |
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/cubature_kalman_filter/cubature_kalman_filter.py | h | (x) | return x | Measurement Model | Measurement Model | 109 | 112 | def h(x):
"""Measurement Model"""
x = hx @ x
return x | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/cubature_kalman_filter/cubature_kalman_filter.py#L109-L112 | 2 | [
0,
1,
2,
3
] | 100 | [] | 0 | true | 72.727273 | 4 | 1 | 100 | 1 | def h(x):
x = hx @ x
return x | 526 |
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/cubature_kalman_filter/cubature_kalman_filter.py | sigma | (x, p) | return SP, W | Unscented Transform with Cubature Rule
Generate 2n Sigma Points to represent the nonlinear motion
Assign Weights to each Sigma Point, Wi = 1/2n
Cubature Rule - Special Case of Unscented Transform
W0 = 0, no extra tuning parameters, no negative weights | Unscented Transform with Cubature Rule
Generate 2n Sigma Points to represent the nonlinear motion
Assign Weights to each Sigma Point, Wi = 1/2n
Cubature Rule - Special Case of Unscented Transform
W0 = 0, no extra tuning parameters, no negative weights | 115 | 132 | def sigma(x, p):
"""
Unscented Transform with Cubature Rule
Generate 2n Sigma Points to represent the nonlinear motion
Assign Weights to each Sigma Point, Wi = 1/2n
Cubature Rule - Special Case of Unscented Transform
W0 = 0, no extra tuning parameters, no negative weights
"""
n = np.shap... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/cubature_kalman_filter/cubature_kalman_filter.py#L115-L132 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17
] | 100 | [] | 0 | true | 72.727273 | 18 | 2 | 100 | 5 | def sigma(x, p):
n = np.shape(x)[0]
SP = np.zeros((n, 2*n))
W = np.zeros((1, 2*n))
for i in range(n):
SD = sqrtm(p)
SP[:, i] = (x + (math.sqrt(n) * SD[:, i]).reshape((n, 1))).flatten()
SP[:, i+n] = (x - (math.sqrt(n) * SD[:, i]).reshape((n, 1))).flatten()
W[:, i] = 1/(2*n... | 527 |
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/cubature_kalman_filter/cubature_kalman_filter.py | cubature_prediction | (x_pred, p_pred) | return x_pred, p_pred | 135 | 145 | def cubature_prediction(x_pred, p_pred):
n = np.shape(x_pred)[0]
[SP, W] = sigma(x_pred, p_pred)
x_pred = np.zeros((n, 1))
p_pred = q
for i in range(2*n):
x_pred = x_pred + (f(SP[:, i]).reshape((n, 1)) * W[0, i])
for i in range(2*n):
p_step = (f(SP[:, i]).reshape((n, 1)) - x_pred... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/cubature_kalman_filter/cubature_kalman_filter.py#L135-L145 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
] | 100 | [] | 0 | true | 72.727273 | 11 | 3 | 100 | 0 | def cubature_prediction(x_pred, p_pred):
n = np.shape(x_pred)[0]
[SP, W] = sigma(x_pred, p_pred)
x_pred = np.zeros((n, 1))
p_pred = q
for i in range(2*n):
x_pred = x_pred + (f(SP[:, i]).reshape((n, 1)) * W[0, i])
for i in range(2*n):
p_step = (f(SP[:, i]).reshape((n, 1)) - x_pred... | 528 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/cubature_kalman_filter/cubature_kalman_filter.py | cubature_update | (x_pred, p_pred, z) | return x_pred, p_pred | 148 | 164 | def cubature_update(x_pred, p_pred, z):
n = np.shape(x_pred)[0]
m = np.shape(z)[0]
[SP, W] = sigma(x_pred, p_pred)
y_k = np.zeros((m, 1))
P_xy = np.zeros((n, m))
s = r
for i in range(2*n):
y_k = y_k + (h(SP[:, i]).reshape((m, 1)) * W[0, i])
for i in range(2*n):
p_step = (... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/cubature_kalman_filter/cubature_kalman_filter.py#L148-L164 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
13,
14,
15,
16
] | 94.117647 | [] | 0 | false | 72.727273 | 17 | 3 | 100 | 0 | def cubature_update(x_pred, p_pred, z):
n = np.shape(x_pred)[0]
m = np.shape(z)[0]
[SP, W] = sigma(x_pred, p_pred)
y_k = np.zeros((m, 1))
P_xy = np.zeros((n, m))
s = r
for i in range(2*n):
y_k = y_k + (h(SP[:, i]).reshape((m, 1)) * W[0, i])
for i in range(2*n):
p_step = (... | 529 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/cubature_kalman_filter/cubature_kalman_filter.py | generate_measurement | (x_true) | return z | 167 | 170 | def generate_measurement(x_true):
gz = hx @ x_true
z = gz + z_noise @ np.random.randn(4, 1)
return z | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/cubature_kalman_filter/cubature_kalman_filter.py#L167-L170 | 2 | [
0,
1,
2,
3
] | 100 | [] | 0 | true | 72.727273 | 4 | 1 | 100 | 0 | def generate_measurement(x_true):
gz = hx @ x_true
z = gz + z_noise @ np.random.randn(4, 1)
return z | 530 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/cubature_kalman_filter/cubature_kalman_filter.py | plot_animation | (i, x_true_cat, x_est_cat, z) | 173 | 182 | def plot_animation(i, x_true_cat, x_est_cat, z):
if i == 0:
plt.plot(x_true_cat[0], x_true_cat[1], '.r')
plt.plot(x_est_cat[0], x_est_cat[1], '.b')
else:
plt.plot(x_true_cat[0:, 0], x_true_cat[0:, 1], 'r')
plt.plot(x_est_cat[0:, 0], x_est_cat[0:, 1], 'b')
plt.plot(z[0], z[1],... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/cubature_kalman_filter/cubature_kalman_filter.py#L173-L182 | 2 | [
0
] | 10 | [
1,
2,
3,
5,
6,
7,
8,
9
] | 80 | false | 72.727273 | 10 | 2 | 20 | 0 | def plot_animation(i, x_true_cat, x_est_cat, z):
if i == 0:
plt.plot(x_true_cat[0], x_true_cat[1], '.r')
plt.plot(x_est_cat[0], x_est_cat[1], '.b')
else:
plt.plot(x_true_cat[0:, 0], x_true_cat[0:, 1], 'r')
plt.plot(x_est_cat[0:, 0], x_est_cat[0:, 1], 'b')
plt.plot(z[0], z[1],... | 531 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/cubature_kalman_filter/cubature_kalman_filter.py | plot_ellipse | (x_est, p_est) | 185 | 198 | def plot_ellipse(x_est, p_est):
phi = np.linspace(0, 2 * math.pi, 100)
p_ellipse = np.array(
[[p_est[0, 0], p_est[0, 1]], [p_est[1, 0], p_est[1, 1]]])
x0 = 3 * sqrtm(p_ellipse)
xy_1 = np.array([])
xy_2 = np.array([])
for i in range(100):
arr = np.array([[math.sin(phi[i])], [math.... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/cubature_kalman_filter/cubature_kalman_filter.py#L185-L198 | 2 | [
0
] | 7.142857 | [
1,
2,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13
] | 85.714286 | false | 72.727273 | 14 | 2 | 14.285714 | 0 | def plot_ellipse(x_est, p_est):
phi = np.linspace(0, 2 * math.pi, 100)
p_ellipse = np.array(
[[p_est[0, 0], p_est[0, 1]], [p_est[1, 0], p_est[1, 1]]])
x0 = 3 * sqrtm(p_ellipse)
xy_1 = np.array([])
xy_2 = np.array([])
for i in range(100):
arr = np.array([[math.sin(phi[i])], [math.... | 532 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/cubature_kalman_filter/cubature_kalman_filter.py | plot_final | (x_true_cat, x_est_cat, z_cat) | 201 | 214 | def plot_final(x_true_cat, x_est_cat, z_cat):
fig = plt.figure()
subplot = fig.add_subplot(111)
subplot.plot(x_true_cat[0:, 0], x_true_cat[0:, 1],
'r', label='True Position')
subplot.plot(x_est_cat[0:, 0], x_est_cat[0:, 1],
'b', label='Estimated Position')
subplot.p... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/cubature_kalman_filter/cubature_kalman_filter.py#L201-L214 | 2 | [
0
] | 7.142857 | [
1,
2,
3,
5,
7,
8,
9,
10,
11,
12,
13
] | 78.571429 | false | 72.727273 | 14 | 1 | 21.428571 | 0 | def plot_final(x_true_cat, x_est_cat, z_cat):
fig = plt.figure()
subplot = fig.add_subplot(111)
subplot.plot(x_true_cat[0:, 0], x_true_cat[0:, 1],
'r', label='True Position')
subplot.plot(x_est_cat[0:, 0], x_est_cat[0:, 1],
'b', label='Estimated Position')
subplot.p... | 533 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/cubature_kalman_filter/cubature_kalman_filter.py | main | () | 217 | 242 | def main():
print(__file__ + " start!!")
x_est = x_0
p_est = p_0
x_true = x_0
x_true_cat = np.array([x_0[0, 0], x_0[1, 0]])
x_est_cat = np.array([x_0[0, 0], x_0[1, 0]])
z_cat = np.array([x_0[0, 0], x_0[1, 0]])
for i in range(N):
x_true = f(x_true)
z = generate_measurement... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/cubature_kalman_filter/cubature_kalman_filter.py#L217-L242 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
14,
15,
17,
19,
21,
22,
23,
24,
25
] | 80.769231 | [
12,
16,
18,
20
] | 15.384615 | false | 72.727273 | 26 | 7 | 84.615385 | 0 | def main():
print(__file__ + " start!!")
x_est = x_0
p_est = p_0
x_true = x_0
x_true_cat = np.array([x_0[0, 0], x_0[1, 0]])
x_est_cat = np.array([x_0[0, 0], x_0[1, 0]])
z_cat = np.array([x_0[0, 0], x_0[1, 0]])
for i in range(N):
x_true = f(x_true)
z = generate_measurement... | 534 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/histogram_filter/histogram_filter.py | histogram_filter_localization | (grid_map, u, z, yaw) | return grid_map | 59 | 64 | def histogram_filter_localization(grid_map, u, z, yaw):
grid_map = motion_update(grid_map, u, yaw)
grid_map = observation_update(grid_map, z, RANGE_STD)
return grid_map | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/histogram_filter/histogram_filter.py#L59-L64 | 2 | [
0,
1,
2,
3,
4,
5
] | 100 | [] | 0 | true | 90.410959 | 6 | 1 | 100 | 0 | def histogram_filter_localization(grid_map, u, z, yaw):
grid_map = motion_update(grid_map, u, yaw)
grid_map = observation_update(grid_map, z, RANGE_STD)
return grid_map | 535 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/histogram_filter/histogram_filter.py | calc_gaussian_observation_pdf | (grid_map, z, iz, ix, iy, std) | return pdf | 67 | 76 | def calc_gaussian_observation_pdf(grid_map, z, iz, ix, iy, std):
# predicted range
x = ix * grid_map.xy_resolution + grid_map.min_x
y = iy * grid_map.xy_resolution + grid_map.min_y
d = math.hypot(x - z[iz, 1], y - z[iz, 2])
# likelihood
pdf = norm.pdf(d - z[iz, 0], 0.0, std)
return pdf | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/histogram_filter/histogram_filter.py#L67-L76 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 100 | [] | 0 | true | 90.410959 | 10 | 1 | 100 | 0 | def calc_gaussian_observation_pdf(grid_map, z, iz, ix, iy, std):
# predicted range
x = ix * grid_map.xy_resolution + grid_map.min_x
y = iy * grid_map.xy_resolution + grid_map.min_y
d = math.hypot(x - z[iz, 1], y - z[iz, 2])
# likelihood
pdf = norm.pdf(d - z[iz, 0], 0.0, std)
return pdf | 536 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/histogram_filter/histogram_filter.py | observation_update | (grid_map, z, std) | return grid_map | 79 | 88 | def observation_update(grid_map, z, std):
for iz in range(z.shape[0]):
for ix in range(grid_map.x_w):
for iy in range(grid_map.y_w):
grid_map.data[ix][iy] *= calc_gaussian_observation_pdf(
grid_map, z, iz, ix, iy, std)
grid_map = normalize_probability(gri... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/histogram_filter/histogram_filter.py#L79-L88 | 2 | [
0,
1,
2,
3,
4,
6,
7,
8,
9
] | 90 | [] | 0 | false | 90.410959 | 10 | 4 | 100 | 0 | def observation_update(grid_map, z, std):
for iz in range(z.shape[0]):
for ix in range(grid_map.x_w):
for iy in range(grid_map.y_w):
grid_map.data[ix][iy] *= calc_gaussian_observation_pdf(
grid_map, z, iz, ix, iy, std)
grid_map = normalize_probability(gri... | 537 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/histogram_filter/histogram_filter.py | calc_control_input | () | return u | 91 | 95 | def calc_control_input():
v = 1.0 # [m/s]
yaw_rate = 0.1 # [rad/s]
u = np.array([v, yaw_rate]).reshape(2, 1)
return u | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/histogram_filter/histogram_filter.py#L91-L95 | 2 | [
0,
1,
2,
3,
4
] | 100 | [] | 0 | true | 90.410959 | 5 | 1 | 100 | 0 | def calc_control_input():
v = 1.0 # [m/s]
yaw_rate = 0.1 # [rad/s]
u = np.array([v, yaw_rate]).reshape(2, 1)
return u | 538 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/histogram_filter/histogram_filter.py | motion_model | (x, u) | return x | 98 | 111 | def motion_model(x, u):
F = np.array([[1.0, 0, 0, 0],
[0, 1.0, 0, 0],
[0, 0, 1.0, 0],
[0, 0, 0, 0]])
B = np.array([[DT * math.cos(x[2, 0]), 0],
[DT * math.sin(x[2, 0]), 0],
[0.0, DT],
[1.0, 0.0]])
x... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/histogram_filter/histogram_filter.py#L98-L111 | 2 | [
0,
1,
5,
6,
10,
11,
12,
13
] | 57.142857 | [] | 0 | false | 90.410959 | 14 | 1 | 100 | 0 | def motion_model(x, u):
F = np.array([[1.0, 0, 0, 0],
[0, 1.0, 0, 0],
[0, 0, 1.0, 0],
[0, 0, 0, 0]])
B = np.array([[DT * math.cos(x[2, 0]), 0],
[DT * math.sin(x[2, 0]), 0],
[0.0, DT],
[1.0, 0.0]])
x... | 539 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/histogram_filter/histogram_filter.py | draw_heat_map | (data, mx, my) | 114 | 118 | def draw_heat_map(data, mx, my):
max_value = max([max(i_data) for i_data in data])
plt.grid(False)
plt.pcolor(mx, my, data, vmax=max_value, cmap=plt.cm.get_cmap("Blues"))
plt.axis("equal") | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/histogram_filter/histogram_filter.py#L114-L118 | 2 | [
0
] | 20 | [
1,
2,
3,
4
] | 80 | false | 90.410959 | 5 | 2 | 20 | 0 | def draw_heat_map(data, mx, my):
max_value = max([max(i_data) for i_data in data])
plt.grid(False)
plt.pcolor(mx, my, data, vmax=max_value, cmap=plt.cm.get_cmap("Blues"))
plt.axis("equal") | 540 | |||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/histogram_filter/histogram_filter.py | observation | (xTrue, u, RFID) | return xTrue, z, ud | 121 | 141 | def observation(xTrue, u, RFID):
xTrue = motion_model(xTrue, u)
z = np.zeros((0, 3))
for i in range(len(RFID[:, 0])):
dx = xTrue[0, 0] - RFID[i, 0]
dy = xTrue[1, 0] - RFID[i, 1]
d = math.hypot(dx, dy)
if d <= MAX_RANGE:
# add noise to range observation
... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/histogram_filter/histogram_filter.py#L121-L141 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20
] | 100 | [] | 0 | true | 90.410959 | 21 | 3 | 100 | 0 | def observation(xTrue, u, RFID):
xTrue = motion_model(xTrue, u)
z = np.zeros((0, 3))
for i in range(len(RFID[:, 0])):
dx = xTrue[0, 0] - RFID[i, 0]
dy = xTrue[1, 0] - RFID[i, 1]
d = math.hypot(dx, dy)
if d <= MAX_RANGE:
# add noise to range observation
... | 541 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/histogram_filter/histogram_filter.py | normalize_probability | (grid_map) | return grid_map | 144 | 151 | def normalize_probability(grid_map):
sump = sum([sum(i_data) for i_data in grid_map.data])
for ix in range(grid_map.x_w):
for iy in range(grid_map.y_w):
grid_map.data[ix][iy] /= sump
return grid_map | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/histogram_filter/histogram_filter.py#L144-L151 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7
] | 100 | [] | 0 | true | 90.410959 | 8 | 4 | 100 | 0 | def normalize_probability(grid_map):
sump = sum([sum(i_data) for i_data in grid_map.data])
for ix in range(grid_map.x_w):
for iy in range(grid_map.y_w):
grid_map.data[ix][iy] /= sump
return grid_map | 542 | ||
AtsushiSakai/PythonRobotics | 15ab19688b2f6c03ee91a853f1f8cc9def84d162 | Localization/histogram_filter/histogram_filter.py | init_grid_map | (xy_resolution, min_x, min_y, max_x, max_y) | return grid_map | 154 | 171 | def init_grid_map(xy_resolution, min_x, min_y, max_x, max_y):
grid_map = GridMap()
grid_map.xy_resolution = xy_resolution
grid_map.min_x = min_x
grid_map.min_y = min_y
grid_map.max_x = max_x
grid_map.max_y = max_y
grid_map.x_w = int(round((grid_map.max_x - grid_map.min_x)
... | https://github.com/AtsushiSakai/PythonRobotics/blob/15ab19688b2f6c03ee91a853f1f8cc9def84d162/project2/Localization/histogram_filter/histogram_filter.py#L154-L171 | 2 | [
0,
1,
2,
3,
4,
5,
6,
7,
8,
10,
12,
13,
15,
16,
17
] | 83.333333 | [] | 0 | false | 90.410959 | 18 | 3 | 100 | 0 | def init_grid_map(xy_resolution, min_x, min_y, max_x, max_y):
grid_map = GridMap()
grid_map.xy_resolution = xy_resolution
grid_map.min_x = min_x
grid_map.min_y = min_y
grid_map.max_x = max_x
grid_map.max_y = max_y
grid_map.x_w = int(round((grid_map.max_x - grid_map.min_x)
... | 543 |
Subsets and Splits
SQL Console for claudios/dypybench_functions
Retrieves specific code examples with exact coverage and line requirements, but only provides basic filtering without revealing meaningful patterns or relationships in the dataset.
SQL Console for claudios/dypybench_functions
Filters code examples with specific project ID, docstring requirements, full coverage, and minimum lines, providing basic filtering insight but limited analytical value.
Filtered Training Functions
Retrieves specific code examples with exact coverage and line requirements, providing basic filtering but limited analytical insight into the dataset.
High Coverage Train Functions
Retrieves specific code documentation examples that meet strict quality criteria, but only shows raw data without revealing patterns or insights about the dataset.
Highly Covered Functions
Filters for code examples with complete documentation and substantial implementation, but doesn't provide meaningful aggregations or insights about the dataset patterns.