22 #include "gmock/gmock.h" 23 #include "gtest/gtest.h" 27 namespace optimization {
30 using ::testing::DoubleEq;
31 using ::testing::ElementsAre;
33 using LandmarkObservation =
34 PoseGraphInterface::LandmarkNode::LandmarkObservation;
36 TEST(LandmarkCostFunctionTest, SmokeTest) {
39 prev_node.gravity_alignment = Eigen::Quaterniond::Identity();
42 next_node.gravity_alignment = Eigen::Quaterniond::Identity();
44 std::unique_ptr<ceres::CostFunction> cost_function(
53 prev_node, next_node));
55 const std::array<double, 3> prev_node_pose{{2., 0., 0.}};
56 const std::array<double, 3> next_node_pose{{0., 2., 0.}};
57 const std::array<double, 4> landmark_rotation{{1., 0., 0., 0.}};
58 const std::array<double, 3> landmark_translation{{1., 2., 1.}};
59 const std::array<const double*, 4> parameter_blocks{
60 {prev_node_pose.data(), next_node_pose.data(), landmark_rotation.data(),
61 landmark_translation.data()}};
63 std::array<double, 6> residuals;
64 std::array<std::array<double, 13>, 6> jacobians;
65 std::array<double*, 6> jacobians_ptrs;
66 for (
int i = 0; i < 6; ++i) jacobians_ptrs[i] = jacobians[i].data();
68 cost_function->Evaluate(parameter_blocks.data(), residuals.data(),
69 jacobians_ptrs.data());
70 EXPECT_THAT(residuals, ElementsAre(DoubleEq(1.), DoubleEq(0.), DoubleEq(0.),
71 DoubleEq(0.), DoubleEq(0.), DoubleEq(0.)));
static ceres::CostFunction * CreateAutoDiffCostFunction(const LandmarkObservation &observation, const NodeSpec2D &prev_node, const NodeSpec2D &next_node)
Time FromUniversal(const int64 ticks)
TEST(TrajectoryConnectivityStateTest, UnknownTrajectory)