21 #include <boost/math/constants/constants.hpp> 28 Heuristic(
"DirectionRelationHeuristic"), mStaticBreakRatio(pStaticBreakRatio), mTogetherRatio(pTogetherRatio), mMaxAngleDeviation(pMaxAngleDeviation) {}
33 typedef Eigen::Vector3d Vector;
36 for (
TrackPtr& first : tracks->tracks) {
38 double currentClosestDistance;
39 int currentBestBreaks = 1;
40 int currentBestCommonPositions = 1;
42 for (
TrackPtr& second : tracks->tracks) {
43 if (first == second) {
65 int commonPositions = 0;
66 double averageDistance = 0;
68 for (
size_t i = 0; i < first->objects.size(); i++) {
69 ObjectPtr firstObject = first->objects[i];
70 ObjectPtr secondObject = second->objects[i];
71 if (!firstObject || !secondObject) {
76 secondObject->pose->point);
79 if (commonPositions < (
double) first->objects.size() *
mTogetherRatio) {
83 averageDistance /= (double) commonPositions;
86 Vector directionVector;
89 for (
size_t i = 0; i < first->objects.size(); i++) {
90 ObjectPtr firstObject = first->objects[i];
91 ObjectPtr secondObject = second->objects[i];
92 if (!firstObject || !secondObject) {
108 directionVector = currentDirection;
114 (!currentBest || (currentClosestDistance > averageDistance))
116 currentBest = second;
117 currentClosestDistance = averageDistance;
118 currentBestBreaks = staticBreaks;
119 currentBestCommonPositions = commonPositions;
124 double conf = 1 - (double) currentBestBreaks / (
double) currentBestCommonPositions;
127 || (conf == this->
confidence && bestDistance > currentClosestDistance))) {
129 cluster.push_back(first);
130 cluster.push_back(currentBest);
133 bestDistance = currentClosestDistance;
DirectionRelationHeuristic(const double pStaticBreakRatio, const double pTogetherRatio, const double pMaxAngleDeviation)
double mMaxAngleDeviation
static double getAngleBetweenAxes(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
static double getDistanceBetweenPoints(const PointPtr &p1, const PointPtr &p2)
static Eigen::Vector3d getDirectionVector(const PosePtr &first, const PosePtr &second)
virtual void applyHeuristic(const TracksPtr &tracks)
boost::shared_ptr< Tracks > TracksPtr
boost::shared_ptr< Track > TrackPtr
this namespace contains all generally usable classes.
boost::shared_ptr< Object > ObjectPtr