camera_info_tests.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Michael Ferguson
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 // Author: Michael Ferguson
18 
21 #include <gtest/gtest.h>
22 
23 TEST(CameraInfoTests, test_update_camera_info)
24 {
25  sensor_msgs::CameraInfo start;
26  start.P[0] = 1.0; // FX
27  start.P[2] = 2.0; // CX
28  start.P[5] = 3.0; // FY
29  start.P[6] = 4.0; // CY
30 
31  start.K[0] = 5.0; // FX
32  start.K[2] = 6.0; // CX
33  start.K[4] = 7.0; // FY
34  start.K[5] = 8.0; // CY
35 
36  sensor_msgs::CameraInfo end =
37  robot_calibration::updateCameraInfo(0.0, 0.0, 0.0, 0.0, start);
38 
39  EXPECT_EQ(start.P[0], end.P[0]);
40  EXPECT_EQ(start.P[2], end.P[2]);
41  EXPECT_EQ(start.P[5], end.P[5]);
42  EXPECT_EQ(start.P[6], end.P[6]);
43  EXPECT_EQ(start.K[0], end.K[0]);
44  EXPECT_EQ(start.K[2], end.K[2]);
45  EXPECT_EQ(start.K[4], end.K[4]);
46  EXPECT_EQ(start.K[5], end.K[5]);
47 }
48 
49 TEST(CameraInfoTests, test_extended_camera_info)
50 {
51  ros::NodeHandle nh("~");
53 
54  manager.init(nh);
55 
56  robot_calibration_msgs::ExtendedCameraInfo eci =
57  manager.getDepthCameraInfo();
58 
59  ASSERT_EQ(static_cast<size_t>(2), eci.parameters.size());
60  EXPECT_EQ(eci.parameters[0].name, "z_offset_mm");
61  EXPECT_EQ(eci.parameters[0].value, 2.0);
62  EXPECT_EQ(eci.parameters[1].name, "z_scaling");
63  EXPECT_EQ(eci.parameters[1].value, 1.1);
64 }
65 
66 int main(int argc, char** argv)
67 {
68  ros::init(argc, argv, "camera_info_tests");
69  testing::InitGoogleTest(&argc, argv);
70  return RUN_ALL_TESTS();
71 }
sensor_msgs::CameraInfo updateCameraInfo(double camera_fx, double camera_fy, double camera_cx, double camera_cy, const sensor_msgs::CameraInfo &info)
Update the camera calibration with the new offsets.
Definition: camera_info.h:54
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
robot_calibration_msgs::ExtendedCameraInfo getDepthCameraInfo()
Definition: depth_camera.h:75
TEST(CameraInfoTests, test_update_camera_info)
int main(int argc, char **argv)
Base class for a feature finder.
Definition: depth_camera.h:32


robot_calibration
Author(s): Michael Ferguson
autogenerated on Tue Nov 3 2020 17:30:30