grepros 1.3.0
grep for ROS bag files and live topics
Loading...
Searching...
No Matches
ConditionMixin Class Reference
Inheritance diagram for ConditionMixin:
Inheritance graph

Classes

class  Empty
 
class  Message
 
class  NoMessageException
 
class  Topic
 

Public Member Functions

 __init__ (self, args=None, **kwargs)
 
 close_batch (self)
 
 conditions_get_topics (self)
 
 conditions_register_message (self, topic, msg)
 
 conditions_set_topic_state (self, topic, pure)
 
 has_conditions (self)
 
 is_conditions_topic (self, topic, pure=True)
 
 is_processable (self, topic, msg, stamp, index=None)
 
 validate (self)
 

Public Attributes

 args
 

Static Public Attributes

 DEFAULT_ARGS = dict(CONDITION=())
 Constructor argument defaults.
 
 TOPIC_RGX = re.compile(r"<topic\s+([^\s><]+)\s*>")
 

Detailed Description

Provides topic conditions evaluation.

Evaluates a set of Python expressions, with a namespace of:
- msg:                current message being checked
- topic:              current topic being read
- <topic /any/name>   messages in named or wildcarded topic

<topic ..> gets replaced with an object with the following behavior:
- len(obj)  -> number of messages processed in topic
- bool(obj) -> whether there are any messages in topic
- obj[pos]  -> topic message at position (from latest if negative, first if positive)
- obj.x     -> attribute x of last message

All conditions need to evaluate as true for a message to be processable.
If a condition tries to access attributes of a message not yet present,
condition evaluates as false.

If a condition topic matches more than one real topic (by wildcard or by
different types in one topic), evaluation is done for each set of
topics separately, condition passing if any set passes.

Example condition: `<topic */control_enable>.data and <topic */cmd_vel>.linear.x > 0`
                   `and <topic */cmd_vel>.angular.z < 0.02`.

Definition at line 258 of file inputs.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self,
  args = None,
**  kwargs 
)
@param   args             arguments as namespace or dictionary, case-insensitive
@param   args.condition   Python expressions that must evaluate as true
                          for message to be processable, see ConditionMixin
@param   kwargs           any and all arguments as keyword overrides, case-insensitive

Reimplemented in BagSource, LiveSource, and AppSource.

Definition at line 365 of file inputs.py.

Member Function Documentation

◆ close_batch()

close_batch (   self)
Clears cached messages.

Reimplemented in BagSource.

Definition at line 432 of file inputs.py.

◆ conditions_get_topics()

conditions_get_topics (   self)
Returns a list of all topics used in conditions (may contain wildcards).

Definition at line 441 of file inputs.py.

◆ conditions_register_message()

conditions_register_message (   self,
  topic,
  msg 
)
Retains message for condition evaluation if in condition topic.

Definition at line 463 of file inputs.py.

◆ conditions_set_topic_state()

conditions_set_topic_state (   self,
  topic,
  pure 
)
Sets whether topic is purely used for conditions not matching.

Definition at line 458 of file inputs.py.

◆ has_conditions()

has_conditions (   self)
Returns whether there are any conditions configured.

Definition at line 437 of file inputs.py.

◆ is_conditions_topic()

is_conditions_topic (   self,
  topic,
  pure = True 
)
Returns whether topic is used for checking condition.

@param   pure  whether use should be solely for condition, not for matching at all

Definition at line 445 of file inputs.py.

◆ is_processable()

is_processable (   self,
  topic,
  msg,
  stamp,
  index = None 
)
Returns whether message passes passes current state conditions, if any.

Reimplemented in BagSource, LiveSource, and AppSource.

Definition at line 385 of file inputs.py.

◆ validate()

validate (   self)
Returns whether conditions have valid syntax, sets options, prints errors.

Reimplemented in BagSource, LiveSource, and AppSource.

Definition at line 413 of file inputs.py.

Member Data Documentation

◆ args

args

Definition at line 429 of file inputs.py.

◆ DEFAULT_ARGS

DEFAULT_ARGS = dict(CONDITION=())
static

Constructor argument defaults.

Definition at line 288 of file inputs.py.

◆ TOPIC_RGX

TOPIC_RGX = re.compile(r"<topic\s+([^\s><]+)\s*>")
static

Definition at line 285 of file inputs.py.


The documentation for this class was generated from the following file: