Skip to content
Snippets Groups Projects
Commit 60fd7d8b authored by Joan Vallvé Navarro's avatar Joan Vallvé Navarro
Browse files

efficiency issues

parent d114f33b
No related branches found
No related tags found
1 merge request!419Resolve "Processor motion model"
Pipeline #6733 failed
...@@ -17,7 +17,7 @@ WOLF_PTR_TYPEDEFS(FactorVelocityDirection3d); ...@@ -17,7 +17,7 @@ WOLF_PTR_TYPEDEFS(FactorVelocityDirection3d);
class FactorVelocityDirection3d: public FactorAutodiff<FactorVelocityDirection3d,1,3,4> class FactorVelocityDirection3d: public FactorAutodiff<FactorVelocityDirection3d,1,3,4>
{ {
protected: protected:
double min_vel_norm_; double min_vel_sq_norm_; // stored in squared norm for efficiency
public: public:
FactorVelocityDirection3d(FeatureBasePtr _ftr_ptr, FactorVelocityDirection3d(FeatureBasePtr _ftr_ptr,
...@@ -34,8 +34,9 @@ class FactorVelocityDirection3d: public FactorAutodiff<FactorVelocityDirection3d ...@@ -34,8 +34,9 @@ class FactorVelocityDirection3d: public FactorAutodiff<FactorVelocityDirection3d
_status, _status,
_ftr_ptr->getFrame()->getV(), _ftr_ptr->getFrame()->getV(),
_ftr_ptr->getFrame()->getO()), _ftr_ptr->getFrame()->getO()),
min_vel_norm_(_min_vel_norm) min_vel_sq_norm_(_min_vel_norm*_min_vel_norm)
{ {
assert(abs(_ftr_ptr->getMeasurement().norm() - 1.0) < wolf::EPS && "velocity direction measurement must be normalized");
// std::cout << "created FactorVelocityDirection3d " << std::endl; // std::cout << "created FactorVelocityDirection3d " << std::endl;
} }
...@@ -51,7 +52,7 @@ inline bool FactorVelocityDirection3d::operator ()(const T* const _v, const T* c ...@@ -51,7 +52,7 @@ inline bool FactorVelocityDirection3d::operator ()(const T* const _v, const T* c
Eigen::Map<const Eigen::Matrix<T,3,1> > v(_v); Eigen::Map<const Eigen::Matrix<T,3,1> > v(_v);
Eigen::Map<const Eigen::Quaternion<T> > q(_q); Eigen::Map<const Eigen::Quaternion<T> > q(_q);
if (v.norm() < min_vel_norm_) if (v.squaredNorm() < min_vel_sq_norm_)
{ {
_residuals[0] = T(0); _residuals[0] = T(0);
return true; return true;
...@@ -73,7 +74,7 @@ inline bool FactorVelocityDirection3d::operator ()(const T* const _v, const T* c ...@@ -73,7 +74,7 @@ inline bool FactorVelocityDirection3d::operator ()(const T* const _v, const T* c
// << v_local(2) << "\n"; // << v_local(2) << "\n";
// error (angle between measurement and velocity in local coordinates) // error (angle between measurement and velocity in local coordinates)
T error = acos( v_local.dot(getMeasurement().cast<T>()) / (v_local.norm() * getMeasurement().cast<T>().norm())); T error = acos( v_local.dot(getMeasurement().cast<T>()) / (v_local.norm()));
// residual // residual
_residuals[0] = getMeasurementSquareRootInformationUpper()(0,0) * error; _residuals[0] = getMeasurementSquareRootInformationUpper()(0,0) * error;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment