function options = WP_analyzer(intentions)
%

% codes for options
AVOID_OBSTACLE = 1;
FIND_FLOOR = 2;
FIND_GRAVITY = 3;
SET_POSE = 4;
RESET_POSE = 5;
EXTEND_WP = 11;
COMBINE_WP = 12;
TERMINATE = 13;

OBSTACLE = 6;  % belief type value

MAX_POSE_UNCERTAINTY = 1;

options = intentions;

% Avoid obstacles
indexes = WP_beliefs(5,0,'type',OBSTACLE);
if ~isempty(indexes)&isempty(find(options==AVOID_OBSTACLE))
    options = [options,AVOID_OBSTACLE];
    return
end

% Find Floor
floor_uncertainty = WP_beliefs(1,9,'uncertainty',0);
if floor_uncertainty>MAX_POSE_UNCERTAINTY...
        &isempty(find(options==FIND_FLOOR))
    options = [options,FIND_FLOOR];
    return
end

% Get gravity vector
gravity_uncertainty = WP_beliefs(1,2,'uncertainty',0);
if max(max(gravity_uncertainty))>MAX_POSE_UNCERTAINTY...
        &isempty(find(options==FIND_GRAVITY))
    options = [options,FIND_GRAVITY];
    return
end

% Terminate
if isempty(options)&isempty(find(options==TERMINATE))
    options = [options,TERMINATE];
    WP_beliefs(2,7,'info',1);
end
return

% Get worldframe (initial)
if max(max(WP_beliefs(1,1,'uncertainty',0)))>MAX_POSE_UNCERTAINTY...
        & isempty(find(intentions==SET_POSE))...  % not already on list
        & WP_beliefs(1,8,'info',0)==0  % never found world frame
    options = [options,SET_POSE];
end

% Get worldframe (refind)
if max(max(WP_beliefs(1,1,'uncertainty',0)))>MAX_POSE_UNCERTAINTY...
        & isempty(find(intentions==RESET_POSE))...  % not already on list
        & WP_beliefs(1,8,'info',0)==1  % already found world frame once
    options = [options,RESET_POSE];
end

% Delete find worldframe intention (initial)
if max(max(WP_beliefs(1,1,'uncertainty',0)))<MAX_POSE_UNCERTAINTY...
        & ~isempty(find(intentions==SET_POSE))
    index = find(options==SET_POSE);
    options(index) = options(end);
    options = options(1:end-1);
end

% Delete find worldframe intention (refind)
if max(max(WP_beliefs(1,1,'uncertainty',0)))<MAX_POSE_UNCERTAINTY...
        & ~isempty(find(intentions==RESET_POSE))
    index = find(options==RESET_POSE);
    options(index) = options(end);
    options = options(1:end-1);
end

% Set Extend WP
if WP_open_WP>0
    options = [options,EXTEND_WP];
    return
end

% Set combine Wps
if WP_beliefs(1,10,'info',0)==0
    options = [options,COMBINE_WP];
    return
end

% Terminate
if isempty(find(options==TERMINATE))
    options = [options,TERMINATE];
    return
end
