Ask Your Question

Get error when trying to publish float64 arm message

asked 2014-05-24 13:38:19 -0500

garym gravatar image

Get an error(see below) when trying to publish a float64 arm command.

Using Ubuntu 12.04.1 Ros Hydro

source file:

#include "ros/ros.h"
#include <std_msgs/Float64.h>
#include "pub/ArmPan.h"

pub::ArmPan panmsg;

int main(int argc, char **argv)
    ros::init(argc, argv, "pub");
    ros::NodeHandle n;
    ros::Publisher ArmPan_pub = n.advertise<std_msgs::Float64>("ArmPan/command", 1000);
    ros::Rate loop_rate(10);
    int count = 0;

        panmsg.ArmPan = 1.0;
    return 0;

the file ArmPan.msg has one line: float64 ArmPan

rosrun fails with this err:

[FATAL] Assertion failed
file = /opt/ros/hydro/include/ros/publisher.h
line 115
cond = impl_->md5sum == "*" || std::string(mt::md5sum<M>(message))
             == "*" || impl_->md5sum == mt::md5sum<M>(message)
Trying to publish message of type [pub/ArmPan] on a publisher with type [std_msgs/Float64]

if the message

rostopic pub -1 ArmPan/command std_msgs/Float64 1

is entered, it works.

This code worked in earlier versions of ROS but now fails with Hydro. Can you tell me why? Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-05-24 14:03:24 -0500

ahendrix gravatar image

The problem here is that you're advertising one type of message, and calling publish with a different type of message.

This only worked in older versions of ROS because there was a bug in the publisher that didn't check the data type on publish, and I guess you were able to get away with it because the serialized version of your message just happened to be the same as a std_msgs/Float64

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


Asked: 2014-05-24 13:38:19 -0500

Seen: 1,757 times

Last updated: May 24 '14