OnMessage<INDEX>() and ConsumeIfReady(). The concrete policy (All, FieldSync, …) implements IsReadyNoLock() to define the firing condition.
All types live in the
basis::synchronizers namespace.
Headers are in cpp/synchronizers/include/basis/synchronizers/.MessageSumType
| Container form | Meaning |
|---|---|
std::shared_ptr<const T> | Single most-recent message |
std::vector<std::shared_ptr<const T>> | Buffered messages |
std::variant<std::monostate, std::shared_ptr<const T>, std::shared_ptr<const U>> | Message or alternate inproc type |
MessageMetadata<T_MSG_CONTAINER>
synchronizer_base.h
Per-input metadata that modifies synchronizer behavior.
When
true, this input does not block the ready check. The handler fires even if no message has been received on this input.When
true, consuming the synchronizer output does not clear this input’s storage. The last received message is retained and re-used on subsequent firings.SynchronizerBase<T_MSG_CONTAINERs...>
synchronizer_base.h
Abstract CRTP-free base for all synchronizers. Manages per-input Storage objects and a mutex protecting them.
Template parameters
One type per handler input, in order. Each is the container type for that input (see
MessageSumType above).Constructor
Per-input metadata. Pass as individual arguments or as a tuple. When omitted, all inputs use default metadata (required, not cached).
OnMessage<INDEX>
msg in the slot for input INDEX, then checks if the synchronizer is ready.
Zero-based index of the input. Must be within
[0, sizeof...(T_MSG_CONTAINERs)).The received message. Must be assignable to the container type at position
INDEX.When non-null and the synchronizer becomes ready, the consumed
MessageSumType is written here while the lock is still held. Avoids a separate ConsumeIfReady() call.true if the synchronizer is ready after storing the message.
ConsumeIfReady
MessageSumType and clears non-cached inputs if ready, or std::nullopt otherwise.
IsReady
true if the synchronizer would fire right now, without consuming the messages.
All<T_MSG_CONTAINERs...>
all.h — inherits SynchronizerBase
Fires when every non-optional input has received at least one message. The simplest and most common synchronizer policy.
Ready condition
IsReadyNoLock() returns true when AreAllNonOptionalFieldsFilledNoLock() is true — i.e. every input with is_optional == false holds a non-null message.
Field<T_CONTAINER_MSG, T_FIELD>
field.h
A compile-time descriptor that associates a container type with a field accessor. Used as a template argument to FieldSync to declare which field to synchronize across messages.
The container type, e.g.
std::shared_ptr<const sensor_msgs::Image>.A pointer to member or a lambda/function pointer that extracts the sync key from the underlying message. Pass
nullptr to mark an input as unsynced (it acts like All for that slot).FieldSync<T_OPERATOR, T_FIELD_SYNCs...>
field.h — inherits SynchronizerBase
Synchronizes messages across inputs by comparing extracted field values using T_OPERATOR. When a new message arrives on a synced input, the synchronizer searches all other synced inputs’ buffers for a matching field value.
A struct with a templated
operator()(const T1& t1, const T2& t2) that returns a truthy value when two field values are considered “in sync”. See Equal and ApproximatelyEqual below.One or more
Field<> descriptors. Inputs whose FieldPtr == nullptr are unsynced and always use the most recently received message.OnMessage<INDEX> (overridden)
msg, extracts its field value, and searches all other synced input buffers for matching values. For unsynced inputs: directly stores msg (overwrites).
Returns true when all non-optional inputs are filled with a matched set.
FieldSyncEqual<T_FIELD_SYNCs...>
field.h
Alias for FieldSync<Equal, T_FIELD_SYNCs...>. Fires when field values are exactly equal (==).
FieldSyncApproximatelyEqual<EPSILON, T_FIELD_SYNCs...>
field.h
Alias for FieldSync<ApproximatelyEqual<EPSILON>, T_FIELD_SYNCs...>. Fires when field values satisfy std::abs(a - b) <= EPSILON.
Maximum allowed difference between two field values. Must be a compile-time constant of a numeric type compatible with
std::abs and operator- on the field’s value type.Custom operator example
You can define your ownT_OPERATOR for domain-specific matching:
Type utilities
These helpers are used internally and in generated code.HasPushBack<T>
A C++20 concept. Satisfied when T has a push_back(value_type) method — i.e. when the container is a std::vector.
ExtractFromContainer<T>
Extracts the element type from a container:
- For vector-like types:
T::value_type - Otherwise:
Titself
IsStdVariant<T>
Type trait that is std::true_type when T is a std::variant specialization.