Code Monkey home page Code Monkey logo

Comments (2)

FlorianReimold avatar FlorianReimold commented on June 23, 2024

Hi @lin0303-siyuan,

tl;dr: eCAL always needs a little time to start up. By default, 1 seconds. If you sleep >1s before publishing your first message, you should receive it.

Long explanation
In eCAL, 2 different communications are always happening simultaneously.

  1. The data-communication is what you are actually seeing. This transports the payload, in your case the "Hello World" Strings.
  2. In the background, hidden from you, eCAL however has to send around some metadata. This metadata is for instance responsible for individual nodes finding each other.

In order to have a successful connection from a publisher to a subscriber, the following information have to be exchanged:

  • The publisher must receive the information that a subscriber for its topic exists and where it lives (to determine the data transport layer like UDP for network or SHM for localhost). While the eCAL API already allows you to publish data without having a subscriber, the eCAL library will simply do nothing if there is no subscriber, in order to save system resources.
  • The subscriber must receive information from the publisher about how the data will be transmitted. Again, it must know about the concrete layer (UDP, TCP, SHM), as well as the layer parameters (Port for TCP, SHM filename for SHM)

Only after these information have been exchanges successfully, the data communcation can start. The metadata is however only transmitted once every 1s. Therefore, if you call publisher.Send() directly after you created the publisher, eCAL didn't have enough time for publisher <-> subscriber matching, yet.

You should easily be able to work around this, by adding a delay between the instantiation of your publisher and the first Send() call. For instance, you can move the std::chrono::sleep_for to the beginning of the while loop, so that eCAL has some time to establish all connections.

Kind Regards
Florian

from ecal.

lin0303-siyuan avatar lin0303-siyuan commented on June 23, 2024

Really appreciate your answer, it solved my problem. It's such a nice explanation.

from ecal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.