occupied_space_cost_function_2d_test.cc
Go to the documentation of this file.
00001 /*
00002  * Copyright 2018 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #include "cartographer/mapping/internal/2d/scan_matching/occupied_space_cost_function_2d.h"
00018 
00019 #include "cartographer/mapping/2d/probability_grid.h"
00020 #include "cartographer/mapping/probability_values.h"
00021 #include "gmock/gmock.h"
00022 #include "gtest/gtest.h"
00023 
00024 namespace cartographer {
00025 namespace mapping {
00026 namespace scan_matching {
00027 namespace {
00028 
00029 using ::testing::DoubleEq;
00030 using ::testing::ElementsAre;
00031 
00032 TEST(OccupiedSpaceCostFunction2DTest, SmokeTest) {
00033   ValueConversionTables conversion_tables;
00034   ProbabilityGrid grid(MapLimits(1., Eigen::Vector2d(1., 1.), CellLimits(2, 2)),
00035                        &conversion_tables);
00036   sensor::PointCloud point_cloud = {{Eigen::Vector3f{0.f, 0.f, 0.f}}};
00037   ceres::Problem problem;
00038   std::unique_ptr<ceres::CostFunction> cost_function(
00039       CreateOccupiedSpaceCostFunction2D(1.f, point_cloud, grid));
00040 
00041   const std::array<double, 3> pose_estimate{{0., 0., 0.}};
00042   const std::array<const double*, 1> parameter_blocks{{pose_estimate.data()}};
00043 
00044   std::array<double, 1> residuals;
00045   std::array<std::array<double, 3>, 1> jacobians;
00046   std::array<double*, 1> jacobians_ptrs;
00047   for (int i = 0; i < 1; ++i) jacobians_ptrs[i] = jacobians[i].data();
00048   cost_function->Evaluate(parameter_blocks.data(), residuals.data(),
00049                           jacobians_ptrs.data());
00050 
00051   EXPECT_THAT(residuals, ElementsAre(DoubleEq(kMaxProbability)));
00052 }
00053 
00054 }  // namespace
00055 }  // namespace scan_matching
00056 }  // namespace mapping
00057 }  // namespace cartographer


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:35