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

Subcriber able to switch between multiple callback function

asked 2015-03-19 14:43:20 -0600

215 gravatar image

I have a class which contains a 2 callback function, and based on a boolean it determines which one to use.. The problem is that the state of the boolean get sets in the constructor, and main kept spinning it. so the boolean gets reset..

How overcome this problem, they the callback function both retrieve images and based on the boolean perform different vision actions.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-03-20 02:42:56 -0600

The easiest way to do what you want is having a single subscriber callback and taking the decision which processing step to perform based on the boolean from within the callback.

Like so:

imageCallback(ImageConstPtr img)
{
  //Check the bool
  if (use_default_image_processing){
   defaultProcess(img);
  }else{
   someOtherProcessingStep(img)
  }
}
edit flag offensive delete link more

Comments

Where should i initialize it, and how / where should i change it?

215 gravatar image 215  ( 2015-03-20 03:02:55 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-03-19 14:43:20 -0600

Seen: 264 times

Last updated: Mar 20 '15