test_on_motion.cpp
Go to the documentation of this file.
1 // Copyright 2024 Ekumen, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <gtest/gtest.h>
16 
17 #include <sophus/se2.hpp>
18 #include <sophus/so2.hpp>
19 
21 
22 namespace {
23 
24 TEST(OnMotionPolicy, TriggerOnMotion) {
25  auto policy = beluga::policies::on_motion(0.1, 0.05);
26  const Sophus::SE2d pose1(Sophus::SO2d(0.2), Eigen::Vector2d(1.0, 2.0));
27  const Sophus::SE2d pose2(Sophus::SO2d(0.25), Eigen::Vector2d(1.2, 2.2));
28 
29  ASSERT_TRUE(policy(pose1)); // First pose triggers the policy
30  ASSERT_FALSE(policy(pose1)); // Same pose should not trigger again
31  ASSERT_TRUE(policy(pose2)); // Second pose triggers the policy
32 }
33 
34 TEST(OnMotionPolicy, NoTriggerWithoutMotion) {
35  auto policy = beluga::policies::on_motion(0.1, 0.05);
36  const Sophus::SE2d pose1(Sophus::SO2d(0.1), Eigen::Vector2d(1.0, 2.0));
37  const Sophus::SE2d pose2(Sophus::SO2d(0.1), Eigen::Vector2d(1.05, 2.05));
38 
39  ASSERT_TRUE(policy(pose1)); // First pose triggers the policy
40  ASSERT_FALSE(policy(pose2)); // Small motion should not trigger the policy
41 }
42 
43 } // namespace
Sophus::SO2
on_motion.hpp
Defines a policy for triggering an action based on motion.
se2.hpp
Sophus::SE2
so2.hpp
beluga::policies::on_motion
constexpr detail::on_motion_fn on_motion
Policy that triggers an action based on motion.
Definition: on_motion.hpp:121
beluga::TEST
TEST(Bresenham, MultiPassGuarantee)
Definition: test_bresenham.cpp:27


beluga
Author(s):
autogenerated on Tue Jul 16 2024 02:59:53