Skip to content

Commit

Permalink
Fix Eigen point alignment in a vector
Browse files Browse the repository at this point in the history
  • Loading branch information
niosus committed Nov 27, 2018
1 parent ed79668 commit 57ca59d
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 47 deletions.
67 changes: 37 additions & 30 deletions depth_clustering.sublime-project
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
{
"build_systems":
[
{
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"name": "Anaconda Python Builder",
"selector": "source.python",
"shell_cmd": "\"python\" -u \"$file\""
}
],
"folders":
[
{
"path": "."
}
],
"settings":
{
"ecc_common_flags":
[
"-I/usr/include",
"-I/usr/lib/clang/$clang_version/include",
"-I~/Code/catkin_ws/build/$project_name/src"
],
"ecc_flags_sources": [
{
"file": "CMakeLists.txt",
"prefix_paths": ["/opt/ros/kinetic", "~/Code/catkin_ws/devel"]
}
]
}
"build_systems":
[
{
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"name": "Anaconda Python Builder",
"selector": "source.python",
"shell_cmd": "\"python\" -u \"$file\""
}
],
"folders":
[
{
"path": "."
}
],
"settings":
{
"ecc_common_flags":
[
"-I/usr/include",
"-I/usr/lib/clang/$clang_version/include",
"-I~/Code/catkin_ws/build/$project_name/src"
],
"ecc_flags_sources":
[
{
"file": "CMakeLists.txt",
"prefix_paths":
[
"/opt/ros/kinetic",
"~/Code/catkin_ws/devel",
"/opt/ros/melodic"
]
}
],
"ecc_use_target_compiler_built_in_flags": false,
}
}
2 changes: 1 addition & 1 deletion src/projections/cloud_projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ RichPoint CloudProjection::UnprojectPoint(const cv::Mat& image, const int row,
}

void CloudProjection::CheckCloudAndStorage(
const std::vector<RichPoint>& points) {
const RichPoint::AlignedVector& points) {
if (this->_data.size() < 1) {
throw std::length_error("_data size is < 1");
}
Expand Down
14 changes: 7 additions & 7 deletions src/projections/cloud_projection.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CloudProjection {
*
* @param[in] points The points
*/
virtual void InitFromPoints(const std::vector<RichPoint>& points) = 0;
virtual void InitFromPoints(const RichPoint::AlignedVector& points) = 0;

/**
* @brief Polymorphic clone of a projection.
Expand Down Expand Up @@ -96,7 +96,7 @@ class CloudProjection {
*
* @param[in] points The points to check
*/
void CheckCloudAndStorage(const std::vector<RichPoint>& points);
void CheckCloudAndStorage(const RichPoint::AlignedVector& points);

/**
* @brief Unproject a point from depth image coordinate
Expand All @@ -111,11 +111,11 @@ class CloudProjection {
const int col) const;

/**
* @brief Set corrections for systematic error in a dataset (see
* notebooks in the repo)
*
* @param[in] corrections A vector of correction in depth for every beam.
*/
* @brief Set corrections for systematic error in a dataset (see
* notebooks in the repo)
*
* @param[in] corrections A vector of correction in depth for every beam.
*/
inline void SetCorrections(const std::vector<float>& corrections) {
_corrections = corrections;
}
Expand Down
4 changes: 1 addition & 3 deletions src/projections/ring_projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@

namespace depth_clustering {

using std::vector;

void RingProjection::InitFromPoints(const std::vector<RichPoint>& points) {
void RingProjection::InitFromPoints(const RichPoint::AlignedVector& points) {
fprintf(stderr, "Projecting cloud with %lu points\n", points.size());
time_utils::Timer timer;
this->CheckCloudAndStorage(points);
Expand Down
5 changes: 3 additions & 2 deletions src/projections/ring_projection.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

#include <vector>

#include "projections/projection_params.h"
#include "projections/cloud_projection.h"
#include "projections/projection_params.h"
#include "utils/cloud.h"
#include "utils/radians.h"

namespace depth_clustering {
Expand All @@ -39,7 +40,7 @@ class RingProjection : public CloudProjection {
*
* @param[in] cloud The cloud with laser ring information
*/
void InitFromPoints(const std::vector<RichPoint>& cloud) override;
void InitFromPoints(const RichPoint::AlignedVector& cloud) override;
CloudProjection::Ptr Clone() const override;
virtual ~RingProjection() {}

Expand Down
3 changes: 2 additions & 1 deletion src/projections/spherical_projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

namespace depth_clustering {

void SphericalProjection::InitFromPoints(const std::vector<RichPoint>& points) {
void SphericalProjection::InitFromPoints(
const RichPoint::AlignedVector& points) {
this->CheckCloudAndStorage(points);
for (size_t index = 0; index < points.size(); ++index) {
const auto& point = points[index];
Expand Down
3 changes: 2 additions & 1 deletion src/projections/spherical_projection.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "projections/cloud_projection.h"
#include "projections/projection_params.h"
#include "utils/cloud.h"

namespace depth_clustering {

Expand All @@ -38,7 +39,7 @@ class SphericalProjection : public CloudProjection {
*
* @param[in] points The points
*/
void InitFromPoints(const std::vector<RichPoint>& points) override;
void InitFromPoints(const RichPoint::AlignedVector& points) override;
typename CloudProjection::Ptr Clone() const override;
virtual ~SphericalProjection() {}
};
Expand Down
5 changes: 3 additions & 2 deletions src/utils/cloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define SRC_UTILS_CLOUD_H_

#include <Eigen/Core>
#include <Eigen/StdVector>

#if PCL_FOUND
#include <pcl/point_cloud.h>
Expand Down Expand Up @@ -53,7 +54,7 @@ class Cloud {

virtual ~Cloud() {}

inline const std::vector<RichPoint>& points() const { return _points; }
inline const RichPoint::AlignedVector& points() const { return _points; }

inline Pose& pose() { return _pose; }
inline const Pose& pose() const { return _pose; }
Expand Down Expand Up @@ -109,7 +110,7 @@ class Cloud {
#endif // PCL_FOUND

protected:
std::vector<RichPoint> _points = std::vector<RichPoint>();
RichPoint::AlignedVector _points;

Pose _pose;
Pose _sensor_pose;
Expand Down
5 changes: 5 additions & 0 deletions src/utils/rich_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define SRC_UTILS_RICH_POINT_H_

#include <Eigen/Core>
#include <vector>

namespace depth_clustering {

Expand All @@ -26,6 +27,10 @@ namespace depth_clustering {
class RichPoint {
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW

using AlignedVector =
std::vector<RichPoint, Eigen::aligned_allocator<RichPoint>>;

RichPoint() {}
explicit RichPoint(float x, float y, float z) : _point(x, y, z) {}
explicit RichPoint(float x, float y, float z, uint16_t ring)
Expand Down

0 comments on commit 57ca59d

Please sign in to comment.