GAMS  1.4.0
Epsilon.h
Go to the documentation of this file.
1 
55 #ifndef _GAMS_POSE_EPSILON_H_
56 #define _GAMS_POSE_EPSILON_H_
57 
58 #include <iostream>
59 #include <string>
60 
61 #include "gams/GamsExport.h"
62 #include "gams/pose/Position.h"
63 #include "gams/pose/Orientation.h"
64 
65 namespace gams { namespace pose {
66 
69 public:
72 virtual bool check_position(
73  const pose::Position &current,
74  const pose::Position &target) const = 0;
75 
76 virtual ~PositionBounds() = default;
77 };
78 
81 public:
84 virtual bool check_orientation(
85  const pose::Orientation &current,
86  const pose::Orientation &target) const = 0;
87 
88 virtual ~OrientationBounds() = default;
89 };
90 
94 public PositionBounds, public OrientationBounds {};
95 
102 private:
103 double dist_ = 0.1, radians_ = M_PI/16;
104 public:
107 
111 Epsilon(double dist)
112 : dist_(dist) {}
113 
118 Epsilon(double dist_tol, double radians_tol)
119 : dist_(dist_tol), radians_(radians_tol) {}
120 
127 //
129 template<typename AngleUnits>
130 Epsilon(double dist, double angle, AngleUnits u)
131 : dist_(dist), radians_(u.to_radians(angle)) {}
132 
134  const pose::Position &current,
135  const pose::Position &target) const override {
136 return current.distance_to(target) <= dist_;
137 }
138 
140  const pose::Orientation &current,
141  const pose::Orientation &target) const override {
142 return fabs(current.angle_to(target)) <= radians_;
143 }
144 };
145 
146 } }
147 
148 #endif // _GAMS_POSE_EPSILON_H_
#define GAMS_EXPORT
Definition: GamsExport.h:20
A simple bounds checker which tests whether the current position is within the given number of meters...
Definition: Epsilon.h:101
Epsilon(double dist)
Use default value for angle tolerance.
Definition: Epsilon.h:111
Epsilon()
Use default values for position and angle tolerance.
Definition: Epsilon.h:106
bool check_orientation(const pose::Orientation &current, const pose::Orientation &target) const override
Override to return whether the current orientation is within the expected bounds of target.
Definition: Epsilon.h:139
bool check_position(const pose::Position &current, const pose::Position &target) const override
Override to return whether the current position is within the expected bounds of target.
Definition: Epsilon.h:133
Epsilon(double dist, double angle, AngleUnits u)
Use specified tolerances, with custom angle units.
Definition: Epsilon.h:130
Epsilon(double dist_tol, double radians_tol)
Use specified tolerances.
Definition: Epsilon.h:118
double distance_to(const derived_type &target) const
Calculate distance from this Coordinate to a target.
Interface for defining a bounds checker for Orientations.
Definition: Epsilon.h:80
virtual bool check_orientation(const pose::Orientation &current, const pose::Orientation &target) const =0
Override to return whether the current orientation is within the expected bounds of target.
virtual ~OrientationBounds()=default
Interface for defining a bounds checker for Poses, a combination of position and orientation checking...
Definition: Epsilon.h:94
Interface for defining a bounds checker for Positions.
Definition: Epsilon.h:68
virtual bool check_position(const pose::Position &current, const pose::Position &target) const =0
Override to return whether the current position is within the expected bounds of target.
virtual ~PositionBounds()=default
Contains all GAMS-related tools, classes and code.
Copyright (c) 2015 Carnegie Mellon University.
Copyright (c) 2015-2018 Carnegie Mellon University.