scan-context/src/example/longterm_localization/NCLT/2012-01-15/1_DataMaker/helper/getPlaceIdx.m

24 lines
427 B
Mathematica
Raw Normal View History

2021-10-19 00:52:12 +00:00
function [ PlaceIdx ] = getPlaceIdx(curPose, PlaceIndexAndGridCenters)
%% load meta file
%% Main
curX = curPose(1);
curY = curPose(2);
PlaceCellCenters = PlaceIndexAndGridCenters(:, 2:3);
nPlaces = length(PlaceCellCenters);
Dists = zeros(nPlaces, 1);
for ii=1:nPlaces
Dist = norm(PlaceCellCenters(ii, :) - [curX, curY]);
Dists(ii) = Dist;
end
[NearestDist, NearestIdx] = min(Dists);
PlaceIdx = NearestIdx;
end