forked from laboshinl/loam_velodyne
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Moved all class header files into include directory. * Moved Vector3, Angle and Twist class definitions from math_utils.h into own loam_types.h in include directory. * Added publish cloud message function to common.h to simplify publishing of cloud messages. * Made all point calculations / transformations in math_utils.h generic with respect to the pcl point type.
- Loading branch information
1 parent
f7457e7
commit aa9965d
Showing
19 changed files
with
250 additions
and
244 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
#ifndef LOAM_LOAM_TYPES_H | ||
#define LOAM_LOAM_TYPES_H | ||
|
||
|
||
#include <pcl/point_types.h> | ||
|
||
|
||
namespace loam { | ||
|
||
/** \brief Vector4f decorator for convenient handling. | ||
* | ||
*/ | ||
class Vector3 : public Eigen::Vector4f { | ||
public: | ||
Vector3(float x, float y, float z) | ||
: Eigen::Vector4f(x, y, z, 0) {} | ||
|
||
Vector3(void) | ||
: Eigen::Vector4f(0, 0, 0, 0) {} | ||
|
||
template<typename OtherDerived> | ||
Vector3(const Eigen::MatrixBase <OtherDerived> &other) | ||
: Eigen::Vector4f(other) {} | ||
|
||
Vector3(const pcl::PointXYZI &p) | ||
: Eigen::Vector4f(p.x, p.y, p.z, 0) {} | ||
|
||
template<typename OtherDerived> | ||
Vector3 &operator=(const Eigen::MatrixBase <OtherDerived> &rhs) { | ||
this->Eigen::Vector4f::operator=(rhs); | ||
return *this; | ||
} | ||
|
||
Vector3 &operator=(const pcl::PointXYZ &rhs) { | ||
x() = rhs.x; | ||
y() = rhs.y; | ||
z() = rhs.z; | ||
return *this; | ||
} | ||
|
||
Vector3 &operator=(const pcl::PointXYZI &rhs) { | ||
x() = rhs.x; | ||
y() = rhs.y; | ||
z() = rhs.z; | ||
return *this; | ||
} | ||
|
||
float x() const { return (*this)(0); } | ||
|
||
float y() const { return (*this)(1); } | ||
|
||
float z() const { return (*this)(2); } | ||
|
||
float &x() { return (*this)(0); } | ||
|
||
float &y() { return (*this)(1); } | ||
|
||
float &z() { return (*this)(2); } | ||
|
||
// easy conversion | ||
operator pcl::PointXYZI() { | ||
pcl::PointXYZI dst; | ||
dst.x = x(); | ||
dst.y = y(); | ||
dst.z = z(); | ||
dst.intensity = 0; | ||
return dst; | ||
} | ||
}; | ||
|
||
|
||
/** \brief Class for holding an angle. | ||
* | ||
* This class provides buffered access to sine and cosine values to the represented angular value. | ||
*/ | ||
class Angle { | ||
public: | ||
Angle() | ||
: _radian(0.0), | ||
_cos(1.0), | ||
_sin(0.0) {} | ||
|
||
Angle(float radValue) | ||
: _radian(radValue), | ||
_cos(std::cos(radValue)), | ||
_sin(std::sin(radValue)) {} | ||
|
||
Angle(const Angle &other) | ||
: _radian(other._radian), | ||
_cos(other._cos), | ||
_sin(other._sin) {} | ||
|
||
void operator=(const Angle &rhs) { | ||
_radian = (rhs._radian); | ||
_cos = (rhs._cos); | ||
_sin = (rhs._sin); | ||
} | ||
|
||
void operator+=(const float &radValue) { *this = (_radian + radValue); } | ||
|
||
void operator+=(const Angle &other) { *this = (_radian + other._radian); } | ||
|
||
void operator-=(const float &radValue) { *this = (_radian - radValue); } | ||
|
||
void operator-=(const Angle &other) { *this = (_radian - other._radian); } | ||
|
||
Angle operator-() const { | ||
Angle out; | ||
out._radian = -_radian; | ||
out._cos = _cos; | ||
out._sin = -(_sin); | ||
return out; | ||
} | ||
|
||
float rad() const { return _radian; } | ||
|
||
float deg() const { return _radian * 180 / M_PI; } | ||
|
||
float cos() const { return _cos; } | ||
|
||
float sin() const { return _sin; } | ||
|
||
private: | ||
float _radian; ///< angle value in radian | ||
float _cos; ///< cosine of the angle | ||
float _sin; ///< sine of the angle | ||
}; | ||
|
||
|
||
/** \brief Twist composed by three angles and a three-dimensional position. */ | ||
struct Twist { | ||
Angle rot_x; | ||
Angle rot_y; | ||
Angle rot_z; | ||
Vector3 pos; | ||
}; | ||
|
||
} // end namespace loam | ||
|
||
#endif //LOAM_LOAM_TYPES_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
add_library(loam | ||
math_utils.h | ||
CircularBuffer.h | ||
ScanRegistration.h | ||
ScanRegistration.cpp | ||
VelodyneScanRegistration.h | ||
VelodyneScanRegistration.cpp | ||
LaserOdometry.h | ||
LaserOdometry.cpp | ||
LaserMapping.h | ||
LaserMapping.cpp | ||
TransformMaintenance.h | ||
TransformMaintenance.cpp) | ||
target_link_libraries(loam ${catkin_LIBRARIES} ${PCL_LIBRARIES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.