GithubHelp home page GithubHelp logo

nobleo / static_executor Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 58 KB

Library that adds alternative(s) to the default executor in ROS2

License: Apache License 2.0

CMake 8.39% C++ 82.04% EmberScript 9.57%

static_executor's Introduction

static_executor

Library that adds alternative(s) to the default executor in ROS2

How to use

  1. Add static_executor to your CMakeLists.txt and package.xml as a dependency.

  2. Add

#include "static_executor/executors/static_single_threaded_executor.hpp"

at the top of your code.

  1. You can now replace
rclcpp::executors::SingleThreadedExecutor exec;

with

rclcpp::executors::StaticSingleThreadedExecutor exec;

in your source code.

No other changes are required.

Depends on

rclcpp

static_executor's People

Contributors

martincornelis2 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

static_executor's Issues

IPC causes spurious awakes of the executor

I'm investigating spurious awakes in both the standard and this executor.
See ros2/rclcpp#1021 for the standard executor

The problem mentioned in the ticket above does not appear in the static executor when I run that dummy executable with only 1 timer.
However, if I run a system made of 2 nodes (1 pub and 1 sub) in the same executor with IPC on, I see the exact same pattern.

I think that the root cause is how the static executor handles the waitable objects:
in each "iteration" of the static executor:

  • timer makes the publisher to publish a message. It's intra-process only, so the message is pushed into the subscription queue and the condition variable is triggered.
  • the executor checks waitable objects only through the is_ready() condition, that in this case consists in checking if the buffer is not empty. Since a message has just been pushed, the IPC subscription is invoked.
  • the executor goes back to wait
  • the executor wakes up immediately due to the condition variable triggered by the publisher above
  • there is no work to do
  • the executor goes back to wait

@MartinCornelis2 what do you think? I think that this problem with IPC is not present with the standard executor because only 1 item is processed in every iteration and the waitables are managed by the memory strategy.

Unit-tests for static executor

Hi,

I created a bunch of "unit-tests" for the static executor.
They test the following scenarios:

  1. add 1 pub node and 1 sub node to the executor and spin
  2. add 1 pub node to the executor and spin, then add 1 sub node while spinning
  3. add 1 pub node and 1 node with no entities to the executor and spin, then add 1 sub to the second node while spinning
  4. add 1 pub node and 1 sub node to the executor and spin, then while spinning remove the sub node from the executor

You can find them here
https://github.com/alsora/ros2-code-examples/blob/master/simple_static_executor/static_executor_test.cpp

These tests are meant to be used with your rclcpp version (nobleo/feature/static_executor), I opened the ticket here since it was not possible in that repo.

To build colcon build --packages-select simple_static_executor
To run ./install/simple_static_executor/lib/simple_static_executor/static_executor_test 2
Where the number at the end denotes the id of the test you want to run (1, 2, 3, 4)

The results are unfortunately not good.

Test 2 throws an exception

[ERROR] [1584978899.809709877] [rclcpp]: Couldn't add guard_condition to wait set: guard_conditions set is full, at /root/ros2_ws/src/ros2/rcl/rcl/src/rcl/wait.c:456
terminate called after throwing an instance of 'std::runtime_error'
  what():  Couldn't fill wait set
Aborted (core dumped)

In test 4 the subscription keeps receiving messages after having been removed from the executor

Could you have a look at the test?
Maybe I'm not using the executor as it is supposed to be used.

FYI the standard SingleThreadExecutor allows to pass all the tests successfully.

@MartinCornelis2 @mauropasse

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.