From 254f8c5f75276706ad7b61267ee3f98c39a4249f Mon Sep 17 00:00:00 2001 From: dellaert Date: Wed, 1 Oct 2014 11:01:38 +0200 Subject: [PATCH] Possible naming convention --- .../nonlinear/tests/testBADFactor.cpp | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/gtsam_unstable/nonlinear/tests/testBADFactor.cpp b/gtsam_unstable/nonlinear/tests/testBADFactor.cpp index e44da22e5..b4960afcd 100644 --- a/gtsam_unstable/nonlinear/tests/testBADFactor.cpp +++ b/gtsam_unstable/nonlinear/tests/testBADFactor.cpp @@ -28,21 +28,29 @@ using namespace std; using namespace gtsam; +/* ************************************************************************* */ +// Proposed naming convention +/* ************************************************************************* */ +typedef Expression Point2_; +typedef Expression Point3_; +typedef Expression Rot3_; +typedef Expression Pose3_; +typedef Expression Cal3_S2_; + /* ************************************************************************* */ // Functions that allow creating concise expressions -Expression transform_to(const Expression& x, - const Expression& p) { - return Expression(x, &Pose3::transform_to, p); +/* ************************************************************************* */ +Point3_ transform_to(const Pose3_& x, const Point3_& p) { + return Point3_(x, &Pose3::transform_to, p); } -Expression project(const Expression& p_cam) { - return Expression(PinholeCamera::project_to_camera, p_cam); +Point2_ project(const Point3_& p_cam) { + return Point2_(PinholeCamera::project_to_camera, p_cam); } template -Expression uncalibrate(const Expression& K, - const Expression& xy_hat) { - return Expression(K, &CAL::uncalibrate, xy_hat); +Point2_ uncalibrate(const Expression& K, const Point2_& xy_hat) { + return Point2_(K, &CAL::uncalibrate, xy_hat); } /* ************************************************************************* */ @@ -66,14 +74,14 @@ TEST(BADFactor, test) { Expression c(0); // Create leaves - Expression x(1); - Expression p(2); - Expression K(3); + Pose3_ x(1); + Point3_ p(2); + Cal3_S2_ K(3); // Create expression tree - Expression p_cam(x, &Pose3::transform_to, p); - Expression xy_hat(PinholeCamera::project_to_camera, p_cam); - Expression uv_hat(K, &Cal3_S2::uncalibrate, xy_hat); + Point3_ p_cam(x, &Pose3::transform_to, p); + Point2_ xy_hat(PinholeCamera::project_to_camera, p_cam); + Point2_ uv_hat(K, &Cal3_S2::uncalibrate, xy_hat); // Create factor and check value, dimension, linearization BADFactor f(measured, uv_hat); @@ -95,8 +103,8 @@ TEST(BADFactor, test) { TEST(BADFactor, compose) { // Create expression - Expression R1(1), R2(2); - Expression R3 = R1 * R2; + Rot3_ R1(1), R2(2); + Rot3_ R3 = R1 * R2; // Create factor BADFactor f(Rot3(), R3); @@ -119,8 +127,8 @@ TEST(BADFactor, compose) { TEST(BADFactor, compose2) { // Create expression - Expression R1(1), R2(1); - Expression R3 = R1 * R2; + Rot3_ R1(1), R2(1); + Rot3_ R3 = R1 * R2; // Create factor BADFactor f(Rot3(), R3);