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(LandmarkCostFunction3DTest, SmokeTest) {
42 std::unique_ptr<ceres::CostFunction> cost_function(
51 prev_node, next_node));
53 const std::array<double, 4> prev_node_rotation{{1., 0., 0., 0.}};
54 const std::array<double, 3> prev_node_translation{{0., 0., 0.}};
55 const std::array<double, 4> next_node_rotation{{1., 0., 0., 0.}};
56 const std::array<double, 3> next_node_translation{{2., 2., 2.}};
57 const std::array<double, 4> landmark_rotation{{1., 0., 0., 0.}};
58 const std::array<double, 3> landmark_translation{{1., 2., 2.}};
59 const std::array<const double*, 6> parameter_blocks{
60 {prev_node_rotation.data(), prev_node_translation.data(),
61 next_node_rotation.data(), next_node_translation.data(),
62 landmark_rotation.data(), landmark_translation.data()}};
64 std::array<double, 6> residuals;
65 std::array<std::array<double, 21>, 6> jacobians;
66 std::array<double*, 6> jacobians_ptrs;
67 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 NodeSpec3D &prev_node, const NodeSpec3D &next_node)
Time FromUniversal(const int64 ticks)
TEST(TrajectoryConnectivityStateTest, UnknownTrajectory)