geometry_tools_tests.cpp
Go to the documentation of this file.
1 #include "ros/ros.h"
4 #include "boost/foreach.hpp"
5 
6 #include <gtest/gtest.h>
7 
8 class PointInPolygonTest : public::testing::Test{
9 protected:
10  virtual void SetUp(){
11  //make upright hourglass polygon
12  geometry_msgs::Point32 point;
13  point.x = -1; point.y = 1;
14  polygon_.points.push_back(point);
15  point.x = 1; point.y = 1;
16  polygon_.points.push_back(point);
17  point.x = -1; point.y = -1;
18  polygon_.points.push_back(point);
19  point.x = 1; point.y = -1;
20  polygon_.points.push_back(point);
21  }
22  geometry_msgs::Polygon polygon_;
23 };
24 
26  geometry_msgs::Point point;
27  point.x = 0.5; point.y = 0;
28  ASSERT_FALSE(frontier_exploration::pointInPolygon(point, polygon_));
29  point.x = -0.5; point.y = 0;
30  ASSERT_FALSE(frontier_exploration::pointInPolygon(point, polygon_));
31  point.x = 0; point.y = 1.1;
32  ASSERT_FALSE(frontier_exploration::pointInPolygon(point, polygon_));
33  point.x = 0; point.y = -1.1;
34  ASSERT_FALSE(frontier_exploration::pointInPolygon(point, polygon_));
35 }
36 
38  geometry_msgs::Point point;
39  point.x = 0; point.y = 0.5;
41  point.x = 0; point.y = 0.5;
43 }
44 
45 TEST(PointsAdjacentTest, different)
46 {
47  geometry_msgs::Point a, b;
48  a.x = 1;
49  ASSERT_FALSE(frontier_exploration::pointsNearby(a,b,0));
50  ASSERT_FALSE(frontier_exploration::pointsNearby(a,b,0.1));
51  ASSERT_TRUE(frontier_exploration::pointsNearby(a,b,1));
52 }
53 
54 TEST(PointsAdjacentTest, identical)
55 {
56  geometry_msgs::Point a, b;
57  a.x = 1;
58  b.x = 1;
59  ASSERT_TRUE(frontier_exploration::pointsNearby(a,b,0));
60  ASSERT_TRUE(frontier_exploration::pointsNearby(a,b,0.1));
61  ASSERT_TRUE(frontier_exploration::pointsNearby(a,b,1));
62 }
63 
64 int main(int argc, char **argv){
65  testing::InitGoogleTest(&argc, argv);
66  return RUN_ALL_TESTS();
67 }
TEST(PointsAdjacentTest, different)
bool pointsNearby(const T &one, const S &two, const double &proximity)
Evaluate whether two points are approximately adjacent, within a specified proximity distance...
int main(int argc, char **argv)
geometry_msgs::Polygon polygon_
TEST_F(PointInPolygonTest, outside)
bool pointInPolygon(const T &point, const geometry_msgs::Polygon &polygon)
Evaluate if point is inside area defined by polygon. Undefined behaviour for points on line...


frontier_exploration
Author(s): Paul Bovbel
autogenerated on Mon Jun 10 2019 13:25:00