21 #include <boost/math/constants/constants.hpp> 27 Heuristic(
"DirectionOrientationRelationHeuristic"), mStaticBreakRatio(pStaticBreakRatio), mTogetherRatio(pTogetherRatio), mMaxAngleDeviation(pMaxAngleDeviation) {}
32 typedef Eigen::Vector3d Vector;
35 for (
TrackPtr& first : tracks->tracks) {
37 double currentClosestDistance;
38 int currentBestBreaks = 1;
39 int currentBestCommonPositions = 1;
41 for (
TrackPtr& second : tracks->tracks) {
42 if (first == second) {
64 int commonPositions = 0;
65 double averageDistance = 0;
67 for (
size_t i = 0; i < first->objects.size(); i++) {
68 ObjectPtr firstObject = first->objects[i];
69 ObjectPtr secondObject = second->objects[i];
70 if (!firstObject || !secondObject) {
75 secondObject->pose->point);
78 if (commonPositions < (
double) first->objects.size() *
mTogetherRatio) {
82 averageDistance /= (double) commonPositions;
85 Vector directionVector;
86 double orientationDifference;
89 for (
size_t i = 0; i < first->objects.size(); i++)
91 ObjectPtr firstObject = first->objects[i];
92 ObjectPtr secondObject = second->objects[i];
93 if (!firstObject || !secondObject) {
100 firstObject->pose->quat, secondObject->pose->quat
108 secondObject->pose->quat);
112 double orientationDeviation = fabs(orientationDifference - currentOrientationDiff);
117 directionVector = currentDirection;
118 orientationDifference = currentOrientationDiff;
124 (!currentBest || (currentClosestDistance > averageDistance))
126 currentBest = second;
127 currentClosestDistance = averageDistance;
128 currentBestBreaks = staticBreaks;
129 currentBestCommonPositions = commonPositions;
134 double conf = 1 - (double) currentBestBreaks / (
double) currentBestCommonPositions;
137 || (conf == this->
confidence && bestDistance > currentClosestDistance))) {
139 cluster.push_back(first);
140 cluster.push_back(currentBest);
143 bestDistance = currentClosestDistance;
static double getAngleBetweenQuats(const QuaternionPtr &q1, const QuaternionPtr &q2)
static double getAngleBetweenAxes(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
double mMaxAngleDeviation
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.
DirectionOrientationRelationHeuristic(const double pStaticBreakRatio, const double pTogetherRatio, const double pMaxAngleDeviation)
boost::shared_ptr< Object > ObjectPtr