test_timestamp_moving_average.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018-2021 The urg_stamped Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <gtest/gtest.h>
18 
20 
21 namespace urg_stamped
22 {
24 {
26  for (double t = 10.0; t < 11.0; t += 0.1)
27  {
28  ASSERT_EQ(ma.update(ros::Time(t)), ros::Time(t));
29  }
30  ma.reset();
31  for (double t = 12.0; t < 13.0; t += 0.1)
32  {
33  ASSERT_EQ(ma.update(ros::Time(t)), ros::Time(t));
34  }
35 }
36 
38 {
40  ASSERT_EQ(ma.update(ros::Time(10.000)), ros::Time(10.000));
41  ASSERT_EQ(ma.update(ros::Time(10.100)), ros::Time(10.100));
42  ASSERT_EQ(ma.update(ros::Time(10.203)), ros::Time(10.201));
43  ASSERT_EQ(ma.update(ros::Time(10.300)), ros::Time(10.301));
44  ASSERT_EQ(ma.update(ros::Time(10.400)), ros::Time(10.401));
45  ASSERT_EQ(ma.update(ros::Time(10.500)), ros::Time(10.500));
46 }
47 
49 {
51  for (double t = 10.0; t < 11.0; t += 0.1)
52  {
53  ASSERT_EQ(ma.update(ros::Time(t)), ros::Time(t));
54  }
55  // skip 0.5 sec.
56  for (double t = 11.5; t < 12.0; t += 0.1)
57  {
58  ASSERT_EQ(ma.update(ros::Time(t)), ros::Time(t));
59  }
60 }
61 } // namespace urg_stamped
62 
63 int main(int argc, char** argv)
64 {
65  testing::InitGoogleTest(&argc, argv);
66 
67  return RUN_ALL_TESTS();
68 }
ros::Time update(const ros::Time &stamp)
TEST(DeviceTimeOriginTest, testEstimateOriginByAverage)
int main(int argc, char **argv)


urg_stamped
Author(s): Atsushi Watanabe
autogenerated on Tue May 11 2021 02:14:05