47 #ifndef _MIRA_COLLISIONTEST_H_ 48 #define _MIRA_COLLISIONTEST_H_ 50 #include <boost/optional.hpp> 61 namespace mira {
namespace model {
94 mSegments(other.mSegments),
95 mShapeLUTBB(other.mShapeLUTBB),
96 mShapeDimension(other.mShapeDimension),
97 mObstacleThreshold(other.mObstacleThreshold),
98 mSegmentStep(other.mSegmentStep)
100 mShapeLUT.reserve(other.
mShapeLUT.size());
102 std::back_inserter(mShapeLUT),
106 template<
typename Reflector>
109 r.member(
"CellSize", mCellSize,
110 "Resolution of the collision map [m]", 0.02f);
111 r.member(
"Segments", mSegments,
112 "Size of the collision LUT (360 deg is divided in #segments)",
114 r.property(
"ObstacleThreshold", mObstacleThreshold,
115 "Occupancy grid values above this threshold are counted as obstacles",
126 mShapeLUT.reserve(other.
mShapeLUT.size());
128 std::back_inserter(mShapeLUT),
147 bool testCollision(
const Img8U1& map,
const Point2i& p,
float phi)
const;
161 float distanceToObstacle(
const Img32F1& distanceMap,
const Point2i& p,
float phi,
162 Point2i* oClosestModelPoint = NULL)
const;
178 static boost::optional<Point2i> obstaclePosition(
180 const Point2i& closestModelPoint,
181 std::map<int, Point2i>* ioCache = NULL);
193 void distanceTransform(
const Img8U1& map,
Img32F1& oDistanceMap)
const;
204 void distanceTransform(
const Img8U1& map,
Img32F1& oDistanceMap,
220 void distanceTransformAndClearShape(
const Img8U1& map,
Img32F1& oDistanceMap,
221 const Point2i& p,
float phi)
const;
234 void distanceTransformAndClearShape(
const Img8U1& map,
Img32F1& oDistanceMap,
236 const Point2i& p,
float phi)
const;
242 const Img8U1& getShape(
float phi)
const;
247 const Rect2i& getShapeBB(
float phi)
const;
255 void initialize(
const Footprint& footprint);
264 void initialize(
const Footprint& footprint,
float cellSize);
278 void initialize(
const Footprint& footprint,
float cellSize, uint32 segments);
289 uint8 freeValue = 0)
const;
306 float decayRate,
float neutral = 127.f,
307 bool decayObstacles =
true,
bool decayFreespace =
false,
308 bool invertShape =
false)
const;
313 int calculateSegment(
float phi)
const;
314 std::pair<Point2i, Rect2i> calculateOffsetAndOverlap(
const Size2i& map,
CollisionTest & operator=(const CollisionTest &other)
Definition: CollisionTest.h:119
uint32 mSegments
Size of the collision LUT (360° is divided in #segments)
Definition: CollisionTest.h:321
#define MIRA_INITIALIZE_THIS
std::vector< Img8U1 > mShapeLUT
Look up table for faster collision checking.
Definition: CollisionTest.h:323
Class that provides several methods for running collision tests of a rigid models footprint with imag...
Definition: CollisionTest.h:82
CollisionTest(float cellSize=0.02f, uint32 segments=360)
Definition: CollisionTest.h:86
float mCellSize
Resolution of the collision map [m].
Definition: CollisionTest.h:320
PropertyHint limits(const T &min, const T &max)
CollisionTest(const CollisionTest &other)
Definition: CollisionTest.h:93
RigidModel export macro declaration.
int mObstacleThreshold
Occupancy grid values above this threshold are counted as obstacles.
Definition: CollisionTest.h:330
std::vector< Rect2i > mShapeLUTBB
Bounding box for each precalculated shape.
Definition: CollisionTest.h:324
#define MIRA_RIGID_MODEL_EXPORT
Definition: RigidModelExports.h:61
float mSegmentStep
Denotes a step in rad between each LUT entry (2pi / mSegments)
Definition: CollisionTest.h:333
PropertyHint step(const T &step)
void reflect(Reflector &r)
Definition: CollisionTest.h:107
Img< T, TChannels > clone() const
int mShapeDimension
Each LUT entry has this dimension (e.g. is a dim x dim image)
Definition: CollisionTest.h:327