47 #ifndef _MIRA_COLLISIONTEST_H_ 48 #define _MIRA_COLLISIONTEST_H_ 50 #include <boost/optional.hpp> 60 namespace mira {
namespace model {
105 template<
typename Reflector>
109 "Resolution of the collision map [m]", 0.02f);
111 "Size of the collision LUT (360 deg is divided in #segments)",
114 "Occupancy grid values above this threshold are counted as obstacles",
161 Point2i* oClosestModelPoint = NULL)
const;
179 const Point2i& closestModelPoint,
180 std::map<int, Point2i>* ioCache = NULL);
220 const Point2i& p,
float phi)
const;
235 const Point2i& p,
float phi)
const;
288 uint8 freeValue = 0)
const;
305 float decayRate,
float neutral = 127.f,
306 bool decayObstacles =
true,
bool decayFreespace =
false,
307 bool invertShape =
false)
const;
CollisionTest & operator=(const CollisionTest &other)
Definition: CollisionTest.h:118
float distanceToObstacle(const Img32F1 &distanceMap, const Point2i &p, float phi, Point2i *oClosestModelPoint=NULL) const
Calculates the distance of the enclosed footprint to the nearest obstacle in the given map...
uint32 mSegments
Size of the collision LUT (360° is divided in #segments)
Definition: CollisionTest.h:320
#define MIRA_INITIALIZE_THIS
std::pair< Point2i, Rect2i > calculateOffsetAndOverlap(const Size2i &map, const Point2i &p, float phi) const
void distanceTransform(const Img8U1 &map, Img32F1 &oDistanceMap) const
Calculates a distance transformation on the given map.
static boost::optional< Point2i > obstaclePosition(const Img32F1 &distanceMap, const Img< int32 > &labelMap, const Point2i &closestModelPoint, std::map< int, Point2i > *ioCache=NULL)
Determine the position of the obstacle.
std::vector< Img8U1 > mShapeLUT
Look up table for faster collision checking.
Definition: CollisionTest.h:322
Class that provides several methods for running collision tests of a rigid models footprint with imag...
Definition: CollisionTest.h:81
CollisionTest(float cellSize=0.02f, uint32 segments=360)
Definition: CollisionTest.h:85
int calculateSegment(float phi) const
float mCellSize
Resolution of the collision map [m].
Definition: CollisionTest.h:319
PropertyHint limits(const T &min, const T &max)
void initialize(const Footprint &footprint)
Initialize collision testing with the given footprint.
CollisionTest(const CollisionTest &other)
Definition: CollisionTest.h:92
int mObstacleThreshold
Occupancy grid values above this threshold are counted as obstacles.
Definition: CollisionTest.h:329
void clearShape(Img8U1 &map, const Point2i &p, float phi, uint8 freeValue=0) const
Clears the map region that is covered by the rotated footprint at position p in the given map...
void distanceTransformAndClearShape(const Img8U1 &map, Img32F1 &oDistanceMap, const Point2i &p, float phi) const
Calculates a distance transformation on the given map and clears the rotated footprint at position p ...
const Rect2i & getShapeBB(float phi) const
Return the bounding box for the shape for phi.
std::vector< Rect2i > mShapeLUTBB
Bounding box for each precalculated shape.
Definition: CollisionTest.h:323
float mSegmentStep
Denotes a step in rad between each LUT entry (2pi / mSegments)
Definition: CollisionTest.h:332
PropertyHint step(const T &step)
void reflect(Reflector &r)
Definition: CollisionTest.h:106
Img< T, TChannels > clone() const
const Img8U1 & getShape(float phi) const
Return the entry of the LUT that is closest to the representation of the enclosed footprint rotated a...
int mShapeDimension
Each LUT entry has this dimension (e.g. is a dim x dim image)
Definition: CollisionTest.h:326
void decayShape(Img8U1 &map, const Point2i &p, float phi, float decayRate, float neutral=127.f, bool decayObstacles=true, bool decayFreespace=false, bool invertShape=false) const
Decays the map region that is covered by the rotated footprint at position p in the given map...
bool testCollision(const Img8U1 &map, const Point2i &p, float phi) const
Tests collision of the enclosed footprint with a given map for rotation phi.