One node of many not publishing at random [closed]

asked 2013-04-08 06:48:20 -0500

Claudio gravatar image

updated 2014-04-20 14:09:23 -0500

ngrennan gravatar image

I wrote a couple of nodes to gather timing data. Each node master of a chain publishes its summary on the same topic called /timestats_pool.

Then there is a an aggregator that subscribes this pool and outputs ordered data on /timestats_aggregated.

Now if I launch any number of nodes manually, everything is fine. But if I launch many with a launch file like the following

<launch>
    <!-- == ROBOT 01 == -->
        <param name="robot1_stats_orig/master" value="true"/>
        <node pkg="timestats" type="ts_generator" name="robot1_stats_orig">
            <remap from="input" to="robot1_end"/>
            <remap from="output" to="robot1_start"/>
        </node>

        <node pkg="timestats" type="ts_generator" name="robot1_stats_link1">
            <remap from="input" to="robot1_start"/>
            <remap from="output" to="link1"/>
        </node>

        <node pkg="timestats" type="ts_generator" name="robot1_stats_link2">
            <remap from="input" to="link1"/>
            <remap from="output" to="robot1_end"/>
        </node>

    <!-- == END ROBOT 01 == -->


    <!-- == ROBOT 02 == -->
        <param name="robot2_stats_orig/master" value="true"/>
        <node pkg="timestats" type="ts_generator" name="robot2_stats_orig">
            <remap from="input" to="robot2_end"/>
            <remap from="output" to="robot2_start"/>
        </node>

        <node pkg="timestats" type="ts_generator" name="robot2_stats_link1">
            <remap from="input" to="robot2_start"/>
            <remap from="output" to="link2"/>
        </node>

        <node pkg="timestats" type="ts_generator" name="robot2_stats_link2">
            <remap from="input" to="link2"/>
            <remap from="output" to="robot2_end"/>
        </node>
    <!-- == END ROBOT 02 == -->


    <!-- == ROBOT 03 == -->
        <param name="robot3_stats_orig/master" value="true"/>
        <node pkg="timestats" type="ts_generator" name="robot3_stats_orig">
            <remap from="input" to="robot3_end"/>
            <remap from="output" to="robot3_start"/>
        </node>

        <node pkg="timestats" type="ts_generator" name="robot3_stats_link1">
            <remap from="input" to="robot3_start"/>
            <remap from="output" to="link3"/>
        </node>

        <node pkg="timestats" type="ts_generator" name="robot3_stats_link2">
            <remap from="input" to="link3"/>
            <remap from="output" to="robot3_end"/>
        </node>
    <!-- == END ROBOT 03 == -->

    <node pkg="timestats" type="ts_monitor" name="aggregator"/>
</launch>

I don't always get all three masters: at random one would fail to publish its data. I can see messages being passed on every topic, so the nodes are working plus since the launch file is the same, but the missing stat is random, I don't see why this is happening and what can I do to avoid the problem.

Maybe when subscriptions are too fast some are missed? So maybe the node that arrives second (let's say) always gets discarded and its publisher is never connected? Or something like that...

Could it be so?

here is the source for the master

#include <ros/ros.h>
#include <ros/subscriber.h>
#include <time.h>
#include <sstream>
#include <timing_class.hpp>
#include <timestats/AggregatedStats.h>
#include <timestats/Machine.h>
#include <timestats/Report.h>
#include <timestats/StatsInfo.h>

std::string MachineName;
timestats::Report traceNew, traceReply;
timestats::StatsInfo statsmsg;
int counter = 0, filter = 0;
bool ping_submit_ready = false, ready_reply = false, master = false, stats_submit_ready = false;
std::stringstream ss;
TimeStatistics::accumulator *_node_data;




void timerCallback(const ros::TimerEvent&)
{
    timespec timestruct;
    clock_gettime(CLOCK_REALTIME, &timestruct);
    traceNew.machine.clear();
    traceNew.header.assign(MachineName);
    traceNew.counter = counter; 
    timestats::Machine localmachine;
    localmachine.name.assign(MachineName);
    localmachine.timestamp = ((timestruct.tv_sec << 32) + timestruct.tv_nsec);
    traceNew.machine.push_back(localmachine);
    ping_submit_ready = true;
    counter++;
}

void subscriberCallback(const timestats::Report& msg)
{
    timespec timestruct;
    clock_gettime(CLOCK_REALTIME, &timestruct);
    traceReply = msg;
    timestats::Machine localmachine;
    localmachine.name.assign(MachineName);
    localmachine.timestamp = ((timestruct ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2015-12-12 01:18:44.478314