Ask Your Question
0

Debugging a bad topic subscription

asked 2015-03-20 01:44:06 -0500

Stephane Caron gravatar image

Hi,

I just solve a situation I don't know how to debug. When subscribing to a topic, the prototype of my callback function was

void my_callback(const std_msgs::String::ConstPtr& msg);

instead of

void my_callback(const control_msgs::JointControllerState::ConstPtr& msg);

However, the code compiled fine and no error was reported at runtime. For future use, where should I look to get more debug info on topic subscriptions?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2015-03-20 04:51:15 -0500

Wolf gravatar image

The actually a WARNING will be at runtime logged at the publisher side:

E. g. if trying to publish a std_msgs/Emtpy to topic /camera/image where rosrun image_view image_view is listening:

rostopic pub /camera/image std_msgs/Empty -r 1
[WARN] [WallTime: 1426844976.659990] Could not process inbound connection: topic types do not match: [sensor_msgs/Image] vs. [std_msgs/Empty]{'topic': '/camera/image', 'tcp_nodelay': '0', 'md5sum': '060021388200f6f0f447d0fcd9c64743', 'type': 'sensor_msgs/Image', 'callerid': '/image_view_1426844958567455361'}

On the subscriber side, however, no Error/Warning is logged:

rosrun image_view  image_view image:=/camera/image
[ INFO] [1426844958.672731010]: Using transport "raw"

So you have to look at the log msgs of the publisher.

edit flag offensive delete link more
1

answered 2015-03-20 04:35:55 -0500

The message type that is the argument for the callback determines the message type for the subscriber. If you use the wrong message type there, you should get an error at runtime that says message types between publisher and subscriber do not match (red ROS_ERROR logging). This would only appear if you have a actual topic connection, however. Are you sure that is the case?

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

1 follower

Stats

Asked: 2015-03-20 01:44:06 -0500

Seen: 1,007 times

Last updated: Mar 20 '15