Skip to content

Commit ec2a275

Browse files
committed
release PoseOptimizationSLAM3D
1 parent 57e0dd2 commit ec2a275

File tree

5 files changed

+245
-205
lines changed

5 files changed

+245
-205
lines changed

Localization/histogram_filter/histogram_filter.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
NOISE_RANGE = 2.0 # [m] 1σ range noise parameter
3939
NOISE_SPEED = 0.5 # [m/s] 1σ speed noise parameter
4040

41-
4241
show_animation = True
4342

4443

@@ -66,11 +65,10 @@ def histogram_filter_localization(grid_map, u, z, yaw):
6665

6766

6867
def calc_gaussian_observation_pdf(gmap, z, iz, ix, iy, std):
69-
7068
# predicted range
7169
x = ix * gmap.xy_reso + gmap.minx
7270
y = iy * gmap.xy_reso + gmap.miny
73-
d = math.sqrt((x - z[iz, 1])**2 + (y - z[iz, 2])**2)
71+
d = math.sqrt((x - z[iz, 1]) ** 2 + (y - z[iz, 2]) ** 2)
7472

7573
# likelihood
7674
pdf = (1.0 - norm.cdf(abs(d - z[iz, 0]), 0.0, std))
@@ -79,7 +77,6 @@ def calc_gaussian_observation_pdf(gmap, z, iz, ix, iy, std):
7977

8078

8179
def observation_update(gmap, z, std):
82-
8380
for iz in range(z.shape[0]):
8481
for ix in range(gmap.xw):
8582
for iy in range(gmap.yw):
@@ -99,7 +96,6 @@ def calc_input():
9996

10097

10198
def motion_model(x, u):
102-
10399
F = np.array([[1.0, 0, 0, 0],
104100
[0, 1.0, 0, 0],
105101
[0, 0, 1.0, 0],
@@ -122,7 +118,6 @@ def draw_heat_map(data, mx, my):
122118

123119

124120
def observation(xTrue, u, RFID):
125-
126121
xTrue = motion_model(xTrue, u)
127122

128123
z = np.zeros((0, 3))
@@ -131,7 +126,7 @@ def observation(xTrue, u, RFID):
131126

132127
dx = xTrue[0, 0] - RFID[i, 0]
133128
dy = xTrue[1, 0] - RFID[i, 1]
134-
d = math.sqrt(dx**2 + dy**2)
129+
d = math.sqrt(dx ** 2 + dy ** 2)
135130
if d <= MAX_RANGE:
136131
# add noise to range observation
137132
dn = d + np.random.randn() * NOISE_RANGE
@@ -146,7 +141,6 @@ def observation(xTrue, u, RFID):
146141

147142

148143
def normalize_probability(gmap):
149-
150144
sump = sum([sum(igmap) for igmap in gmap.data])
151145

152146
for ix in range(gmap.xw):
@@ -214,11 +208,11 @@ def calc_grid_index(gmap):
214208
def main():
215209
print(__file__ + " start!!")
216210

217-
# RFID positions [x, y]
218-
RFID = np.array([[10.0, 0.0],
219-
[10.0, 10.0],
220-
[0.0, 15.0],
221-
[-5.0, 20.0]])
211+
# RF_ID positions [x, y]
212+
RF_ID = np.array([[10.0, 0.0],
213+
[10.0, 10.0],
214+
[0.0, 15.0],
215+
[-5.0, 20.0]])
222216

223217
time = 0.0
224218

@@ -233,18 +227,18 @@ def main():
233227
u = calc_input()
234228

235229
yaw = xTrue[2, 0] # Orientation is known
236-
xTrue, z, ud = observation(xTrue, u, RFID)
230+
xTrue, z, ud = observation(xTrue, u, RF_ID)
237231

238232
grid_map = histogram_filter_localization(grid_map, u, z, yaw)
239233

240234
if show_animation:
241235
plt.cla()
242236
draw_heat_map(grid_map.data, mx, my)
243237
plt.plot(xTrue[0, :], xTrue[1, :], "xr")
244-
plt.plot(RFID[:, 0], RFID[:, 1], ".k")
238+
plt.plot(RF_ID[:, 0], RF_ID[:, 1], ".k")
245239
for i in range(z.shape[0]):
246240
plt.plot([xTrue[0, :], z[i, 1]], [
247-
xTrue[1, :], z[i, 2]], "-k")
241+
xTrue[1, :], z[i, 2]], "-k")
248242
plt.title("Time[s]:" + str(time)[0: 4])
249243
plt.pause(0.1)
250244

README.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -609,19 +609,6 @@ This is a list: [Users comments](https://github.com/AtsushiSakai/PythonRobotics/
609609

610610
- [Alexis Paques](https://github.com/AlexisTM)
611611

612-
613-
614-
615-
616-
617-
618-
619-
620-
621-
622-
623-
624-
625-
612+
- [Ryohei Sasaki](https://github.com/rsasaki0109)
626613

627614

SLAM/PoseOptimizationSLAM3D/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ python pose_optimization_slam_3d.py
1515
~~~
1616

1717
## Reference
18-
[A Compact and Portable Implementation of Graph\-based SLAM](https://www.researchgate.net/publication/321287640_A_Compact_and_Portable_Implementation_of_Graph-based_SLAM)
19-
[GitHub \- furo\-org/p2o: Single header 2D/3D graph\-based SLAM library](https://github.com/furo-org/p2o)
20-
[GitHub \- AtsushiSakai/PythonRobotics
18+
- [A Compact and Portable Implementation of Graph\-based SLAM](https://www.researchgate.net/publication/321287640_A_Compact_and_Portable_Implementation_of_Graph-based_SLAM)
19+
20+
- [GitHub \- furo\-org/p2o: Single header 2D/3D graph\-based SLAM library](https://github.com/furo-org/p2o)
21+
22+
- [GitHub \- AtsushiSakai/PythonRobotics
2123
/SLAM/PoseOptimizationSLAM](https://github.com/AtsushiSakai/PythonRobotics/tree/master/SLAM/PoseOptimizationSLAM)
24+
25+
- [リー代数による3次元ポーズ調整\(Pose Adjustment\)\[PythonRobotics\]\[SLAM\] \- Qiita](https://qiita.com/saitosasaki/items/a0540cba994f08bf5e16#comment-3e6588e6b096cc2567d8)

SLAM/PoseOptimizationSLAM3D/data_downloader.py

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

9-
109
import subprocess
10+
11+
1112
def main():
1213
print("start!!")
1314

1415
cmd = "wget https://www.dropbox.com/s/zu23p8d522qccor/parking-garage.g2o?dl=0 -O parking-garage.g2o -nc"
1516
subprocess.call(cmd, shell=True)
17+
cmd = "wget http://www.furo.org/irie/datasets/torus3d_guess.g2o -nc"
18+
subprocess.call(cmd, shell=True)
19+
cmd = "wget http://www.furo.org/irie/datasets/sphere2200_guess.g2o -nc"
20+
subprocess.call(cmd, shell=True)
1621

1722
print("done!!")
1823

1924

2025
if __name__ == '__main__':
21-
main()
26+
main()

0 commit comments

Comments
 (0)