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

odometry messages to C++ node silently dropped

asked 2015-03-23 23:42:28 -0500

Sam Bishop gravatar image

updated 2015-03-25 08:52:22 -0500

I'm sure this is something silly, but I'm stumped and would really appreciate some help.

I was writing a node that needs to consume odometry messages, and I just couldn't get it to actually consume the messages. (By that I mean that I can rostopic pub ... a message and a rostopic echo ... will show that it has been sent, but my subscriber callback method isn't called.) I have trimmed my code down to a small ROS package and posted it on GitHub ( https://github.com/sambishop/aav-ros-... ), but I will also post it below.

The problem seems to be related to nav_msgs/Odometry messages somehow. If I modify the code to consume std_msgs/String messages instead, then it works. Also, this code works on one of my computers, the one stuck on Hydro, but not on my computer running Indigo.

QuinticControl.h:

#include "nav_msgs/Odometry.h"
#include "ros/ros.h"

namespace aav_control {
  class QuinticControl {
  public:
    void updateOdometry(const nav_msgs::Odometry::ConstPtr &odometry);
  };
}

QuinticControl.cpp:

#include "QuinticControl.h"

using namespace aav_control;

void QuinticControl::updateOdometry(const nav_msgs::Odometry::ConstPtr &odometry) {
  fprintf(stderr, "updateOdometry() called\n");
}

main.cpp:

#include "QuinticControl.h"
#include "ros/ros.h"

int main(int argc, char **argv) {
  ros::init(argc, argv, "aav_control2");
  ros::NodeHandle node;
  aav_control::QuinticControl control;
  ros::Subscriber subscriber = node.subscribe(
      "odometry/filtered",
      1000,
      &aav_control::QuinticControl::updateOdometry,
      &control
    );
  ros::spin();
  return 0;
}

This is my rostopic command:

rostopic pub /odometry/filtered nav_msgs/Odometry -f src/aav_control2/odom_.1_.5.yaml

EDIT 1
This is the output of rosnode:

$ rosnode info /aav_control2 
--------------------------------------------------------------------------------
Node [/aav_control2]
Publications: 
 * /rosout [rosgraph_msgs/Log]

Subscriptions: 
 * /odometry/filtered [unknown type]

Services: 
 * /aav_control2/get_loggers
 * /aav_control2/set_logger_level


contacting node http://turbo:36683/ ...
Pid: 7592
Connections:
 * topic: /rosout
    * to: /rosout
    * direction: outbound
    * transport: TCPROS

Here is the version using std_msgs::String that works:

QuinticControl.h:

#include "std_msgs/String.h"
#include "ros/ros.h"

namespace aav_control {
  class QuinticControl {
  public:
    void updateOdometry(const std_msgs::String::ConstPtr &odometry);
  };
}

QuinticControl.cpp:

#include "QuinticControl.h"

using namespace aav_control;

void QuinticControl::updateOdometry(const std_msgs::String::ConstPtr &odometry) {
  fprintf(stderr, "updateOdometry() called\n");
}

And the rostopic command:

rostopic pub /odometry/filtered std_msgs/String 'hello'

When that is run, the "updateOdometry() called" message is written to the console. You can see that I have only modified the callback method signature and the #include. Unless there's a problem with the way I'm using rostopic?

I have verified the works-with-strings/doesn't-work-with-odometry-messages on a second computer running Indigo. Unfortunately, I don't have easy access to a second computer running Hydro.

edit retag flag offensive close merge delete

Comments

can you verify using rosnode info your node really subscribes to the correct topic /odometry/filtered ?

Wolf gravatar image Wolf  ( 2015-03-24 03:29:40 -0500 )edit

Good question. I have edited my question, adding that and other information. Thank you!

Sam Bishop gravatar image Sam Bishop  ( 2015-03-24 09:40:39 -0500 )edit

Are you sure your message is not malformed via the YAML file?

aak2166 gravatar image aak2166  ( 2015-03-24 11:44:14 -0500 )edit

I don't think rostopic will publish a malformed message, and I am able to rostopic pub and rostopic echo the message (using Indigo) without errors or warnings. I have also confirmed again that all of this, including the C++ code, works with Hydro.

Sam Bishop gravatar image Sam Bishop  ( 2015-03-24 12:40:19 -0500 )edit

Did you copy you yaml file from your hydro PC? Maybe the definition of the nav_msgs::Odometry changed between both versions??

Wolf gravatar image Wolf  ( 2015-03-25 10:02:06 -0500 )edit

I did. I created it manually there, and used the error messages from rostopic to tell me when it was malformed. It seems like the message is okay though given that rostopic on Indigo has no problem sending or receiving it.

Sam Bishop gravatar image Sam Bishop  ( 2015-03-25 10:37:28 -0500 )edit

rostopic does plot you the message even if it is outdated! Your really have to check the md5sum for being sure the message can be received by your subscriber.

Wolf gravatar image Wolf  ( 2015-03-25 12:46:14 -0500 )edit
1

I believe that the MD5 sum would only matter if it was a bag file. But rosmsg md5 nav_msgs/Odometry returns cd5e73d190d741a2f92e81eda573aca7 on both Indigo and Hydro, so it doesn't look like the message format has changed anyways.

Sam Bishop gravatar image Sam Bishop  ( 2015-03-25 13:39:40 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-03-25 16:30:09 -0500

Dirk Thomas gravatar image

I used the rqt plugin "Message Publisher" to send nav_msgs::Odometry messages and they are received by your node perfectly fine.

Looking at your yaml file it looks like it is incomplete. I used the rqt plugin to publish messages and "record" them with rostopic echo. The resulting file works also fine when replayed with rostopic pub.

See my yaml file which contains the header information not available in yours:

header: 
  seq: 1
  stamp: 
    secs: 0
    nsecs: 0
  frame_id: ''
child_frame_id: child_frame
pose: 
  pose: 
    position: 
      x: 0.0
      y: 0.0
      z: 0.0
    orientation: 
      x: 0.0
      y: 0.0
      z: 0.0
      w: 0.0
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
twist: 
  twist: 
    linear: 
      x: 0.0
      y: 0.0
      z: 0.0
    angular: 
      x: 0.0
      y: 0.0
      z: 0.0
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-03-23 23:42:28 -0500

Seen: 1,314 times

Last updated: Mar 25 '15