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<
CheiralityException> {
public:
CheiralityException() :
ThreadsafeException<CheiralityException>("Cheirality Exception") {
}
CheiralityException()
: 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 {
public:
StereoCheiralityException() :
std::runtime_error("Stereo Cheirality Exception") {
StereoCheiralityException()
: 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()) <<
" moved behind camera " << DefaultKeyFormatter(this->key1()) << std::endl;
if (throwCheirality_)
throw e;
throw CheiralityException(this->key2());
}
return Vector2::Constant(2.0 * K_->fx());
}

View File

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