VSLAMFactor Testable
parent
8c695a778c
commit
70efccefbc
|
@ -35,11 +35,10 @@ void VSLAMFactor::print(const std::string& s) const {
|
|||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
bool VSLAMFactor::equals(const NonlinearFactor<VSLAMConfig>& f, double tol) const {
|
||||
const VSLAMFactor* p = dynamic_cast<const VSLAMFactor*>(&f);
|
||||
if (p == NULL) return false;
|
||||
if (cameraFrameNumber_ != p->cameraFrameNumber_ || landmarkNumber_ != p->landmarkNumber_) return false;
|
||||
if (!equal_with_abs_tol(this->z_,p->z_,tol)) return false;
|
||||
bool VSLAMFactor::equals(const VSLAMFactor& p, double tol) const {
|
||||
if (&p == NULL) return false;
|
||||
if (cameraFrameNumber_ != p.cameraFrameNumber_ || landmarkNumber_ != p.landmarkNumber_) return false;
|
||||
if (!equal_with_abs_tol(this->z_,p.z_,tol)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "NonlinearFactor.h"
|
||||
#include "LinearFactor.h"
|
||||
#include "Cal3_S2.h"
|
||||
#include "Testable.h"
|
||||
|
||||
|
||||
namespace gtsam {
|
||||
|
||||
|
@ -18,7 +20,8 @@ class VSLAMConfig;
|
|||
* Non-linear factor for a constraint derived from a 2D measurement,
|
||||
* i.e. the main building block for visual SLAM.
|
||||
*/
|
||||
class VSLAMFactor : public NonlinearFactor<VSLAMConfig>
|
||||
//class VSLAMFactor : public NonlinearFactor<VSLAMConfig>, Testable<NonlinearFactor<VSLAMConfig> >
|
||||
class VSLAMFactor : public NonlinearFactor<VSLAMConfig>, Testable<VSLAMFactor>
|
||||
{
|
||||
private:
|
||||
|
||||
|
@ -51,7 +54,7 @@ class VSLAMFactor : public NonlinearFactor<VSLAMConfig>
|
|||
/**
|
||||
* equals
|
||||
*/
|
||||
bool equals(const NonlinearFactor<VSLAMConfig>&, double tol=1e-9) const;
|
||||
bool equals(const VSLAMFactor&, double tol=1e-9) const;
|
||||
|
||||
/**
|
||||
* predict the measurement
|
||||
|
|
|
@ -70,6 +70,21 @@ TEST( VSLAMFactor, error )
|
|||
CHECK(assert_equal(expected_config,actual_config,1e-9));
|
||||
}
|
||||
|
||||
TEST( VSLAMFactor, equals )
|
||||
{
|
||||
// Create two identical factors and make sure they're equal
|
||||
Vector z = Vector_(2,323.,240.);
|
||||
double sigma=1.0;
|
||||
int cameraFrameNumber=1, landmarkNumber=1;
|
||||
boost::shared_ptr<VSLAMFactor>
|
||||
factor1(new VSLAMFactor(z, sigma, cameraFrameNumber, landmarkNumber, K));
|
||||
|
||||
boost::shared_ptr<VSLAMFactor>
|
||||
factor2(new VSLAMFactor(z, sigma, cameraFrameNumber, landmarkNumber, K));
|
||||
|
||||
CHECK(assert_equal(*factor1, *factor2));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
int main() {
|
||||
TestResult tr;
|
||||
|
|
Loading…
Reference in New Issue