Specify key involved when throwing cheirality exception

release/4.3a0
Toni Rosinol 2018-05-24 18:05:57 -04:00
parent dccc742490
commit 2af48952b2
4 changed files with 25 additions and 7 deletions

View File

@ -32,9 +32,17 @@ namespace gtsam {
class GTSAM_EXPORT CheiralityException: public ThreadsafeException< class GTSAM_EXPORT CheiralityException: public ThreadsafeException<
CheiralityException> { CheiralityException> {
public: public:
CheiralityException() : CheiralityException()
ThreadsafeException<CheiralityException>("Cheirality Exception") { : CheiralityException(std::numeric_limits<Key>::max()) {}
}
CheiralityException(Key j)
: ThreadsafeException<CheiralityException>("CheiralityException"),
j_(j) {}
Key nearbyVariable() const {return j_;}
private:
Key j_;
}; };
/** /**

View File

@ -25,9 +25,19 @@ namespace gtsam {
class GTSAM_EXPORT StereoCheiralityException: public std::runtime_error { class GTSAM_EXPORT StereoCheiralityException: public std::runtime_error {
public: public:
StereoCheiralityException() : StereoCheiralityException()
std::runtime_error("Stereo Cheirality Exception") { : StereoCheiralityException(std::numeric_limits<Key>::max()) {}
StereoCheiralityException(Key j)
: std::runtime_error("Stereo Cheirality Exception"),
j_(j) {}
Key nearbyVariable() const {
return j_;
} }
private:
Key j_;
}; };
/** /**

View File

@ -152,7 +152,7 @@ namespace gtsam {
std::cout << e.what() << ": Landmark "<< DefaultKeyFormatter(this->key2()) << std::cout << e.what() << ": Landmark "<< DefaultKeyFormatter(this->key2()) <<
" moved behind camera " << DefaultKeyFormatter(this->key1()) << std::endl; " moved behind camera " << DefaultKeyFormatter(this->key1()) << std::endl;
if (throwCheirality_) if (throwCheirality_)
throw e; throw CheiralityException(this->key2());
} }
return Vector2::Constant(2.0 * K_->fx()); return Vector2::Constant(2.0 * K_->fx());
} }

View File

@ -144,7 +144,7 @@ public:
std::cout << e.what() << ": Landmark "<< DefaultKeyFormatter(this->key2()) << std::cout << e.what() << ": Landmark "<< DefaultKeyFormatter(this->key2()) <<
" moved behind camera " << DefaultKeyFormatter(this->key1()) << std::endl; " moved behind camera " << DefaultKeyFormatter(this->key1()) << std::endl;
if (throwCheirality_) if (throwCheirality_)
throw e; throw StereoCheiralityException(this->key2());
} }
return Vector3::Constant(2.0 * K_->fx()); return Vector3::Constant(2.0 * K_->fx());
} }