How to fix ros::ConflictingSubscriptionException?

asked 2017-06-13 12:08:01 -0600

alexandru.lesi gravatar image

Hi,

I'm trying to run a node that keeps dying as the following error occurs:

terminate called after throwing an instance of 'ros::ConflictingSubscriptionException'
what():  Tried to subscribe to a topic with the same name but different md5sum as a topic that was already subscribed [sensor_msgs/CameraInfo/c9a58c1b0b154e0e6da7578cb991d214 vs. sensor_msgs/Image/060021388200f6f0f447d0fcd9c64743]

There is only one subscriber within this node itself, which I just need to get the 'CameraInfoConstPtr'. A different node I'm using is subscribed to the image of the camera, which is how I suspect the error occurs. The camera is a Kinect which is run through openni_camera. If I try openni2_camera the Kinect won't start correctly (i.e. expected topics don't show up in the rostopic list). How can I solve this issue?

Here's a code snippet. I only need the camera info to set up a pinhole camera model:

image_geometry::PinholeCameraModel model;
sensor_msgs::CameraInfoConstPtr ptr;
bool set = false;

void imageCallback2(const sensor_msgs::ImageConstPtr& msg, const sensor_msgs::CameraInfoConstPtr& nptr){
    ROS_INFO("IN");
    ptr = nptr;
    set = true;
}

int main(int argc, char **argv)
{
  ros::init(argc, argv, "get_ray");
  ros::NodeHandle nh;
  image_transport::ImageTransport it(nh);
  image_transport::CameraSubscriber csub = it.subscribeCamera("/rgb", 1, imageCallback2);
  ros::spin();

  return 0;
}
edit retag flag offensive close merge delete