camera_pose_calibration.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2016 Delft Robotics B.V.
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 "camera_pose_calibration_impl.hpp"
00018 #include <gtest/gtest.h>
00019 
00020 int main(int argc, char **argv) {
00021         ::testing::InitGoogleTest(&argc, argv);
00022         return RUN_ALL_TESTS();
00023 }
00024 
00025 namespace camera_pose_calibration {
00026 
00028 TEST(CameraPoseCalibration, findIsometry_identity) {
00029         // Define cloud
00030         pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
00031         cloud->push_back(pcl::PointXYZ(0,0,0));
00032         cloud->push_back(pcl::PointXYZ(0,1,0));
00033         cloud->push_back(pcl::PointXYZ(0,0,1));
00034 
00035         // Calculate expected result and actual result
00036         Eigen::Isometry3d expected = Eigen::Isometry3d::Identity();
00037         Eigen::Isometry3d actual = findIsometry(cloud, cloud);
00038 
00039         for (int row=0; row<actual.matrix().rows(); row++) {
00040                 for (int col=0; col<actual.matrix().cols(); col++) {
00041                         EXPECT_NEAR(expected(row,col), actual(row,col), 6E-8);
00042                 }
00043         }
00044 }
00045 
00047 TEST(CameraPoseCalibration, findIsometry_translation) {
00048         // Define source
00049         pcl::PointCloud<pcl::PointXYZ>::Ptr source(new pcl::PointCloud<pcl::PointXYZ>);
00050         source->push_back(pcl::PointXYZ(0,0,0));
00051         source->push_back(pcl::PointXYZ(1,0,0));
00052         source->push_back(pcl::PointXYZ(0,1,0));
00053         source->push_back(pcl::PointXYZ(0,0,1));
00054 
00055         // Define target
00056         pcl::PointCloud<pcl::PointXYZ>::Ptr target(new pcl::PointCloud<pcl::PointXYZ>);
00057         target->push_back(pcl::PointXYZ(0,0,2));
00058         target->push_back(pcl::PointXYZ(1,0,2));
00059         target->push_back(pcl::PointXYZ(0,1,2));
00060         target->push_back(pcl::PointXYZ(0,0,3));
00061 
00062         // Expected result
00063         Eigen::Isometry3d expected = Eigen::Isometry3d::Identity() * Eigen::Translation3d(0,0,2);
00064 
00065         // Calculate isometry with function to be unit tested
00066         Eigen::Isometry3d actual = findIsometry(source, target);
00067 
00068         for (int row=0; row<actual.matrix().rows(); row++) {
00069                 for (int col=0; col<actual.matrix().cols(); col++) {
00070                         EXPECT_NEAR(expected(row,col), actual(row,col), 6E-8);
00071                 }
00072         }
00073 }
00074 
00075 }


camera_pose_calibration
Author(s): Hans Gaiser , Jeff van Egmond , Maarten de Vries , Mihai Morariu , Ronald Ensing
autogenerated on Thu Jun 6 2019 20:34:08