Ask Your Question
0

ERROR: Advertise a service already advertised in this node

asked 2016-11-16 23:06:19 -0600

Pototo gravatar image

updated 2016-11-17 16:36:54 -0600

Folks,

I am subscribing to a compressed image published (or republished) by image_proc (it takes my rgb_raw, and publishes rectified rgb and mono images, including compressed versions). But when I subscribe to the compressed images (rgb or mono), I get these messages:

[ERROR] [1479358743.735774954]: Tried to advertise a service that is already advertised in this node [/v_control_node/compressed/set_parameters]

This is my subscriber:

camera_track_sub_ = it_.subscribeCamera("/camera/rgb/image_rect", 2,
&MyNodeClass::ImageCb, this,
image_transport::TransportHints("compressed"));
// I assume TransportHints converts "/camera/rgb/image_rect" to "/camera/rgb/image_rect/compressed"

I have ROS indigo, and Ubuntu 14.04.

edit retag flag offensive close merge delete

Comments

How do you subscribe?

NEngelhard gravatar imageNEngelhard ( 2016-11-17 12:43:18 -0600 )edit

#include <sensor_msgs compressedimage.h="">
// inside my class
ros::NodeHandle nh_;
image_transport::ImageTransport it_;
image_transport::CameraSubscriber camera_track_sub_; /**< subscriber for the camera info and the image info. */

Pototo gravatar imagePototo ( 2016-11-17 13:22:12 -0600 )edit

// Then, on my class as well
public:
MyNodeClass(int32_t id)
: it_(nh_), id_(id)

Pototo gravatar imagePototo ( 2016-11-17 13:23:15 -0600 )edit

Please edit your question. And you only show the declaration for the subscriber, but no use of it.

NEngelhard gravatar imageNEngelhard ( 2016-11-17 13:24:37 -0600 )edit

camera_track_sub_ = it_.subscribeCamera("/camera/rgb/image_rect", 2,
&MyNodeClass::ImageCb, this,
image_transport::TransportHints("compressed"));
// I assume TransportHints converts "/camera/rgb/image_rect" to "/camera/rgb/image_rect/compressed"

Pototo gravatar imagePototo ( 2016-11-17 13:26:16 -0600 )edit

After the subscriber is enabled, the callback grabs that rectified mono image message, cv_bridge converts it into sensor_msgs::image_encodings::MONO8, then I to my analysis. I don't re-publish the image at all.

Pototo gravatar imagePototo ( 2016-11-17 14:10:11 -0600 )edit

Can you please add the code to the question? It's hard to read it in several parts in the comments.

NEngelhard gravatar imageNEngelhard ( 2016-11-17 14:29:02 -0600 )edit

I found the error problem. See answer below. Print Statements helped me see it

Pototo gravatar imagePototo ( 2016-11-17 16:22:20 -0600 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2016-11-17 16:34:35 -0600

Pototo gravatar image

updated 2016-11-17 16:39:36 -0600

The problem is that I shut down my subscriber when I don't need it, and re-subscribe again when I need it. But if the subscriber is already initialized, then I get the error if I call it again. I added a boolean to check if it is already initialized (if you know a image_transport method that checks for this, or how to access the private variable impl_, then let me know):

if (image_analyze == CMDTYPE_START)
{
  /* use boolean to avoid re-initializing subscriber. */
  if (already_started_ == false)
  {
    already_started_ = true;
    camera_track_sub_ = it_.subscribeCamera("/camera/rgb/image_rect", 2,
    &MyNodeClass::ImageCb, this,
    image_transport::TransportHints("compressed"));
  }
}
else if (image_analyze == CMDTYPE_STOP)
{
  already_started_ = false;
  /// shutdown already checks if the subscriber is valid.
  /// so, no need to check if it has already been shutdown
  camera_track_sub_.shutdown();
}
edit flag offensive delete link more

Comments

How come this not happened for the non-rgb-compressed topics (such as regular rgb, compressedDepth, and non-image related topics)? I guess they forgot to add code to check rgb compressed subscribers?

Pototo gravatar imagePototo ( 2016-11-17 16:38:21 -0600 )edit

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 2016-11-16 23:06:19 -0600

Seen: 1,978 times

Last updated: Nov 17 '16