Skip to content

Commit

Permalink
divide by valid point count only in ScanMatcher::GetResponse
Browse files Browse the repository at this point in the history
Otherwise the returned response value is too low for loop closure
when used with a half-blocked lidar.
  • Loading branch information
981213 committed Apr 5, 2023
1 parent 695125b commit ab57ae9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/karto_sdk/src/Mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,7 @@ kt_double ScanMatcher::GetResponse(kt_int32u angleIndex, kt_int32s gridPositionI

// get number of points in offset list
kt_int32u nPoints = pOffsets->GetSize();
kt_int32u nValidPoints = 0;
if (nPoints == 0) {
return response;
}
Expand All @@ -1198,10 +1199,11 @@ kt_double ScanMatcher::GetResponse(kt_int32u angleIndex, kt_int32s gridPositionI

// uses index offsets to efficiently find location of point in the grid
response += pByte[pAngleIndexPointer[i]];
nValidPoints++;
}

// normalize response
response /= (nPoints * GridStates_Occupied);
response /= (nValidPoints * GridStates_Occupied);
assert(fabs(response) <= 1.0);

return response;
Expand Down

0 comments on commit ab57ae9

Please sign in to comment.