[Documentation] [TitleIndex] [WordIndex

(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Introduction to Sigslots

Description: Creating, connecting and triggering signals and slots.

Keywords: ecl sigslots

Tutorial Level: INTERMEDIATE

Next Tutorial: Relaying Signals Debugging Sigslots

Slot Loading

Loading of slots can be done directly to free or member functions through the constructors. Below is a simple example for various types of loading.

   1 void f(const int& i) {}
   2 class A {
   3 public:
   4     void f(const int& i) {}
   5 };
   6 // ...
   7 A a;
   8 Slot<const int&> slot0(f);
   9 Slot<const int&> slot1(&A::f,a);


   1 Signal<const int&> signal;
   2 Slot<const int&> slot(f);
   3 signal.connect("Dudes");
   4 slot.connect("Dudes");

Signals and slots have no limit to the number of connections they may make.


Every time a signal emits, the connected slots are consecutively run with the data that is emitted.

   1 signal.emit(3); // Pass the '3' to all the slot functions.

Every emit, the slots are consecutively run - this means that your slots should by nature be short and concise! Otherwise you'll get serious bottlenecks. This is always a good habit to get into for slots otherwise you'll frequently run into problems. If you have a heavy callback, consider spinning that callback off into a thread. That way the thread response will still be quick (cost of a thread creation) and you can still manage heavy workloads.

Design Considerations

control systems, but if needed, this library can be extended.

2020-01-18 12:37