function [viewerNoCheck, viewer, annoHandle] = helperCreatePoseViewers(initialState, multipathAngles)
%HELPERCREATEPOSEVIEWERS Create pose viewers for the
%   |SensorOutlierDetectionExample| example
%
%   This function is for internal use only. It may be removed in the
%   future.

%   Copyright 2019-2021 The MathWorks, Inc.   

viewerNoCheck = HelperPoseViewer( ...
    'XPositionLimits', [-15, 15], ...
    'YPositionLimits', [-15, 15], ...
    'ZPositionLimits', [-5, 5], ...
    'ReferenceFrame', 'ENU');
viewerNoCheck.AppWindow.Name = 'Pose Estimation (No Outlier Detection)';
ax = viewerNoCheck.AppWindow.Children;
hold(ax, 'on')
initialEulAngs = eulerd(quaternion(initialState(1:4).'), 'ZYX', 'frame');
initialYaw = initialEulAngs(1);
r = norm(initialState(8:10));
x = [0, 1.5*r * cosd(-initialYaw+(multipathAngles(1):0.01:multipathAngles(2))), 0];
y = [0, 1.5*r * sind(-initialYaw+(multipathAngles(1):0.01:multipathAngles(2))), 0];
posAxIdx = contains({vertcat(ax.Title).String}, 'position', 'IgnoreCase', true);
posAx = ax(posAxIdx);
fill(posAx, x, y, [1 0 0], 'FaceAlpha', 0.2);

viewer = HelperPoseViewer( ...
    'XPositionLimits', [-15, 15], ...
    'YPositionLimits', [-15, 15], ...
    'ZPositionLimits', [-5, 5], ...
    'ReferenceFrame', 'ENU');
viewer.AppWindow.Position = [0.501 0.2567 0.4917 0.4225];
viewer.AppWindow.Name = 'Pose Estimation (With Outlier Detection)';
ax = viewer.AppWindow.Children;
hold(ax, 'on')
initialEulAngs = eulerd(quaternion(initialState(1:4).'), 'ZYX', 'frame');
initialYaw = initialEulAngs(1);
r = norm(initialState(8:10));
x = [0, 1.5*r * cosd(-initialYaw+(multipathAngles(1):0.01:multipathAngles(2))), 0];
y = [0, 1.5*r * sind(-initialYaw+(multipathAngles(1):0.01:multipathAngles(2))), 0];
posAxIdx = contains({vertcat(ax.Title).String}, 'position', 'IgnoreCase', true);
posAx = ax(posAxIdx);
fill(posAx, x, y, [1 0 0], 'FaceAlpha', 0.2);

dim = [0.1 0.4 0.3 0.3];
str = 'Outlier status: none';
annoHandle = annotation(posAx.Parent, 'textbox', dim, 'String', str, 'FitboxToText', 'on');
end