Fix leak in LandmarkCostFunctionTest. (#902)

master
gaschler 2018-02-14 12:38:01 +01:00 committed by Wally B. Feed
parent 9793542957
commit cf01184114
2 changed files with 26 additions and 20 deletions

View File

@ -15,8 +15,10 @@
*/ */
#include "cartographer/mapping_2d/pose_graph/landmark_cost_function.h" #include "cartographer/mapping_2d/pose_graph/landmark_cost_function.h"
#include "cartographer/transform/rigid_transform.h"
#include <memory>
#include "cartographer/transform/rigid_transform.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
@ -39,15 +41,16 @@ TEST(LandmarkCostFunctionTest, SmokeTest) {
next_node.time = common::FromUniversal(10); next_node.time = common::FromUniversal(10);
next_node.gravity_alignment = Eigen::Quaterniond::Identity(); next_node.gravity_alignment = Eigen::Quaterniond::Identity();
auto* cost_function = LandmarkCostFunction::CreateAutoDiffCostFunction( std::unique_ptr<ceres::CostFunction> cost_function(
LandmarkObservation{ LandmarkCostFunction::CreateAutoDiffCostFunction(
0 /* trajectory ID */, LandmarkObservation{
common::FromUniversal(5) /* time */, 0 /* trajectory ID */,
transform::Rigid3d::Translation(Eigen::Vector3d(1., 1., 1.)), common::FromUniversal(5) /* time */,
1. /* translation_weight */, transform::Rigid3d::Translation(Eigen::Vector3d(1., 1., 1.)),
2. /* rotation_weight */, 1. /* translation_weight */,
}, 2. /* rotation_weight */,
prev_node, next_node); },
prev_node, next_node));
const std::array<double, 3> prev_node_pose{{2., 0., 0.}}; const std::array<double, 3> prev_node_pose{{2., 0., 0.}};
const std::array<double, 3> next_node_pose{{0., 2., 0.}}; const std::array<double, 3> next_node_pose{{0., 2., 0.}};

View File

@ -15,8 +15,10 @@
*/ */
#include "cartographer/mapping_3d/pose_graph/landmark_cost_function.h" #include "cartographer/mapping_3d/pose_graph/landmark_cost_function.h"
#include "cartographer/transform/rigid_transform.h"
#include <memory>
#include "cartographer/transform/rigid_transform.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
@ -37,15 +39,16 @@ TEST(LandmarkCostFunctionTest, SmokeTest) {
NodeData next_node; NodeData next_node;
next_node.time = common::FromUniversal(10); next_node.time = common::FromUniversal(10);
auto* cost_function = LandmarkCostFunction::CreateAutoDiffCostFunction( std::unique_ptr<ceres::CostFunction> cost_function(
LandmarkObservation{ LandmarkCostFunction::CreateAutoDiffCostFunction(
0 /* trajectory ID */, LandmarkObservation{
common::FromUniversal(5) /* time */, 0 /* trajectory ID */,
transform::Rigid3d::Translation(Eigen::Vector3d(1., 1., 1.)), common::FromUniversal(5) /* time */,
1. /* translation_weight */, transform::Rigid3d::Translation(Eigen::Vector3d(1., 1., 1.)),
2. /* rotation_weight */, 1. /* translation_weight */,
}, 2. /* rotation_weight */,
prev_node, next_node); },
prev_node, next_node));
const std::array<double, 4> prev_node_rotation{{1., 0., 0., 0.}}; const std::array<double, 4> prev_node_rotation{{1., 0., 0., 0.}};
const std::array<double, 3> prev_node_translation{{0., 0., 0.}}; const std::array<double, 3> prev_node_translation{{0., 0., 0.}};