test_first_order_filter.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2018 The urg_stamped Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #include <gtest/gtest.h>
00018 
00019 #include <cmath>
00020 
00021 #include <first_order_filter.h>
00022 
00023 TEST(FirstOrderFilter, PassThrough)
00024 {
00025   FirstOrderFilter<double> flt;
00026 
00027   ASSERT_EQ(flt.update(0.0), 0.0);
00028   ASSERT_EQ(flt.update(1.0), 1.0);
00029   ASSERT_EQ(flt.update(2.0), 2.0);
00030 }
00031 
00032 TEST(FirstOrderFilter, LPF)
00033 {
00034   FirstOrderLPF<double> flt(100);
00035 
00036   ASSERT_EQ(flt.update(0.0), 0.0);
00037   for (size_t i = 0; i < 100 - 1; ++i)
00038     flt.update(1.0);
00039   ASSERT_NEAR(flt.update(1.0), 1.0 - 1.0 / std::exp(1), 1e-2);
00040 }
00041 
00042 TEST(FirstOrderFilter, HPF)
00043 {
00044   FirstOrderHPF<double> flt(100);
00045 
00046   ASSERT_EQ(flt.update(0.0), 0.0);
00047   for (size_t i = 0; i < 100 - 2; ++i)
00048     flt.update(1.0);
00049   ASSERT_NEAR(flt.update(1.0), 1.0 / std::exp(1), 1e-2);
00050 }
00051 
00052 int main(int argc, char **argv)
00053 {
00054   testing::InitGoogleTest(&argc, argv);
00055 
00056   return RUN_ALL_TESTS();
00057 }


urg_stamped
Author(s): Atsushi Watanabe
autogenerated on Thu Jun 6 2019 18:59:51