Closed AndreasAZiegler closed 5 years ago
For anyone that ends up here with a similar issue:
Change:
timeSynchronizer_.registerCallback(
std::bind(&PolygonExplorerNode::subscriberCallback, this,
std::placeholders::_1, std::placeholders::_2));
To:
timeSynchronizer_.registerCallback(
&PolygonExplorerNode::subscriberCallback, this);
Try this :
class SubscribeAndPublish
{
public:
SubscribeAndPublish():sync2(image_sub,image_sub2,500){
//https://gist.github.com/tdenewiler/e2172f628e49ab633ef2786207793336
image_sub.subscribe(n, "/camera/color/image_raw", 1);
image_sub2.subscribe(n, "/camera/aligned_depth_to_color/image_raw", 1);
sync2.registerCallback(boost::bind(&SubscribeAndPublish::callback,this, _1, _2));
odom_pub = n.advertise
The member initialisation doesn't work for me for message_filters::Subscriber
.
This is my code-
class MultiSubscriber : public rclcpp::Node
{
public:
message_filters::Subscriber<sensor_msgs::msg::Image> image_sub_;
message_filters::Subscriber<sensor_msgs::msg::Image> disparity_sub_;
MultiSubscriber(const std::string& name)
: Node(name),
image_sub_(message_filters::Subscriber<sensor_msgs::msg::Image>(this, "image_color_topic")),
disparity_sub_(message_filters::Subscriber<sensor_msgs::msg::Image>(this, "image_disparity_topic"))
{
typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::msg::Image, sensor_msgs::msg::Image> approximate_policy;
message_filters::Synchronizer<approximate_policy>syncApproximate(approximate_policy(10), image_sub_, disparity_sub_);
syncApproximate.registerCallback(&MultSubscriber::disparityCb,this);
}
private:
void disparityCb(const sensor_msgs::msg::Image::SharedPtr disparity_msg, const sensor_msgs::msg::Image::SharedPtr color_msg){
//dosomething
}
};
I get this error -
/home/hsharma/Documents/internship/ws/ros2_ws/src/stereo_ground_surface/obstacle_detection/src/multisense_subscriber.cpp: In constructor ‘MultiSenseSubscriber::MultiSenseSubscriber(const string&)’:
/home/hsharma/Documents/internship/ws/ros2_ws/src/stereo_ground_surface/obstacle_detection/src/multisense_subscriber.cpp:68:120: error: use of deleted function ‘message_filters::Subscriber<sensor_msgs::msg::Image_<std::allocator<void> > >::Subscriber(const message_filters::Subscriber<sensor_msgs::msg::Image_<std::allocator<void> > >&)’
: Node(name), image_sub_(message_filters::Subscriber<sensor_msgs::msg::Image>(this, "/multisense/left/image_color"))
^
In file included from /home/hsharma/Documents/internship/ws/ros2_ws/src/stereo_ground_surface/obstacle_detection/src/multisense_subscriber.cpp:10:0:
/opt/ros/eloquent/include/message_filters/subscriber.h:102:7: note: ‘message_filters::Subscriber<sensor_msgs::msg::Image_<std::allocator<void> > >::Subscriber(const message_filters::Subscriber<sensor_msgs::msg::Image_<std::allocator<void> > >&)’ is implicitly deleted because the default definition would be ill-formed:
class Subscriber : public SubscriberBase, public SimpleFilter<M>
^~~~~~~~~~
/opt/ros/eloquent/include/message_filters/subscriber.h:102:7: error: use of deleted function ‘message_filters::SimpleFilter<sensor_msgs::msg::Image_<std::allocator<void> > >::SimpleFilter(const message_filters::SimpleFilter<sensor_msgs::msg::Image_<std::allocator<void> > >&)’
In file included from /opt/ros/eloquent/include/message_filters/subscriber.h:41:0,
from /home/hsharma/Documents/internship/ws/ros2_ws/src/stereo_ground_surface/obstacle_detection/src/multisense_subscriber.cpp:10:
/opt/ros/eloquent/include/message_filters/simple_filter.h:57:7: note: ‘message_filters::SimpleFilter<sensor_msgs::msg::Image_<std::allocator<void> > >::SimpleFilter(const message_filters::SimpleFilter<sensor_msgs::msg::Image_<std::allocator<void> > >&)’ is implicitly deleted because the default definition would be ill-formed:
class SimpleFilter : public noncopyable
^~~~~~~~~~~~
/opt/ros/eloquent/include/message_filters/simple_filter.h:57:7: error: use of deleted function ‘message_filters::noncopyable::noncopyable(const message_filters::noncopyable&)’
In file included from /opt/ros/eloquent/include/message_filters/subscriber.h:40:0,
from /home/hsharma/Documents/internship/ws/ros2_ws/src/stereo_ground_surface/obstacle_detection/src/multisense_subscriber.cpp:10:
/opt/ros/eloquent/include/message_filters/connection.h:51:3: note: declared here
noncopyable( const noncopyable& ) = delete;
^~~~~~~~~~~
In file included from /opt/ros/eloquent/include/message_filters/subscriber.h:41:0,
from /home/hsharma/Documents/internship/ws/ros2_ws/src/stereo_ground_surface/obstacle_detection/src/multisense_subscriber.cpp:10:
/opt/ros/eloquent/include/message_filters/simple_filter.h:57:7: error: use of deleted function ‘message_filters::Signal1<sensor_msgs::msg::Image_<std::allocator<void> > >::Signal1(const message_filters::Signal1<sensor_msgs::msg::Image_<std::allocator<void> > >&)’
class SimpleFilter : public noncopyable
^~~~~~~~~~~~
In file included from /opt/ros/eloquent/include/message_filters/simple_filter.h:43:0,
from /opt/ros/eloquent/include/message_filters/subscriber.h:41,
from /home/hsharma/Documents/internship/ws/ros2_ws/src/stereo_ground_surface/obstacle_detection/src/multisense_subscriber.cpp:10:
/opt/ros/eloquent/include/message_filters/signal1.h:82:7: note: ‘message_filters::Signal1<sensor_msgs::msg::Image_<std::allocator<void> > >::Signal1(const message_filters::Signal1<sensor_msgs::msg::Image_<std::allocator<void> > >&)’ is implicitly deleted because the default definition would be ill-formed:
class Signal1
^~~~~~~
/opt/ros/eloquent/include/message_filters/signal1.h:82:7: error: use of deleted function ‘std::mutex::mutex(const std::mutex&)’
In file included from /usr/include/c++/7/mutex:43:0,
from /usr/include/c++/7/future:38,
from /opt/ros/eloquent/include/rclcpp/executors.hpp:18,
from /opt/ros/eloquent/include/rclcpp/rclcpp.hpp:145,
from /home/hsharma/Documents/internship/ws/ros2_ws/src/stereo_ground_surface/obstacle_detection/src/multisense_subscriber.cpp:2:
/usr/include/c++/7/bits/std_mutex.h:97:5: note: declared here
mutex(const mutex&) = delete;
The member initialisation doesn't work for me for
message_filters::Subscriber
.
I'll suggest you open up a new issue, otherwise this will probably get lost.
If someone gets stuck on this, someone answered my question on ROS answers - https://answers.ros.org/question/359614/ros2-message-filters-in-a-class-initializing-message_filterssubscriber-object/
I try to get a time_synchronizer running with an Odometry and a LaserScan topic. The example provided in the README uses subscribers as normal function variables whereas in my case the subscriber are a class member variable.
My header
My implementation
When I try to compile it, I get the following errors: