dynamic_reconfigure callback function not called

asked 2017-02-22 09:29:44 -0500

rosnovice12 gravatar image

I am using a simple dynamic_reconfigure server with a callback. The callback runs once when I launch the node but does not run after that when I change parameters using rqt. I have run the command rosrun dynamic_reconfigure dynparam list but I do not see any of the parameters that I use.

I am using to following code to start the server and callback:

 dynamic_reconfigure::Server<stereo_drivers::ExtrinsicsConfig> server;
 dynamic_reconfigure::Server<stereo_drivers::ExtrinsicsConfig>::CallbackType f;
 f = boost::bind(&extrinsicsCallback, _1, _2);
 server.setCallback(f);

Another issue is also that if I move the above code to the end of my main function, it does not seem to run even on the launch time. The following is my main function:

 int main(int argc, char* argv[])
 {
  //Ros initializations.
  ros::init(argc, argv, nodeName.str());
  //ros::NodeHandle n[numPorts];
  std::shared_ptr<ros::NodeHandle> nhPtr;
  nhPtr = std::make_shared<ros::NodeHandle>();

  std::shared_ptr<camera_info_manager::CameraInfoManager> cameraInfoManager;
  cameraInfoManager = std::make_shared<camera_info_manager::CameraInfoManager>(*nhPtr.get(), cameraName.str());     

 ///==================   Works here (only once at launch time) ========================
  dynamic_reconfigure::Server<stereo_drivers::ExtrinsicsConfig> server;
  dynamic_reconfigure::Server<stereo_drivers::ExtrinsicsConfig>::CallbackType f;
  f = boost::bind(&extrinsicsCallback, _1, _2);
  server.setCallback(f);
 ///========================================================================

  std::string calibPath;
  nhPtr->getParam(ros::this_node::getName()+"/calib_path", calibPath);
  if(!cameraInfoManager->loadCameraInfo(calibPath))
  {
      ROS_INFO("Camera info could not be loaded.");
  }       

  std::shared_ptr<image_transport::ImageTransport> it =
      std::make_shared<image_transport::ImageTransport>(*nhPtr.get());
  std::shared_ptr<image_transport::CameraPublisher> stereoPub = 
      std::make_shared<image_transport::CameraPublisher>
     //(it->advertiseCamera(ros::this_node::getNamespace()+"/image_raw", 10));
     (it->advertiseCamera("image_raw", 5));
  std::shared_ptr<ros::Publisher> timestampPublisher =
     std::make_shared<ros::Publisher>(nhPtr.get()->advertise<std_msgs::Int32MultiArray>("timestamp", 1));

  signal(SIGINT, stopSignalHandler);

  ImageBuilder<720, 487, 10> imageBuilder(stereoPub, cameraInfoManager, timestampPublisher);
  imageBuilder.buildImages();        

  ///================== Does not get invoked at all ===============================
  //dynamic_reconfigure::Server<stereo_drivers::ExtrinsicsConfig> server;
  //dynamic_reconfigure::Server<stereo_drivers::ExtrinsicsConfig>::CallbackType f;
  //f = boost::bind(&extrinsicsCallback, _1, _2);
  //server.setCallback(f);
  ///===================================================================

 ros::spin();
}

Hoping to get some help on this problem. Thanks

edit retag flag offensive close merge delete

Comments

Where's your cfg file?

jayess gravatar imagejayess ( 2017-03-26 02:31:31 -0500 )edit