compress_test.cpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2018, Locus Robotics
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  */
34 #include <gtest/gtest.h>
35 #include <nav_2d_utils/path_ops.h>
36 
39 
40 TEST(CompressTest, compress_test)
41 {
42  nav_2d_msgs::Path2D path;
43  // Dataset borrowed from https://karthaus.nl/rdp/
44  addPose(path, 24, 173);
45  addPose(path, 26, 170);
46  addPose(path, 24, 166);
47  addPose(path, 27, 162);
48  addPose(path, 37, 161);
49  addPose(path, 45, 157);
50  addPose(path, 48, 152);
51  addPose(path, 46, 143);
52  addPose(path, 40, 140);
53  addPose(path, 34, 137);
54  addPose(path, 26, 134);
55  addPose(path, 24, 130);
56  addPose(path, 24, 125);
57  addPose(path, 28, 121);
58  addPose(path, 36, 118);
59  addPose(path, 46, 117);
60  addPose(path, 63, 121);
61  addPose(path, 76, 125);
62  addPose(path, 82, 120);
63  addPose(path, 86, 111);
64  addPose(path, 88, 103);
65  addPose(path, 90, 91);
66  addPose(path, 95, 87);
67  addPose(path, 107, 89);
68  addPose(path, 107, 104);
69  addPose(path, 106, 117);
70  addPose(path, 109, 129);
71  addPose(path, 119, 131);
72  addPose(path, 131, 131);
73  addPose(path, 139, 134);
74  addPose(path, 138, 143);
75  addPose(path, 131, 152);
76  addPose(path, 119, 154);
77  addPose(path, 111, 149);
78  addPose(path, 105, 143);
79  addPose(path, 91, 139);
80  addPose(path, 80, 142);
81  addPose(path, 81, 152);
82  addPose(path, 76, 163);
83  addPose(path, 67, 161);
84  addPose(path, 59, 149);
85  addPose(path, 63, 138);
86 
87  EXPECT_EQ(41U, compressPlan(path, 0.1).poses.size());
88  EXPECT_EQ(34U, compressPlan(path, 1.3).poses.size());
89  EXPECT_EQ(12U, compressPlan(path, 9.5).poses.size());
90  EXPECT_EQ(8U, compressPlan(path, 19.9).poses.size());
91 }
92 
93 int main(int argc, char** argv)
94 {
95  testing::InitGoogleTest(&argc, argv);
96  return RUN_ALL_TESTS();
97 }
void addPose(nav_2d_msgs::Path2D &path, double x, double y, double theta=0.0)
Convenience function to add a pose to a path in one line.
Definition: path_ops.cpp:184
int main(int argc, char **argv)
TEST(CompressTest, compress_test)
nav_2d_msgs::Path2D compressPlan(const nav_2d_msgs::Path2D &input_path, double epsilon=0.1)
Decrease the length of the plan by eliminating colinear points.
Definition: path_ops.cpp:176


nav_2d_utils
Author(s):
autogenerated on Sun Jan 10 2021 04:08:32