forked from ruslanmasinjila/ekf_simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
estimateRelativePose.m
46 lines (32 loc) · 1.2 KB
/
estimateRelativePose.m
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
%*************************************************************
% AUTHOR: Ruslan Masinjila
% Contact: [email protected]
%*************************************************************
function [Z] = estimateRelativePose(robotPose,landmarkPose,S)
% When S=[0 0]: Estimates the distance and angle of landmark w.r.t robot (Z_bar)
% Otherwise: Simulates the actual, noisy distance and angle of landmarkPose w.r.t robot (Z)
% INPUT:
% Robot Pose (mu=[x y theta])
% Landmark Position (landmarkPose=[x y])
% Sensor covariances (S=[sigma_rho sigma_phi])
% sigma_rho~Distance error
% sigma_phi~Angle error
% OUTPUT
% When S=[0 0]: Estimated relative Pose (Z_bar)
% Otherwise: Simulated, actual, noisy Pose (Z)
% BEGIN
sigma_rho=S(1);
sigma_phi=S(2);
dx=landmarkPose(1)-robotPose(1);
dy=landmarkPose(2)-robotPose(2);
rho=sqrt((dx)^2+(dy)^2);
phi=atan2(dy,dx);
rho=rho+sigma_rho*randn;
% Add noise to the measured angle
% Find difference between measured noisy angle and robot angle (theta)
phi=(phi-robotPose(3))+sigma_phi*randn;
% Normalize the results between [-pi,pi]
phi=normalizeAngle(phi);
Z=[rho;phi];
% END
end