ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

Right, you need to use boost::bind. Try:

ros::Subscriber sub = n.subscribe("topic-name", 1000, 
    boost::bind(writeOut, _1, cref(sound)));

Note that the call to cref is necessary because you want to pass a const reference instead of passing sound by value, i.e. copying it. If you want a normal reference, not a const reference, use ref.

Right, you need to use boost::bind. Try:

ros::Subscriber sub = n.subscribe("topic-name", 1000, 
    boost::bind(writeOut, _1, cref(sound)));
boost::cref(sound)));

Note that the call to cref is necessary because you want to pass a const reference instead of passing sound by value, i.e. copying it. If you want a normal reference, not a const reference, use ref.

Right, you need to use boost::bind. Try:

ros::Subscriber sub = n.subscribe("topic-name", 1000, 
    boost::bind(writeOut, _1, boost::cref(sound)));

Note that the call to cref is necessary because you want to pass a const reference instead of passing sound by value, i.e. copying it. If you want a normal reference, not a const reference, use ref.

Edit: I just updated my answer to explicitly qualify the namespace of cref (it should be in namespace boost). You need to include boost/ref.hpp.