[ros-users] no matching function for call to ‘ros::NodeHandle::subscribe...

Tully Foote tfoote at willowgarage.com
Mon Oct 18 20:53:12 UTC 2010


Martin,
The message_filters::Subscriber takes constructor arguments for the
subscription and does not accept assignment from a generic subscription
object.  Then you have to register the callback.  See
http://www.ros.org/wiki/message_filters

Tully

PS if you want to call a class method as your callback you will also need to
pass the object as well as the method.  This should be helpful for that
http://www.ros.org/wiki/roscpp_tutorials/Tutorials/UsingClassMethodsAsCallbacksit's
not the same interface but follows the same conventions.

On Mon, Oct 18, 2010 at 1:02 PM, Martin, L <kollaps2001 at hotmail.com> wrote:

>
> Hi,
>
> I am a ROS newbie  and I was trying to compile the following code:
>
> class CloudToPCDFile{
> public:
>  ros::NodeHandle n_;
>  message_filters::Subscriber<sensor_msgs::PointCloud> laser_sub_;
>  CloudToPCDFile(ros::NodeHandle n) :
>         n_(n)
>    {
>          laser_sub_=n_.subscribe("/ptu_46/assembled_cloud", 100,
> scanCallback);
>    }
>
>  void scanCallback (const sensor_msgs::PointCloudConstPtr& scan_in)
>  {
>          //Dummy
>  }
> };
>
> int main(int argc, char** argv)
> {
>  ros::init(argc, argv, "cloud_to_pcd_file");
>  ros::NodeHandle n;
>  CloudToPCDFile lstopc(n);
>  ros::spin();
>  return 0;
> }
>
>
> however, I unfortunately get the following error:
>  error: no matching function for call to ‘ros::NodeHandle::subscribe(const
> char [24], int, <unresolved overloaded function type>)’
>
> any idea what I could be doing wrong?
>
> many thanks!
>
> --
> View this message in context:
> http://ros-users.122217.n3.nabble.com/no-matching-function-for-call-to-ros-NodeHandle-subscribe-tp1727890p1727890.html
> Sent from the ROS-Users mailing list archive at Nabble.com.
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>



-- 
Tully Foote
Systems Engineer
Willow Garage, Inc.
tfoote at willowgarage.com
(650) 475-2827
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20101018/3b2e9b8d/attachment-0003.html>


More information about the ros-users mailing list