Ask Your Question
0

Passing a parameter to a ROS Timer callback

asked 2012-08-14 02:21:47 -0500

Ugo gravatar image

I'm trying to pass a parameter to a ROS Timer callback using boost bind as I'd have done it for a subscriber callback but it's not working for me.

Here's the relevant part of the code.

MyClass::MyClass()
{
    int my_arg = 0;
    node.createTimer(ros.Duration(1.0),
                     boost::bind(&MyClass::callback, this, _1, _2, my_arg),
                     true); //for oneshot
}

void MyClass::callback(int arg)
{
    ROS_ERROR_STREAM("callback: " << arg);
}

But this is not compiling:

/usr/include/boost/bind/bind.hpp:69:37: error: ‘void (MyClass::*)(int)’ is not a class, struct, or union type

Any idea?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2012-08-14 02:37:05 -0500

dornhege gravatar image

The bind call should match the function signature. You'll have to remove the _1, _2 part from the bind call.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2012-08-14 02:21:47 -0500

Seen: 1,514 times

Last updated: Aug 14 '12