- Aldebaran documentation |
- C++ Libraries |
- index

libalmath 2.8.7.4

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
occupancymapparams.h
Go to the documentation of this file.
1 #ifndef OCCUPANCYMAPPARAMS_H
2 #define OCCUPANCYMAPPARAMS_H
3
4 #include <almath/tools/almath.h>
5 #include <almath/api.h>
6
7 namespace AL {
8 namespace Math {
9
18 struct ALMATH_API Point2Di {
19 explicit Point2Di(int _x=0, int _y=0): x(_x), y(_y) {}
20 int x;
21 int y;
22 bool operator == (const Point2Di& other) const {
23 return (x == other.x && y == other.y);
24 }
25 };
26
35 struct ALMATH_API Pose2Di {
36 explicit Pose2Di(int _x=0, int _y=0, float _angle=0.0f)
37 : x(_x), y(_y), theta(_angle) {}
38 explicit Pose2Di(const Point2Di& pt, float _angle=0.0f)
39 : x(pt.x), y(pt.y), theta(_angle) {}
40
41 int x;
42 int y;
43 float theta;
44 bool operator == (const Pose2Di& other) const {
45 return (x == other.x && y == other.y && std::abs(theta - other.theta) < 1e-6f);
46 }
47 };
48
49 typedef std::vector<Pose2D> Pose2DVect;
50 typedef std::vector<Pose2Di> Pose2DiVect;
51
52 static inline int roundToInt(float x) {
53 if (x >= 0.0f) {
54 return static_cast<int>(x + 0.5f);
55 }
56 return static_cast<int>(x - 0.5f);
57 }
58
67 struct ALMATH_API OccupancyMapParams {
68 explicit OccupancyMapParams(int size, float metersPerPixel,
69 const Position2D &mapCenter, float obstacleThreshold = 0.25f);
70
76 void initOriginOffset(const Position2D &mapCenter);
77
78 static inline Point2Di getPixelFromOffsetAndScale(
79 const Math::Pose2D& pose,
80 float metersPerPixel,
81 const Math::Position2D& originOffset) {
82 const float kPixelPerMeter = 1.0f / metersPerPixel;
83
84 const float xx = (pose.x - originOffset.x) * kPixelPerMeter;
85 const int x = roundToInt(xx);
86
87 const float yy = -(pose.y - originOffset.y) * kPixelPerMeter;
88 const int y = roundToInt(yy);
89 return Point2Di(x, y);
90 }
91
97 Point2Di getPixelFromPose(const Pose2D& pose) const;
98
104 Point2Di getPixelFromPosition(const Position2D& position) const;
105
111 Pose2D getPoseFromPixel(const Pose2Di &pixel) const;
112
118 Position2D getPositionFromPixel(const Point2Di &pixel) const;
119
126 Point2Di getDeltaPixelFromDeltaPosition(const Position2D& position) const;
127
130 float getObstacleProbabilityThreshold() const;
131
133 int size;
135 float metersPerPixel;
137 Position2D originOffset;
139 float obstacleProbabilityThreshold;
140 };
141 } // Math
142 } // AL
143
144 #endif // OCCUPANCYMAPPARAMS_H
145
AL::Math::Pose2DiVect
std::vector< Pose2Di > Pose2DiVect
Definition: occupancymapparams.h:50
AL::Math::Point2Di::x
int x
Definition: occupancymapparams.h:20
AL::Math::Position2D
Create and play with a Position2D.
Definition: alposition2d.h:24
AL::Math::Pose2D::y
float y
Definition: alpose2d.h:30
almath.h
AL::Math::Point2Di::y
int y
Definition: occupancymapparams.h:21
AL::Math::OccupancyMapParams
Create a OccupancyMapParams. OccupancyMapParams are used used to define occupancy maps and to provide...
Definition: occupancymapparams.h:67
AL::Math::Pose2D::x
float x
Definition: alpose2d.h:28
AL::Math::Position2D::x
float x
Definition: alposition2d.h:27
AL::Math::OccupancyMapParams::obstacleProbabilityThreshold
float obstacleProbabilityThreshold
Maximum pixel value of an obstacle in the map
Definition: occupancymapparams.h:139
AL::Math::Pose2Di::theta
float theta
Definition: occupancymapparams.h:43
AL::Math::Pose2DVect
std::vector< Pose2D > Pose2DVect
Definition: occupancymapparams.h:49
AL::Math::Point2Di
Create a Point2Di. Point2Di are used on objects that deal with pixels only, and should not care about...
Definition: occupancymapparams.h:18
AL::Math::OccupancyMapParams::originOffset
Position2D originOffset
Metrical coordinate of the (0, 0) pixel.
Definition: occupancymapparams.h:137
AL::Math::Point2Di::Point2Di
Point2Di(int _x=0, int _y=0)
Definition: occupancymapparams.h:19
AL::Math::Pose2Di::y
int y
Definition: occupancymapparams.h:42
AL::Math::OccupancyMapParams::metersPerPixel
float metersPerPixel
Factor representing the metrical size of each pixel.
Definition: occupancymapparams.h:135
AL::Math::Pose2Di::x
int x
Definition: occupancymapparams.h:41
AL::Math::Pose2D
A pose in a 2-dimentional space.
Definition: alpose2d.h:26
AL::Math::OccupancyMapParams::getPixelFromOffsetAndScale
static Point2Di getPixelFromOffsetAndScale(const Math::Pose2D &pose, float metersPerPixel, const Math::Position2D &originOffset)
Definition: occupancymapparams.h:78
AL::Math::Pose2Di::Pose2Di
Pose2Di(int _x=0, int _y=0, float _angle=0.0f)
Definition: occupancymapparams.h:36
AL::Math::Pose2Di::Pose2Di
Pose2Di(const Point2Di &pt, float _angle=0.0f)
Definition: occupancymapparams.h:38
AL::Math::operator==
bool operator==(const BodyMass< T > &lhs, const BodyMass< T > &rhs)
Definition: bodymass.h:79
AL::Math::OccupancyMapParams::size
int size
Pixel size of the associated squared occupancy map.
Definition: occupancymapparams.h:133
AL::Math::Pose2Di
Create a Pose2Di. Pose2Di are used on objects that deal with pixels only, and should not care about m...
Definition: occupancymapparams.h:35
AL::Math::Position2D::y
float y
Definition: alposition2d.h:29