Ask Your Question
0

ERROR: Advertise a service already advertised in this node

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

Pototo gravatar image

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

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 image NEngelhard  ( 2016-11-17 12:43:18 -0500 )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 image Pototo  ( 2016-11-17 13:22:12 -0500 )edit

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

Pototo gravatar image Pototo  ( 2016-11-17 13:23:15 -0500 )edit

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

NEngelhard gravatar image NEngelhard  ( 2016-11-17 13:24:37 -0500 )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 image Pototo  ( 2016-11-17 13:26:16 -0500 )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 image Pototo  ( 2016-11-17 14:10:11 -0500 )edit

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

NEngelhard gravatar image NEngelhard  ( 2016-11-17 14:29:02 -0500 )edit

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

Pototo gravatar image Pototo  ( 2016-11-17 16:22:20 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

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

Pototo gravatar image

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

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 image Pototo  ( 2016-11-17 16:38:21 -0500 )edit
0

answered 2020-04-13 11:47:47 -0500

racklove gravatar image

Hey,

For those here with the error in manipulator type of setup, it is uncommon, it's due tothe same reason as the above. The launch file is trying to invoke a service that is already present.

[ERROR]: Advertise a service already advertised in this node

For me it was in the URDF where there was a common name in the transmission part. Follow the launched files and look for such name collision.

Regards,

edit flag offensive delete link more

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 -0500

Seen: 4,006 times

Last updated: Nov 17 '16