Giter VIP home page Giter VIP logo

Comments (2)

timonegk avatar timonegk commented on July 1, 2024

rate.sleep() does return false in that case, so it would be possible to listen for that and sleep manually then. But the purpose of returning false seems to be for backwards jumps in time, so I don't know if that is a reliable way of circumventing the problem.

from roscpp_core.

peci1 avatar peci1 commented on July 1, 2024

I think this is ill-conditioned requirement.

so it would be possible to listen for that and sleep manually then

For what amount of time would you like to sleep? If using simulation time, imagine /clock has simulation times sequence 0, 10, 20, 30... Now, what should a Rate(1).sleep() do? The time is 10, the sleep is called, what now? If the call would be blocking, you would not get rate higher than the simulation clock.

I think the expected behavior is that the 1st to 9th sleeps are non-blocking and the 10th sleep is blocking. Is that right?

I think in your specific case, you either have to increase resolution of the simulation clock or rewrite the logic of the rate loops. I think a token-bucket rate limiter could work. One such implementation is in http://docs.ros.org/en/melodic/api/cras_cpp_common/html/classcras_1_1TokenBucketLimiter.html .

from roscpp_core.

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.