ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
For reference: https://stackoverflow.com/questions/46662748/building-error-when-declare-tf2-rosbuffer-in-class
2 | No.2 Revision |
For reference: https://stackoverflow.com/questions/46662748/building-error-when-declare-tf2-rosbuffer-in-class
From tf2_ros::Buffer
header, it inherits from BufferCore, which contains a boost::mutex(among other things - there could more than 1 non-copyable attribute) which is not copy-constructible. That makes tf2_ros::Buffer
not copy-constructible. Since test_class do not define a copy-constructor and contains a non-copyable attribute, the compiler cannot generate a copy constructor and fails to compile when you try to call a copy constructor.
So, the class need a copy constructor to do the class initialization : test_class amf = test_class();
If I replace this code line with test_class amf;
it works. Of course it will be necessary to remove the operation of the user-defined class constructor. An alternative way is to define a copy constructor (even an empty constructor) like: test_class(const test_class& right_side)
. This also solve the problem. It seems that realizing tf2_ros::Buffer
not copy-constructibal is the key to solve this problem.