38 #include <boost/math/special_functions/fpclassify.hpp>
60 this->conditionVariables.setZero(1);
66 this->conditionVariables(0)++;
71 if (this->conditionVariables(0) >= this->limits(0))
97 this->
limitNames.push_back(
"Min differential rotation err");
98 this->
limitNames.push_back(
"Min differential translation err");
105 this->conditionVariables.setZero(2);
108 translations.clear();
110 if (parameters.rows() == 4)
112 rotations.push_back(
Quaternion(Eigen::Matrix<T,3,3>(parameters.topLeftCorner(3,3))));
117 Eigen::Matrix<T,3,3> m(Matrix::Identity(3,3));
118 m.topLeftCorner(2,2) = parameters.topLeftCorner(2,2);
122 const unsigned int nbRows = parameters.rows()-1;
123 translations.push_back(parameters.topRightCorner(nbRows,1));
131 rotations.push_back(
Quaternion(Eigen::Matrix<T,3,3>(parameters.topLeftCorner(3,3))));
132 const unsigned int nbRows = parameters.rows()-1;
133 translations.push_back(parameters.topRightCorner(nbRows,1));
135 this->conditionVariables.setZero(2);
136 if(rotations.size() > smoothLength)
138 for(
size_t i = rotations.size()-1; i >= rotations.size()-smoothLength; i--)
141 this->conditionVariables(0) +=
anyabs(rotations[i].angularDistance(rotations[i-1]));
142 this->conditionVariables(1) +=
anyabs((translations[i] - translations[i-1]).norm());
145 this->conditionVariables /= smoothLength;
147 if(this->conditionVariables(0) < this->limits(0) && this->conditionVariables(1) < this->limits(1))
154 if (boost::math::isnan(this->conditionVariables(0)))
155 throw ConvergenceError(
"abs rotation norm not a number");
156 if (boost::math::isnan(this->conditionVariables(1)))
157 throw ConvergenceError(
"abs translation norm not a number");
176 this->
limitNames.push_back(
"Max rotation angle");
177 this->
limitNames.push_back(
"Max translation norm");
185 this->conditionVariables.setZero(2);
186 if (parameters.rows() == 4)
187 initialRotation3D =
Quaternion(Eigen::Matrix<T,3,3>(parameters.topLeftCorner(3,3)));
188 else if (parameters.rows() == 3)
189 initialRotation2D = acos(parameters(0,0));
191 throw runtime_error(
"BoundTransformationChecker only works in 2D or 3D");
193 const unsigned int nbRows = parameters.rows()-1;
194 initialTranslation = parameters.topRightCorner(nbRows,1);
202 if (parameters.rows() == 4)
204 const Quaternion currentRotation =
Quaternion(Eigen::Matrix<T,3,3>(parameters.topLeftCorner(3,3)));
205 this->conditionVariables(0) = currentRotation.angularDistance(initialRotation3D);
207 else if (parameters.rows() == 3)
209 const T currentRotation(acos(parameters(0,0)));
210 this->conditionVariables(0) =
normalizeAngle(currentRotation - initialRotation2D);
214 const unsigned int nbRows = parameters.rows()-1;
215 const Vector currentTranslation = parameters.topRightCorner(nbRows,1);
216 this->conditionVariables(1) = (currentTranslation - initialTranslation).norm();
217 if (this->conditionVariables(0) > this->limits(0) || this->conditionVariables(1) > this->limits(1))
220 oss <<
"limit out of bounds: ";
221 oss <<
"rot: " << this->conditionVariables(0) <<
"/" << this->limits(0) <<
" ";
222 oss <<
"tr: " << this->conditionVariables(1) <<
"/" << this->limits(1);
223 throw ConvergenceError(oss.str());