ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
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
.
2 | No.2 Revision |
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
.
3 | No.3 Revision |
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
.