forked from udacity/P3_Implement_SLAM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
69 lines (57 loc) · 1.48 KB
/
main.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from helpers import display_world, make_data
from robot_class import robot
import numpy as np
import matplotlib.pyplot as plt
import random
world_size = 100.0 # size of world (square)
measurement_range = 50.0 # range at which we can sense landmarks
motion_noise = 2.0 # noise in robot motion
measurement_noise = 2.0 # noise in the measurements
num_landmarks = 5
N = 20 # time steps
distance = 20.0 # distance robot moves each step
data = make_data(
N,
num_landmarks,
world_size,
measurement_range,
motion_noise,
measurement_noise,
distance
)
for index in enumerate(data):
print(data[step][0])
print(data[step][1])
# instantiate a robot, r
r = robot(world_size, measurement_range, motion_noise, measurement_noise)
# print out the location of r
print(r)
# define figure size
plt.rcParams["figure.figsize"] = (5,5)
# create any number of landmarks
r.make_landmarks(num_landmarks)
print('Landmark locations [x,y]: ', r.landmarks)
measurements = r.sense()
print(measurements)
# display the world including these landmarks
#display_world(int(world_size), [r.x, r.y], r.landmarks)
# move robo
r.move(1, 2)
print(r)
measurements = r.sense()
print(measurements)
#data.append([measurements, [dx, dy]])
print(data)
#display_world(int(world_size), [r.x, r.y], r.landmarks)
def slam():
mu = matrix([
[Px0],
[Py0],
[Px1],
[Py1],
[Lx0],
[Ly0],
[Lx1],
[Ly1]
])
return mu