gucoordinates
CameraPivotTests.cc
Go to the documentation of this file.
1/*
2 * CameraPivotTests.cc
3 * tests
4 *
5 * Created by Callum McColl on 20/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#include "GUWrapperTests.hpp"
60
61namespace CGTEST {
62
63 class CameraPivotCPPTests: public GUWrapperTests<GU::CameraPivot, gu_camera_pivot> {
64
65 protected:
66
69
70 void preamble()
71 {
74 for (int i = 2; i < GU_CAMERA_PIVOT_NUM_CAMERAS; i++)
75 {
76 cameras[i].height = 0.0;
77 cameras[i].centerOffset = 0.0;
78 cameras[i].vDirection = 0.0;
79 cameras[i].vFov = 0.0;
80 cameras[i].hFov = 0.0;
81 }
82 empty_strct.pitch = 0.0;
83 empty_strct.yaw = 0.0;
84 empty_strct.height = 0.0;
87 }
88
90 {
91 return GU::CameraPivot(2.0, 3.0, 4.0, cameras, 2);
92 }
93
95 {
97 }
98
100 {
101 obj.set_pitch(1.0);
102 }
103
105 {
106 obj.pitch = 1.0;
107 obj.yaw = 2.0;
108 obj.height = 3.0;
110 obj.numCameras = 2;
111 }
112
114 {
115 return empty();
116 }
117
118 };
119
121
122 TEST_F(CameraPivotCPPTests, GettersSetters) {
123 gu_camera_pivot nao_c = GU_NAO_V5_HEAD(0.0, 0.0);
124 GU::CameraPivot nao = nao_c;
125 ASSERT_EQ(nao.pitch(), 0.0);
126 nao.set_pitch(5.0);
127 ASSERT_EQ(nao.pitch(), 5.0);
128 ASSERT_EQ(nao.yaw(), 0.0);
129 nao.set_yaw(6.0);
130 ASSERT_EQ(nao.yaw(), 6.0);
131 ASSERT_EQ(nao.height(), 41.7);
132 nao.set_height(7.0);
133 ASSERT_EQ(nao.height(), 7.0);
134 equals(nao.camera(0), nao_c.cameras[0]);
135 nao.set_camera(0, nao_c.cameras[1]);
136 equals(nao.camera(1), nao_c.cameras[1]);
137 }
138
139} // namespace
#define WRAPPER_TEST_Fs(className, strctName)
#define GU_CAMERA_PIVOT_NUM_CAMERAS
Definition: camera_pivot.h:74
void change(GU::CameraPivot &obj)
void cchange(gu_camera_pivot &obj)
#define GU_NAO_V5_BOTTOM_CAMERA
#define GU_NAO_V5_TOP_CAMERA
#define GU_NAO_V5_HEAD(p, y)
TEST_F(CameraCoordinateTests, Equality)
void set_yaw(const degrees_d) NOEXCEPT
Definition: CameraPivot.cc:186
void set_camera(const int, const Camera) NOEXCEPT
Definition: CameraPivot.cc:217
void set_pitch(const degrees_d) NOEXCEPT
Definition: CameraPivot.cc:176
void set_height(const centimetres_d) NOEXCEPT
Definition: CameraPivot.cc:197
degrees_d yaw() const NOEXCEPT
Definition: CameraPivot.cc:181
degrees_d pitch() const NOEXCEPT
Definition: CameraPivot.cc:171
Camera camera(const int) const NOEXCEPT
Definition: CameraPivot.cc:212
centimetres_d height() const NOEXCEPT
Definition: CameraPivot.cc:192
A gu_camera_pivot represents the pivot point which a gu_camera is attached to.
Definition: camera_pivot.h:87
degrees_d pitch
The vertical orientation of the pivot point.
Definition: camera_pivot.h:92
degrees_d yaw
The horizontal orientation of the pivot point.
Definition: camera_pivot.h:97
centimetres_d height
The vertical distance from the ground to the pivot point.
Definition: camera_pivot.h:102
gu_camera cameras[2]
The gu_cameras attached to this pivot point.
Definition: camera_pivot.h:107
int numCameras
The number of elements in cameras.
Definition: camera_pivot.h:112
centimetres_d centerOffset
The distance the camera is from the center point.
Definition: camera.h:92
centimetres_d height
The height from the pivot of the camera to the middle of the camera.
Definition: camera.h:80
degrees_d hFov
The horizontal field of view.
Definition: camera.h:110
degrees_d vFov
The vertical field of view.
Definition: camera.h:105
degrees_d vDirection
The degree in which the camera is facing in the vertical direction.
Definition: camera.h:100