-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simply creating a GeneralizedIterativeClosestPoint6D (gicp) object causes segmentation fault #2013
Comments
FWIW, I get the following output (my environment is the same):
|
Valgrind is a big help for memory related problems. I used it sometimes in the past for mem leaks, but I assume its functionalities should also be prepared for double free scenarios. |
|
|
I just made a stripped the GICP6D class to the bare minimum so I can compile the snippet.
I'm starting to think this is an issue with compilation flags. #define PCL_NO_PRECOMPILE
#include <pcl/registration/gicp.h>
namespace pcl
{
struct EIGEN_ALIGN16 _PointXYZLAB
{
PCL_ADD_POINT4D; // this adds the members x,y,z
union
{
struct
{
float L;
float a;
float b;
};
float data_lab[4];
};
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
/** \brief A custom point type for position and CIELAB color value */
struct PointXYZLAB : public _PointXYZLAB
{
inline PointXYZLAB ()
{
x = y = z = 0.0f; data[3] = 1.0f; // important for homogeneous coordinates
L = a = b = 0.0f; data_lab[3] = 0.0f;
}
};
}
// register the custom point type in PCL
POINT_CLOUD_REGISTER_POINT_STRUCT(pcl::_PointXYZLAB,
(float, x, x)
(float, y, y)
(float, z, z)
(float, L, L)
(float, a, a)
(float, b, b)
)
POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZLAB, pcl::_PointXYZLAB)
namespace pcl
{
class PCL_EXPORTS GeneralizedIterativeClosestPoint6D : public GeneralizedIterativeClosestPoint<PointXYZRGBA, PointXYZRGBA>
{
typedef PointXYZRGBA PointSource;
typedef PointXYZRGBA PointTarget;
/** \brief Holds the converted (LAB) data cloud. */
pcl::PointCloud<PointXYZLAB>::Ptr cloud_lab_;
/** \brief Holds the converted (LAB) model cloud. */
pcl::PointCloud<PointXYZLAB>::Ptr target_lab_;
/** \brief 6d-tree to search in model cloud. */
KdTreeFLANN<PointXYZLAB> target_tree_lab_;
/** \brief The color weight. */
float lab_weight_;
public:
/** \brief constructor.
*
* \param[in] lab_weight the color weight
*/
GeneralizedIterativeClosestPoint6D (float lab_weight = 0.032f)
: cloud_lab_ (new pcl::PointCloud<PointXYZLAB>)
, target_lab_ (new pcl::PointCloud<PointXYZLAB>)
, lab_weight_ (lab_weight)
{
// set rescale mask (leave x,y,z unchanged, scale L,a,b by lab_weight)
float alpha[6] = { 1.0, 1.0, 1.0, lab_weight_, lab_weight_, lab_weight_ };
point_rep_.setRescaleValues (alpha);
}
protected:
/** \brief Custom point representation to perform kdtree searches in more than 3 (i.e. in all 6) dimensions. */
class MyPointRepresentation : public PointRepresentation<PointXYZLAB>
{
using PointRepresentation<PointXYZLAB>::nr_dimensions_;
using PointRepresentation<PointXYZLAB>::trivial_;
public:
typedef boost::shared_ptr<MyPointRepresentation> Ptr;
typedef boost::shared_ptr<const MyPointRepresentation> ConstPtr;
MyPointRepresentation ()
{
nr_dimensions_ = 6;
trivial_ = false;
}
virtual
~MyPointRepresentation ()
{
}
inline Ptr
makeShared () const
{
return Ptr (new MyPointRepresentation (*this));
}
virtual void
copyToFloatArray (const PointXYZLAB &p, float * out) const
{
// copy all of the six values
out[0] = p.x;
out[1] = p.y;
out[2] = p.z;
out[3] = p.L;
out[4] = p.a;
out[5] = p.b;
}
};
/** \brief Enables 6d searches with kd-tree class using the color weight. */
MyPointRepresentation point_rep_;
};
} |
tldr: SSE definitions are not being properly exported anymore.
if I add
If I then compile with the same SSE definitions no more compiler error and not more segfaults
|
In preparation of #2100 merge, I decided to test this again. I can still reproduce this with current master and the code provided by @jasjuang, which is no surprise because it fails to call: add_definitions(${PCL_DEFINITIONS}) Adding this line to CMakeLists solves the problem for me. So I don't think this can be counted as a bug. That said, of course it's a bit of a friction, and we will remove it with #2100. |
Your Environment
Minimal code to Reproduce
CMakeLists
main.cpp
Current Behavior
Expected Behavior
Context
This problem is preventing me from using the GICP function, which I would like to improve my result by replacing the traditional ICP with GICP.
@MichaelKorn Thank you for adding GICP into PCL, could you help me solve this problem?
The text was updated successfully, but these errors were encountered: