dock_candidate.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015 Fetch Robotics Inc.
3  * Author: Michael Ferguson, Sriramvarun Nidamarthy
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef FETCH_AUTO_DOCK_DOCK_CANDIDATE_H
20 #define FETCH_AUTO_DOCK_DOCK_CANDIDATE_H
21 
22 #include <geometry_msgs/Point.h>
23 
24 #include <boost/shared_ptr.hpp>
25 #include <vector>
26 
31 {
32  std::vector<geometry_msgs::Point> points;
33  double dist; // distance from initial/previous pose
34 
36  double width()
37  {
38  // If there are no points then there is no width.
39  if (points.empty())
40  {
41  return 0;
42  }
43 
44  geometry_msgs::Point& pt1 = points.front();
45  geometry_msgs::Point& pt2 = points.back();
46  return (sqrt(pow((pt1.x - pt2.x), 2) + pow((pt1.y - pt2.y), 2)));
47  }
48 
53  bool valid(bool dock_found)
54  {
55  // If there are no points this cannot be valid.
56  if (points.empty())
57  {
58  return false;
59  }
60 
61  // Check overall size
62  if (width() > 0.5 || width() < 0.25)
63  return false;
64 
65  // If dock is found, we want to avoid large jumps
66  if (dock_found)
67  {
68  // dist is squared
69  return dist < (0.25*0.25);
70  }
71 
72  // Not too far off from initial pose
73  return dist < 1.0;
74  }
75 };
77 
79 {
81  {
82  return (a->dist > b->dist);
83  }
84 };
85 
86 #endif // FETCH_AUTO_DOCK_DOCK_CANDIDATE_H
bool valid(bool dock_found)
Determine if this candidate meets our basic criteria.
std::vector< geometry_msgs::Point > points
bool operator()(DockCandidatePtr a, DockCandidatePtr b)
double width()
Get the width of this segment.
INLINE Rall1d< T, V, S > sqrt(const Rall1d< T, V, S > &arg)
INLINE Rall1d< T, V, S > pow(const Rall1d< T, V, S > &arg, double m)
A cluster which is a candidate for a dock.
boost::shared_ptr< DockCandidate > DockCandidatePtr


caster_app
Author(s): Ye Tian
autogenerated on Wed Dec 18 2019 03:34:44