gucoordinates
gucoordinates_tests.hpp
Go to the documentation of this file.
1/*
2 * gucoordinates_tests.hpp
3 * ctests
4 *
5 * Created by Callum McColl on 23/06/2020.
6 * Copyright © 2020 Callum McColl. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials
18 * provided with the distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgement:
22 *
23 * This product includes software developed by Callum McColl.
24 *
25 * 4. Neither the name of the author nor the names of contributors
26 * may be used to endorse or promote products derived from this
27 * software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
33 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
34 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
35 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
36 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
37 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
38 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * -----------------------------------------------------------------------
42 * This program is free software; you can redistribute it and/or
43 * modify it under the above terms or under the terms of the GNU
44 * General Public License as published by the Free Software Foundation;
45 * either version 2 of the License, or (at your option) any later version.
46 *
47 * This program is distributed in the hope that it will be useful,
48 * but WITHOUT ANY WARRANTY; without even the implied warranty of
49 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50 * GNU General Public License for more details.
51 *
52 * You should have received a copy of the GNU General Public License
53 * along with this program; if not, see http://www.gnu.org/licenses/
54 * or write to the Free Software Foundation, Inc., 51 Franklin Street,
55 * Fifth Floor, Boston, MA 02110-1301, USA.
56 *
57 */
58
59#ifndef GUCOORDINATES_TESTS_HPP
60#define GUCOORDINATES_TESTS_HPP
61
62#pragma clang diagnostic push
63#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
64#pragma clang diagnostic ignored "-Wfloat-equal"
65#pragma clang diagnostic ignored "-Wsign-compare"
66#pragma clang diagnostic ignored "-Wmissing-noreturn"
67#pragma clang diagnostic ignored "-Wshift-sign-overflow"
68#pragma clang diagnostic ignored "-Wused-but-marked-unused"
69#pragma clang diagnostic ignored "-Wundef"
70#pragma clang diagnostic ignored "-Wc++98-compat"
71#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
72#pragma clang diagnostic ignored "-Wc++11-long-long"
73#pragma clang diagnostic ignored "-Wc++11-extensions"
74#pragma clang diagnostic ignored "-Wdeprecated"
75#include <gtest/gtest.h>
76#pragma clang diagnostic pop
77
78#include "../gucoordinates.h"
79
80#define GU_NAO_V5_TOP_CAMERA gu_camera_make(6.364f, 5.871f, 1.2f, 47.64f, 60.97f)
81#define GU_NAO_V5_BOTTOM_CAMERA gu_camera_make(1.774f, 5.071f, 39.7f, 47.64f, 60.97f)
82
83#define GU_PEPPER_TOP_CAMERA gu_camera_make(115.3f, 8.68f, 0.0f, 44.3f, 55.2f)
84#define GU_PEPPER_BOTTOM_CAMERA gu_camera_make(105.15f, 9.36f, 40.0f, 44.3f, 55.2f)
85
86#define GU_NAO_V5_HEAD(p, y) (gu_camera_pivot) {.pitch = p, .yaw = y, .height = 41.7f, .cameras = {GU_NAO_V5_TOP_CAMERA, GU_NAO_V5_BOTTOM_CAMERA}, .numCameras = 2}
87#define GU_NAO_V5_TOP_CAMERA_INDEX 0
88#define GU_NAO_V5_BOTTOM_CAMERA_INDEX 1
89
90#define GU_PEPPER_HEAD(p, y) {p, y, 0.0f, {GU_PEPPER_TOP_CAMERA, GU_PEPPER_BOTTOM_CAMERA}, 2}
91
92#define GU_NAO_V5_ROBOT(hp, hy, x, y, t) (gu_robot) { .head = { hp, hy, 41.7f, {GU_NAO_V5_TOP_CAMERA, GU_NAO_V5_BOTTOM_CAMERA}, 2 }, .position = { { x, y }, t } }
93
94#define GU_PEPPER_ROBOT(hp, hy, x, y, t) (gu_robot) { .head = { hp, hy, 0.0f, {GU_PEPPER_TOP_CAMERA, GU_PEPPER_BOTTOM_CAMERA}, 2 }, .position = { { x, y }, t } }
95
96#include <math.h>
97
98namespace CGTEST {
99
100 class GUCoordinatesTests: public ::testing::Test {
101 protected:
102
103 virtual void SetUp() {}
104
105 virtual void TearDown() {}
106
108 {
109 ASSERT_EQ(lhs.x, rhs.x);
110 ASSERT_EQ(lhs.y, rhs.y);
111 ASSERT_EQ(lhs.res_width, rhs.res_width);
112 ASSERT_EQ(lhs.res_height, rhs.res_height);
113 }
114
116 {
117 ASSERT_EQ(lhs.x, rhs.x);
118 ASSERT_EQ(lhs.y, rhs.y);
119 ASSERT_EQ(lhs.res_width, rhs.res_width);
120 ASSERT_EQ(lhs.res_height, rhs.res_height);
121 }
122
124 {
125 ASSERT_EQ(lhs.x, rhs.x);
126 ASSERT_EQ(lhs.y, rhs.y);
127 }
128
130 {
131 ASSERT_LT(fabs(lhs.x - rhs.x), 0.001);
132 ASSERT_LT(fabs(lhs.y - rhs.y), 0.001);
133 }
134
135 };
136
137}
138
139#endif /* GUCOORDINATES_TESTS_HPP */
void pixel_equal(const gu_pixel_coordinate lhs, const gu_pixel_coordinate rhs)
void percent_near(const gu_percent_coordinate lhs, const gu_percent_coordinate rhs)
void percent_equal(const gu_percent_coordinate lhs, const gu_percent_coordinate rhs)
void camera_equal(const gu_camera_coordinate lhs, const gu_camera_coordinate rhs)
A gu_camera_coordinate represents the coordinate of a pixel within an image where the (0,...
pixels_u x
The x coordinate of the pixel within the image.
pixels_u res_height
The height of the resolution of the image.
pixels_u res_width
The width of the resolution of the image.
pixels_u y
The y coordinate of the pixel within the image.
A gu_percent_coordinate represents the coordinate of a pixel within an image.
percent_d y
The y coordinate of the pixel within the image as a percentage.
percent_d x
The x coordinate of the pixel within the image as a percentage.
A gu_pixel_coordinate represents the coordinate of a pixel within an image.
pixels_u res_height
The height of the resolution of the image.
pixels_t x
The x coordinate of the pixel within the image.
pixels_u res_width
The width of the resolution of the image.
pixels_t y
The y coordinate of the pixel within the image.