ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Dropping connection due to Datatype mismatch

asked 2018-08-28 08:30:27 -0600

kk2105 gravatar image

updated 2018-08-31 08:35:06 -0600

Hi All,

Kindly help me in finding a fix for this.

I am playing a rosbag which has 5 topics. I want to create a new node and subscribe to one of topic from the rosbag.

I am getting the below error when I try to subscribe to the topic.

 [ERROR] [XXXXX]: Client [/A] wants topic /B to have datatype/md5sum [std_msgs/String/], but our version has [visualization_msgs/MarkerArray/]. Dropping connection.

Looks like the data type from bag file is visualization_msgs/MarkerArray/, how would I make modifications in code so that subscription happens without any issue ?

Subscriber Code given below:

 #include "ros/ros.h"
 #include "std_msgs/String.h"
 #include <visualization_msgs/Marker.h>

 void chatterCallback(const std_msgs::String::ConstPtr& msg)
 {
  ROS_INFO("Control has come inside the function");
  ROS_INFO("I heard: [%s]", msg->data.c_str());
 }

 int main(int argc, char **argv)
 {
  ros::init(argc, argv, "listener");
  ros::NodeHandle n;
  ros::Subscriber sub = n.subscribe("my_topic", 1000, chatterCallback);
  ROS_INFO("Initiated the ROS node and subscriber");
  ros::spin();
  return 0;
 }

Updating the question:

I am trying the same code outside and inside the docker.

Outside the docker: Fixed the error by changing the datatype of the parameter in call back to const visualization_msgs::MarkerArray::ConstPtr& msg

But inside the docker the issue remains the same. The control doesn't come inside the callback function at all.

Waiting 0.2 seconds after advertising topics.../rrrrrr/platform/ros/ros_comm/roscpp/src/libros/publication.cpp:629 Publication::validateHeader() [ERROR] [1535722434.248608746]: Client [/my_c] wants topic /topic to have datatype/md5sum [visualization_msgs/MarkerArray/90da67007c26525f655c1c269094e39f], but our version has [visualization_msgs/MarkerArray/d155b9ce5188fbaf89745847fd5882d7]. Dropping connection.

Thank you, KK

edit retag flag offensive close merge delete

Comments

2

Change the subscription callback signature to accept visualization_msgs/MarkerArray?

gvdhoorn gravatar image gvdhoorn  ( 2018-08-28 09:01:57 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2018-08-28 09:07:54 -0600

updated 2018-08-28 09:08:59 -0600

The subscriber in your code is still expecting a message type of std_msgs/String as defined in the function declaration here, which is why the node is producing the error message:

 void chatterCallback(const std_msgs::String::ConstPtr& msg)

You need to change this so it matches the type of the topic you're trying to subscribe to, in this case a visualization_msgs/MarkerArray. The new function declaration will look like this:

 void chatterCallback(const visualization_msgs::MarkerArray::ConstPtr& msg)

However there are two more changes you need to make to your code and one that you should.

First, you're currently including the Marker message header not the MarkerArray header, so this should be:

#include <visualization_msgs/MarkerArray.h>

Second, the MarkerArray message type doesn't have a string member called data as string does, so you'll need to print some other information out to test this or the code won't compile. You could for example print out the number of markers in the array:

ROS_INFO("I received a MarkerArray with [%s] markers", (int)msg->markers.size());

Finally you should remove the #include "std_msgs/String.h" header because it's no longer used.

Hope this helps.

edit flag offensive delete link more

Comments

@PeteBlackerThe3rd Thanks for the quickly. I am doing the changes in my code. There is one more doubt, since we are adding a new library in this case visualization_msgs/MarkerArray.h in this case, do we need to make changes in CMakeLists.txt as well ?

Thank you, KK

kk2105 gravatar image kk2105  ( 2018-08-28 09:29:43 -0600 )edit

No problem you'll need a dependency setup for the visualization_msgs package in your CMakeLists.txt as well as build and runtime dependencies in your package.xml. This dependency is for the whole package of visualization_msgs so you may have it already, but add it if you haven't.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-08-28 09:59:42 -0600 )edit

@PeteBlackerThe3rd Thanks for the solution. I will update the CMakeLists.txt and let you know.

kk2105 gravatar image kk2105  ( 2018-08-29 00:08:09 -0600 )edit

@PeteBlackerThe3rd It seems like visualization_msgs is not found. Could you please help me to install/add it separately ?

kk2105 gravatar image kk2105  ( 2018-08-30 07:37:47 -0600 )edit

visualization_msgs is a standard package within ROS, you should definitely have it already. Have you updated your package.xml file as well?

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-08-30 07:45:52 -0600 )edit

@PeteBlackerThe3rd Yes, I have updated the package.xml

<build_depend>visualization_msgs</build_depend> <run_depend>visualization_msgs</run_depend>

Updated CMakeLists.txt as well

find_package(catkin REQUIRED COMPONENTS roscpp std_msgs visualization_msgs)

Thank you, KK

kk2105 gravatar image kk2105  ( 2018-08-30 08:04:51 -0600 )edit

What is the actual error you're getting when you try and cakin_make this?

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-08-30 09:53:20 -0600 )edit

@PeteBlackerThe3rd I was able to get rid of the error by changing the data type of the parameter inside callback function (Lets consider this was done on System A). catkin_make is successful and I can see the node is subscribed to the topic.

kk2105 gravatar image kk2105  ( 2018-08-30 13:54:14 -0600 )edit
0

answered 2018-09-05 13:08:08 -0600

kk2105 gravatar image

I was able to get the exact cause for the issue here.

The topic which I was trying to subscribe had been collected in ROS version which is different from the system from which I am trying to subscribe.

The migration of rosbag from one version needs to be done here to fix this issue.

Thank you, KK

edit flag offensive delete link more

Comments

Glad you got to the bottom of this. It's one of the quirks of ROS that identical message types are not ashtrays compatible between versions.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-09-10 07:45:25 -0600 )edit

@PeteBlackerThe3rd Yea, I had to read a lot to get the fix for this.

kk2105 gravatar image kk2105  ( 2018-09-10 08:48:53 -0600 )edit

@kk2105 I am also facing the same issue ,for your information I am using ROS1 noetic on Ubuntu 20.04. But the bag file which is throwing error was of ros2 foxy. I converted the bag file from foxy (.db3 version) to noetic (.bag). The error is kind of same like md5sum error you mentioned above. Can you please help me resolve it?

draj gravatar image draj  ( 2022-11-09 11:06:18 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-08-28 08:30:27 -0600

Seen: 1,680 times

Last updated: Sep 05 '18