ROS2 wall_timer callback function with arguments
Hello, guys!
I am using ROS2 foxy and wondering if it is possible to create a wall_timer
with the callback function that contains some arguments?
I basically need this because I am trying to instantiate n
different wall_timers in a for loop
in a way that every timer has its own callback. Instead of having n
different callbacks (that I don't know how to properly specify in a for loop
), I thought it will be possible to have a single timer callback with the argument that will specify the timer number.
I tried to do it like this:
int callbackTimer(uint8_t timer_id){
}
int createWallTimer(uint8_t timer_id){
int ret = 0;
this->timer[1] = this->create_wall_timer(std::chrono::seconds(1),
std::bind(callbackTimer, this, timer_id));
}
However, when I try to build the code, the compiler says:
error: no matching function to call
When I remove the argument from the callbackTimer()
function, there are no compilation errors.
So, is it possible in ROS2 world to have a wall_timer callback function with arguments? If affirmative, what I am missing?
Thanks in advance for your time and efforts.
Sincerely,
Bojan.