The triggered publisher system publishes a user specified message on an output topic in response to an input message that matches user specified criteria. More...
#include <TriggeredPublisher.hh>
Public Member Functions | |
TriggeredPublisher ()=default | |
Constructor. More... | |
~TriggeredPublisher () override | |
Destructor. More... | |
void | Configure (const Entity &_entity, const std::shared_ptr< const sdf::Element > &_sdf, EntityComponentManager &_ecm, EventManager &_eventMgr) override |
Configure the system. More... | |
void | DoWork () |
Thread that handles publishing output messages. More... | |
bool | MatchInput (const transport::ProtoMsg &_inputMsg) |
Helper function that calls Match on every InputMatcher available. More... | |
Public Member Functions inherited from System | |
System () | |
Constructor. More... | |
virtual | ~System () |
Destructor. More... | |
Detailed Description
The triggered publisher system publishes a user specified message on an output topic in response to an input message that matches user specified criteria.
System Parameters
<input>
The tag contains the input message type, topic and matcher information.- Attributes:
type
: Input message type (eg.ignition.msgs.Boolean
)topic
: Input message topic name
- Attributes:
<input><match>
: Contains configuration for matchers. Multiple<match>
tags are possible. An output message is triggered if all Matchers match.- Attributes:
logic_type
("positive" or "negative"): Specifies whether a comparison must succeed or fail in order to trigger an output message. A "positive" value triggers a match when a comparison succeeds. A "negative" value triggers a match when a comparson fails. The default value is "positive"tol
: Tolerance for floating point comparisons.field
: If specified, only this field inside the input message is compared for a match.
- Value: String used to construct the protobuf message against which input messages are matched. This is the human-readable representation of a protobuf message as used by
ign topic
for publishing messages
- Attributes:
<output>
: Contains configuration for output messages: Multiple<output>
tags are possible. A message will be published on each output topic for each input that matches.- Attributes:
type
: Output message type (eg.ignition.msgs.Boolean
)topic
: Output message topic name
- Value: String used to construct the output protobuf message . This is the human-readable representation of a protobuf message as used by
ign topic
for publishing messages
- Attributes:
Examples:
- Any receipt of a Boolean messages on the input topic triggers an output <plugin><input type="ignition.msgs.Boolean" topic="/input_topic"/><output type="ignition.msgs.Empty" topic="/output_topic"/></plugin>
- Full match: An output is triggered when a Boolean message with a value of "true" is received <plugin><input type="ignition.msgs.Boolean" topic="/input_topic"><match>data: true</match></input><output type="ignition.msgs.Empty" topic="/output_topic"/></plugin>
- Field match: An output is triggered when a specific field matches <plugin><input type="ignition.msgs.Vector2d" topic="/input_topic"><match field="x">1.0</match><match field="y">2.0</match></input><output type="ignition.msgs.Empty" topic="/output_topic"/></plugin>
The logic_type
attribute can be used to negate a match. That is, to trigger an output when the input does not equal the value in <match>
For example, the following will trigger an ouput when the input does not equal 1 AND does not equal 2.
Repeated Fields
When a field matcher is used with repeated fields, the content of the repeated field is treated as a set and the comparison operator is set containment. For example, the data
field of ignition.msgs.Int32_V
is a repeated Int32 message. To match an input that contains the values 1 and 2 the following matcher can be used:
To match an Int32_V message with the exact contents {1, 2}, the full matcher is used instead
Limitations
The current implementation of this system does not support specifying a subfield of a repeated field in the "field" attribute. i.e, if field="f1.f2"
, f1
cannot be a repeated field.
Constructor & Destructor Documentation
◆ TriggeredPublisher()
|
default |
Constructor.
◆ ~TriggeredPublisher()
|
override |
Destructor.
Member Function Documentation
◆ Configure()
|
overridevirtual |
Configure the system.
- Parameters
-
[in] _entity The entity this plugin is attached to. [in] _sdf The SDF Element associated with this system plugin. [in] _ecm The EntityComponentManager of the given simulation instance. [in] _eventMgr The EventManager of the given simulation instance.
Implements ISystemConfigure.
◆ DoWork()
void DoWork | ( | ) |
Thread that handles publishing output messages.
◆ MatchInput()
bool MatchInput | ( | const transport::ProtoMsg & | _inputMsg | ) |
Helper function that calls Match on every InputMatcher available.
- Parameters
-
[in] _inputMsg Input message
- Returns
- True if all of the matchers return true
The documentation for this class was generated from the following file: