Professional Documents
Culture Documents
October 9, 2020
1 Sheet 4
Kelompok 3 :
1. Muhammad Farhan Fathurrahman (23219344)
2. Adityas Regita P. (23220020)
3. Satrya Budi Pratama (23219305)
Link Question : http://ais.informatik.uni-freiburg.de/teaching/ss20/robotics/exercises/sheet04.pdf
Return :
- result : the generated samples
'''
1
# addition
result = mu + x
return result
Return :
- result : the generated samples
'''
# Rejection loop
while True:
x = np.random.uniform(mu - interval, mu + interval, 1)[0]
y = np.random.uniform(0 , max_density,1 )
return x
2
Return :
- result : the generated samples
'''
result = mu + sigma * x
return result
# generate sample
for i in range(n_samples):
# debug
print("%30s : %.3f us" % (sample_function.__name__, time_per_sample))
3
[6]: def evaluate_sampling_distribution(mu, sigma, n_samples, sample_function):
'''
Evaluate the generated samples for each sampling method
Params :
- mu : mean of the normal distribution
- sigma : standart deviation of the normal distribution
- n_samples : number of samples generated
- sample_function : name of the function
Return :
-
'''
n_bins = 100
samples = []
# generate samples
for i in range(n_samples):
# debug
print("Name : {} - Mean : {} - Standart Deviation : {}".
,→format(sample_function.__name__, np.mean(samples), np.std(samples)))
# plotting
plt.figure()
# make histogram
count, bins, ignored = plt.hist(samples, n_bins, density=True)
4
sample_normal_dist_boxmuller,
np.random.normal
]
sample_normal_dist_12 : 11.699 us
sample_normal_dist_rejection : 2803.144 us
sample_normal_dist_boxmuller : 9.977 us
normal : 2.028 us
5
6
7
1.2 Exercise 2: Odometry-based Motion Model
Implement simple odometry-based motion model
[9]: def sample_odometry_motion_model(x, u, a):
'''
Implement the odometry-based motion model, on point(a).
Page 27 on Probabilistic Motion Models.
Params:
- x : pose of the robot before moving [ x, y, theta]
- u : odometry reading obtained from the robot [delta rotation1, delta␣
,→rotation2, delta translation]
Return :
- result : predict new pose of the robot after moving
'''
return new_pose
x = [2, 4, 0]
u = [np.pi / 2, 0.0, 1.0]
alpha = [0.1, 0.1, 0.01, 0.01]
iteration = 5000
8
predicted_pose = []
# looping for 5000
for i in range(iteration):
# append to list
predicted_pose.append(new_pose)
9
1.3 Exercise 3 : Velocity-Based Motion Model
10
11
12
13