30 , m_pCellPassCnt(
Grid<
kt_int32u>::CreateGrid(0, 0, resolution))
31 , m_pCellHitsCnt(
Grid<
kt_int32u>::CreateGrid(0, 0, resolution))
32 , m_pCellUpdater(NULL)
38 throw Exception(
"Resolution cannot be 0");
48 OccupancyGrid::~OccupancyGrid()
62 return pOccupancyGrid;
69 throw Exception(
"OccupancyGrid::CreateFromScans - Not supported in Windows. Please Use CreateFromScans(const LocalizedLaserScanList& rScans, kt_double resolution).");
86 if (rScans.
Size() == 0)
97 return pOccupancyGrid;
112 if (pLocalizedLaserScan != NULL)
162 if (range >= maxRange || range < minRange)
167 else if (range >= rangeThreshold)
170 kt_double ratio = rangeThreshold / range;
173 point.
SetX(scanPosition.
GetX() + ratio * dx);
174 point.
SetY(scanPosition.
GetY() + ratio * dy);
177 if (
RayTrace(scanPosition, point, isEndPointValid, doUpdate))
197 kt_double xStop = x + maxRange * cosTheta;
198 kt_double xSteps = 1 + fabs(xStop - x) * scale;
200 kt_double yStop = y + maxRange * sinTheta;
201 kt_double ySteps = 1 + fabs(yStop - y) * scale;
215 distance = (i + 1) * delta;
223 return (distance < maxRange) ? distance : maxRange;
247 pCellPassCntPtr[index]++;
248 pCellHitCntPtr[index]++;
252 (*m_pCellUpdater)(index);
264 kt_double hitRatio =
static_cast<kt_double>(cellHitCnt) / static_cast<kt_double>(cellPassCnt);
290 for (
kt_int32u i = 0; i < nBytes; i++, pDataPtr++, pCellPassCntPtr++, pCellHitCntPtr++)
292 UpdateCell(pDataPtr, *pCellPassCntPtr, *pCellHitCntPtr);
310 kt_int8u* pDataPtr = m_pOccupancyGrid->GetDataPointer();
311 kt_int32u* pCellPassCntPtr = m_pOccupancyGrid->m_pCellPassCnt->GetDataPointer();
312 kt_int32u* pCellHitCntPtr = m_pOccupancyGrid->m_pCellHitsCnt->GetDataPointer();
314 m_pOccupancyGrid->UpdateCell(&pDataPtr[index], pCellPassCntPtr[index], pCellHitCntPtr[index]);
kt_int32s GetHeight() const
OccupancyGrid * Clone() const
virtual kt_size_t Size() const
void SetSize(const Size2< kt_int32s > &rSize)
kt_double Distance(const Vector2 &rOther) const
kt_int32s GetDataSize() const
CellUpdater * m_pCellUpdater
const Size2< kt_int32s > GetSize() const
kt_double GetHeading() const
kt_bool IsValidGridIndex(const Vector2i &rGrid) const
const T & Maximum(const T &value1, const T &value2)
const BoundingBox2 & GetBoundingBox() const
SmartPointer< Parameter< kt_double > > m_pOccupancyThreshold
OccupancyGrid(kt_int32s width, kt_int32s height, const Vector2d &rOffset, kt_double resolution)
virtual void Add(const T &rValue)
kt_int32s GetWidth() const
TFSIMD_FORCE_INLINE tfScalar distance(const Vector3 &v) const
kt_double Round(kt_double value)
#define const_forEach(listtype, list)
static OccupancyGrid * CreateFromMapper(OpenMapper *pMapper, kt_double resolution)
TFSIMD_FORCE_INLINE const tfScalar & y() const
Pose2 GetSensorPose() const
SmartPointer< Grid< kt_int32u > > m_pCellPassCnt
SmartPointer< Parameter< kt_int32u > > m_pMinPassThrough
void SetOffset(const Vector2d &rOffset)
const LocalizedLaserScanList GetAllProcessedScans() const
void SetScale(kt_double scale)
kt_bool IsFree(const Vector2i &rGridIndex) const
Size2< kt_double > GetSize() const
virtual void operator()(kt_int32u index)
virtual void Resize(kt_int32s width, kt_int32s height)
virtual void Resize(kt_int32s width, kt_int32s height)
const kt_double KT_TOLERANCE
kt_int8u * GetDataPointer()
TFSIMD_FORCE_INLINE const tfScalar & x() const
const Vector2d & GetMinimum() const
SmartPointer< Grid< kt_int32u > > m_pCellHitsCnt
const Vector2d & GetPosition() const
kt_bool RayTrace(const Vector2d &rWorldFrom, const Vector2d &rWorldTo, kt_bool isEndPointValid, kt_bool doUpdate=false)
void UpdateCell(kt_int8u *pCell, kt_int32u cellPassCnt, kt_int32u cellHitCnt)
Vector2< kt_double > Vector2d
static OccupancyGrid * CreateFromScans(const LocalizedLaserScanList &rScans, kt_double resolution)
CoordinateConverter * GetCoordinateConverter() const
kt_double RayCast(const Pose2 &rPose2, kt_double maxRange) const
kt_bool DoubleEqual(kt_double a, kt_double b)
Vector2i WorldToGrid(const Vector2d &rWorld, kt_bool flipY=false) const
static void ComputeDimensions(const LocalizedLaserScanList &rScans, kt_double resolution, kt_int32s &rWidth, kt_int32s &rHeight, Vector2d &rOffset)
kt_double GetMinimumRange() const
kt_double GetScale() const
T * GetDataPointer(const Vector2i &rGrid)
const T GetHeight() const
kt_double GetRangeThreshold() const
void Add(const Vector2d &rPoint)
kt_bool AddScan(LocalizedLaserScan *pScan, kt_bool doUpdate=false)
#define karto_const_forEach(listtype, list)
LaserRangeFinder * GetLaserRangeFinder() const
kt_double GetMaximumRange() const
const Vector2dList & GetPointReadings(kt_bool wantFiltered=false) const