gucoordinates
FieldCoordinateTests.cc
Go to the documentation of this file.
1/*
2 * FieldCoordinateTests.cc
3 * tests
4 *
5 * Created by Callum McColl on 21/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 FieldCoordinateCPPTests: public GUWrapperTests<GU::FieldCoordinate, gu_field_coordinate> {
64
65 protected:
66
68 {
70 }
71
73 {
75 }
76
78 {
80 }
81
83 {
85 coord.x = 40;
86 coord.y = 30;
87 obj.position = coord;
88 obj.heading = 15;
89 }
90
92 {
93 return empty();
94 }
95
96 };
97
99
100 GETTER_IM_TEST_NAME_F(FieldCoordinate, cartesianCoordinateCamera, CartesianCoordinate, rr_coord_to_cartesian_coord_from_field, RelativeCoordinate, pct_coord_to_rr_coord, cartesianCoordinateAt(GU::CameraCoordinate(23, 52, 1920, 1080), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX))
101 GETTER_IM_TEST_NAME_F(FieldCoordinate, cartesianCoordinatePixel, CartesianCoordinate, rr_coord_to_cartesian_coord_from_field, RelativeCoordinate, pct_coord_to_rr_coord, cartesianCoordinateAt(GU::PixelCoordinate(42, -123, 1920, 1080), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX))
102 GETTER_IM_TEST_NAME_F(FieldCoordinate, cartesianCoordinatePercent, CartesianCoordinate, rr_coord_to_cartesian_coord_from_field, RelativeCoordinate, pct_coord_to_rr_coord, cartesianCoordinateAt(GU::PercentCoordinate(-0.24, 0.5), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX))
103 GETTER_IM_TEST_NAME_F(FieldCoordinate, fieldCoordinateCamera, FieldCoordinate, rr_coord_to_field_coord_from_source, RelativeCoordinate, pct_coord_to_rr_coord, fieldCoordinateAt(GU::CameraCoordinate(23, 52, 1920, 1080), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 70))
104 GETTER_IM_TEST_NAME_F(FieldCoordinate, fieldCoordinatePixel, FieldCoordinate, rr_coord_to_field_coord_from_source, RelativeCoordinate, pct_coord_to_rr_coord, fieldCoordinateAt(GU::PixelCoordinate(42, -123, 1920, 1080), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 70))
105 GETTER_IM_TEST_NAME_F(FieldCoordinate, fieldCoordinatePercent, FieldCoordinate, rr_coord_to_field_coord_from_source, RelativeCoordinate, pct_coord_to_rr_coord, fieldCoordinateAt(GU::PercentCoordinate(-0.24, 0.5), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 70))
106
107 GETTER_TEST_F(FieldCoordinate, CartesianCoordinate, rr_coord_to_cartesian_coord_from_field, cartesianCoordinateAt(GU::RelativeCoordinate(-23, 823)))
108 GETTER_TEST_F(FieldCoordinate, FieldCoordinate, rr_coord_to_field_coord_from_source, fieldCoordinateAt(GU::RelativeCoordinate(-23, 823), -3))
109 GETTER_TEST_NAME_F(FieldCoordinate, RelativeCoordinateToCartesian, RelativeCoordinate, field_coord_to_rr_coord_to_target, relativeCoordinateTo(GU::CartesianCoordinate(-80, 23)))
110 GETTER_TEST_NAME_F(FieldCoordinate, RelativeCoordinateToField, RelativeCoordinate, field_coord_to_rr_coord_to_target, relativeCoordinateTo(GU::FieldCoordinate(GU::CartesianCoordinate(-80, 23), 23)))
111
112 GETTER_TEST_NAME_F(FieldCoordinate, percentCoordinateCartesian, PercentCoordinate, rr_coord_to_pct_coord, percentCoordinateTo(GU::CartesianCoordinate(-3, 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX))
113 GETTER_TEST_NAME_F(FieldCoordinate, percentCoordinateField, PercentCoordinate, rr_coord_to_pct_coord, percentCoordinateTo(GU::FieldCoordinate(GU::CartesianCoordinate(23, 100), 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX))
114
115 GETTER_IM_TEST_NAME_F(FieldCoordinate, pixelCoordinateCartesian, PixelCoordinate, pct_coord_to_px_coord, PercentCoordinate, rr_coord_to_pct_coord, pixelCoordinateTo(GU::CartesianCoordinate(-3, 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 1920, 1080))
116 GETTER_IM_TEST_NAME_F(FieldCoordinate, pixelCoordinateField, PixelCoordinate, pct_coord_to_px_coord, PercentCoordinate, rr_coord_to_pct_coord, pixelCoordinateTo(GU::FieldCoordinate(GU::CartesianCoordinate(23, 100), 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 1920, 1080))
117
118 GETTER_IM_TEST_NAME_F(FieldCoordinate, cameraCoordinateCartesian, CameraCoordinate, px_coord_to_cam_coord, PercentCoordinate, rr_coord_to_pct_coord, cameraCoordinateTo(GU::CartesianCoordinate(-3, 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 1920, 1080))
119 GETTER_IM_TEST_NAME_F(FieldCoordinate, cameraCoordinateField, CameraCoordinate, px_coord_to_cam_coord, PercentCoordinate, rr_coord_to_pct_coord, cameraCoordinateTo(GU::FieldCoordinate(GU::CartesianCoordinate(23, 100), 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 1920, 1080))
120
121 GETTER_TEST_NAME_F(FieldCoordinate, clampedPercentCoordinateCartesian, PercentCoordinate, clamped_rr_coord_to_pct_coord, clampedPercentCoordinateTo(GU::CartesianCoordinate(-3, 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX))
122 GETTER_TEST_NAME_F(FieldCoordinate, clampedPercentCoordinateField, PercentCoordinate, clamped_rr_coord_to_pct_coord, clampedPercentCoordinateTo(GU::FieldCoordinate(GU::CartesianCoordinate(23, 100), 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX))
123
124 GETTER_IM_TEST_NAME_F(FieldCoordinate, clampedPixelCoordinateCartesian, PixelCoordinate, pct_coord_to_px_coord, PercentCoordinate, clamped_rr_coord_to_pct_coord, clampedPixelCoordinateTo(GU::CartesianCoordinate(-3, 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 1920, 1080))
125 GETTER_IM_TEST_NAME_F(FieldCoordinate, clampedPixelCoordinateField, PixelCoordinate, pct_coord_to_px_coord, PercentCoordinate, clamped_rr_coord_to_pct_coord, clampedPixelCoordinateTo(GU::FieldCoordinate(GU::CartesianCoordinate(23, 100), 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 1920, 1080))
126
127 GETTER_IM_TEST_NAME_F(FieldCoordinate, clampedCameraCoordinateCartesian, CameraCoordinate, px_coord_to_cam_coord, PercentCoordinate, clamped_rr_coord_to_pct_coord, clampedCameraCoordinateTo(GU::CartesianCoordinate(-3, 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 1920, 1080))
128 GETTER_IM_TEST_NAME_F(FieldCoordinate, clampedCameraCoordinateField, CameraCoordinate, px_coord_to_cam_coord, PercentCoordinate, clamped_rr_coord_to_pct_coord, clampedCameraCoordinateTo(GU::FieldCoordinate(GU::CartesianCoordinate(23, 100), 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 1920, 1080))
129
132 equals(coord.position(), GU::CartesianCoordinate(90, 50));
133 coord.set_position(GU::CartesianCoordinate(-90, -50));
134 equals(coord.position(), GU::CartesianCoordinate(-90, -50));
135 ASSERT_EQ(coord.heading(), 100);
136 coord.set_heading(10);
137 ASSERT_EQ(coord.heading(), 10);
138 }
139
140} // namespace
#define GETTER_IM_TEST_NAME_F(className, testName, resultType, call, imType, imCall, get)
#define WRAPPER_TEST_Fs(className, strctName)
#define GETTER_TEST_NAME_F(className, testName, resultType, call, get)
#define GETTER_TEST_F(className, resultType, call, get)
void cchange(gu_field_coordinate &obj)
void change(GU::FieldCoordinate &obj)
gu_percent_coordinate clamped_rr_coord_to_pct_coord(const gu_relative_coordinate coord, const gu_camera_pivot camera_pivot, const int cameraOffset)
Definition: conversions.c:157
gu_field_coordinate rr_coord_to_field_coord_from_source(const gu_relative_coordinate coord, const gu_field_coordinate source, const degrees_t heading)
Definition: conversions.c:211
gu_camera_coordinate px_coord_to_cam_coord(const gu_pixel_coordinate coord)
Definition: conversions.c:85
gu_pixel_coordinate pct_coord_to_px_coord(const gu_percent_coordinate coord, const pixels_u res_width, const pixels_u res_height)
Definition: conversions.c:105
gu_cartesian_coordinate rr_coord_to_cartesian_coord_from_field(const gu_relative_coordinate coord, const gu_field_coordinate source)
Definition: conversions.c:196
gu_relative_coordinate pct_coord_to_rr_coord(const gu_percent_coordinate coord, const gu_camera_pivot camera_pivot, const int cameraOffset)
Definition: conversions.c:115
gu_percent_coordinate rr_coord_to_pct_coord(const gu_relative_coordinate coord, const gu_camera_pivot camera_pivot, const int cameraOffset)
Definition: conversions.c:142
gu_relative_coordinate field_coord_to_rr_coord_to_target(const gu_field_coordinate source, const gu_cartesian_coordinate target)
Definition: conversions.c:237
#define GU_NAO_V5_BOTTOM_CAMERA_INDEX
TEST_F(CameraCoordinateTests, Equality)
Definition: Camera.hpp:66
degrees_t heading() const NOEXCEPT
void set_heading(const degrees_t) NOEXCEPT
void set_position(const CartesianCoordinate) NOEXCEPT
CartesianCoordinate position() const NOEXCEPT
A cartesian_coordinate is a general coordinate for representing positions on a tow dimensional plane.
millimetres_t y
The y coordinate of the position in centimetres.
millimetres_t x
The x coordinate of the position in centimetres.
A field_coordinate is a coordinate for an object that faces a certain direction (such as a robot) on ...
degrees_t heading
The direction where the object is facing.
gu_cartesian_coordinate position
The position of the object on the field.