Ask Your Question
0

topic is already advertised as md5sum [...] and datatype [...]

asked 2017-04-05 19:15:47 -0600

SRD gravatar image

updated 2017-04-05 19:37:39 -0600

I'm trying to get output from a remote node to the /rosout topic and view it with 'rostopic echo rosout' running on the master. I have a roscore running on hostA brought up by starting roslaunch. On hostB, I have a node built from roscpp.

My nodes code is as follows:

int func1()
{
    if (ros::console::set_logger_level(ROSCONSOLE_DEFAULT_NAME,
        ros::console::levels::Debug) ) {
            ros::console::notifyLoggerLevelsChanged();
        }

    map<string, string> remap;
    remap.emplace("__ip", get_ip());
    remap.emplace("__master", get_master_uri());

    ros::init(remap, "test-node");
    ros::Time::init();

    while (!ros::master::check()) {
        ros::Duration(1.0).sleep();
    }

    nh = boost::make_shared<ros::NodeHandle>();

    ros::spinOnce();

    return 0;
}

int func2()
{
    ROS_INFO("point A");

    ros::Publisher pub =
        nh->advertise<std_msgs::String>("rosout", 1000);

    ROS_INFO("point B");

    std_msgs::String msg;
    stringstream ss;
    ss << "Using stringstream.";
    msg.data = ss.str();
    pub.publish(msg);

    ROS_INFO("point C"); 
    ROS_INFO_STREAM("ss data: " << msg.data);

    ROS_INFO_STREAM("ROS Node Namespace: " << ros::this_node::getNamespace());
    ROS_INFO_STREAM("ROS Node Name: " << ros::this_node::getName());

    ROS_INFO("point 4");

    return 0;    
}

The only thing I ever see show up on the master node is "point A", "point B" never prints and I get the following message on the master node.

Tried to advertise on topic [/rosout] with md5sum [992ce8a1687cec8c8bd883ec973ca4131] and datatype [std_msgs/String], but the topic is already advertised as md5sum [acffd30cd6b6de30f120938c17c593fb] and datatype [rosgraph_msgs/Log]

No where's have I used a datatype of rosgraph_msgs and I'm not sure why the message says so. rqt_console shows me the message is coming from the node "test-node" as an error. Sometimes the "point A" message will come through with severity 'Info' and shows up properly, but won't go beyond the error above.

Also, how is it that ROS_INFO("point A") shows up on the /rosout of the master, yet the topic hasn't even been advertised yet?

Thoughts?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-04-05 19:44:52 -0600

ahendrix gravatar image

The rosout topic is advertised by ros::init as part of the node setup; you don't need to advertise on it yourself.

In addition, ROS_INFO and the associated logging macros already handle publishing to rosout.

The publisher you've created conflicts with the default publisher, which is why you're getting this error message.

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: 2017-04-05 19:15:47 -0600

Seen: 454 times

Last updated: Apr 05 '17