compress_test.cpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2018, Locus Robotics
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the copyright holder nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  */
00034 #include <gtest/gtest.h>
00035 #include <nav_2d_utils/path_ops.h>
00036 
00037 using nav_2d_utils::compressPlan;
00038 using nav_2d_utils::addPose;
00039 
00040 TEST(CompressTest, compress_test)
00041 {
00042   nav_2d_msgs::Path2D path;
00043   // Dataset borrowed from https://karthaus.nl/rdp/
00044   addPose(path, 24, 173);
00045   addPose(path, 26, 170);
00046   addPose(path, 24, 166);
00047   addPose(path, 27, 162);
00048   addPose(path, 37, 161);
00049   addPose(path, 45, 157);
00050   addPose(path, 48, 152);
00051   addPose(path, 46, 143);
00052   addPose(path, 40, 140);
00053   addPose(path, 34, 137);
00054   addPose(path, 26, 134);
00055   addPose(path, 24, 130);
00056   addPose(path, 24, 125);
00057   addPose(path, 28, 121);
00058   addPose(path, 36, 118);
00059   addPose(path, 46, 117);
00060   addPose(path, 63, 121);
00061   addPose(path, 76, 125);
00062   addPose(path, 82, 120);
00063   addPose(path, 86, 111);
00064   addPose(path, 88, 103);
00065   addPose(path, 90, 91);
00066   addPose(path, 95, 87);
00067   addPose(path, 107, 89);
00068   addPose(path, 107, 104);
00069   addPose(path, 106, 117);
00070   addPose(path, 109, 129);
00071   addPose(path, 119, 131);
00072   addPose(path, 131, 131);
00073   addPose(path, 139, 134);
00074   addPose(path, 138, 143);
00075   addPose(path, 131, 152);
00076   addPose(path, 119, 154);
00077   addPose(path, 111, 149);
00078   addPose(path, 105, 143);
00079   addPose(path, 91, 139);
00080   addPose(path, 80, 142);
00081   addPose(path, 81, 152);
00082   addPose(path, 76, 163);
00083   addPose(path, 67, 161);
00084   addPose(path, 59, 149);
00085   addPose(path, 63, 138);
00086 
00087   EXPECT_EQ(41U, compressPlan(path, 0.1).poses.size());
00088   EXPECT_EQ(34U, compressPlan(path, 1.3).poses.size());
00089   EXPECT_EQ(12U, compressPlan(path, 9.5).poses.size());
00090   EXPECT_EQ(8U, compressPlan(path, 19.9).poses.size());
00091 }
00092 
00093 int main(int argc, char** argv)
00094 {
00095   testing::InitGoogleTest(&argc, argv);
00096   return RUN_ALL_TESTS();
00097 }


nav_2d_utils
Author(s):
autogenerated on Wed Jun 26 2019 20:09:36