Compare

Description

Compare the value of a JSON key against a configured operand and activate while the comparison holds. One plugin covers the whole family: comparison picks the operator and the type you give value picks the operand type (the two axes thirteen former per-operator plugins each hard-coded).

Parameters

ParameterDescriptionTypeDefault
keyJSON key where value is located, separate nested dictionary with /strN/A (Mandatory)
comparisonOperator: eq, ne, gt, ge, lt, le, match or existsstrN/A (Mandatory)
valueOperand to compare the JSON value against; its type selects the operand type: bool, int, float, str, list[bool], list[int], list[float] or list[str]any of thoseN/A (Mandatory, except for match and exists)
regexRegex the JSON value must fully matchstrN/A (Mandatory for match)
order_mattersFor list operands: compare element order (true) or as unordered multisets (false)booltrue

The JSON comparison is type-strict: a Record field written as 5 is an integer and never matches a float operand (and 5.0 never matches an int one). gt/ge/lt/le need an int or float operand; ne inverts eq for every operand type.

Configuration

Only forward a TCP Health Record when the check actually failed — suppressing the steady stream of active: true polls and keeping only outage alerts:

measurement_server:
  ros__parameters:
    condition_plugins: ["endpoint_down"]
    endpoint_down:
      plugin: "dc_conditions/Compare"
      key: "active"
      value: false
      comparison: "eq"
    rustfs_health:
      plugin: "dc_measurements/TCPHealth"
      if_all_conditions: ["endpoint_down"]
      topic_output: "/dc/measurement/rustfs_health"
      host: "127.0.0.1"
      port: 9000
      name: "rustfs_api"

A dead-band on Distance traveled — filters out both "parked" noise and implausibly large jumps (dc_demos/params/tb3_simulation_pgsql_minio.yaml):

measurement_server:
  ros__parameters:
    condition_plugins: ["min_distance_traveled", "max_distance_traveled"]
    min_distance_traveled:
      plugin: "dc_conditions/Compare"
      key: "distance_traveled"
      value: 0.01
      comparison: "ge"
    max_distance_traveled:
      plugin: "dc_conditions/Compare"
      key: "distance_traveled"
      value: 2.0
      comparison: "le"
    distance_traveled:
      plugin: "dc_measurements/DistanceTraveled"
      if_all_conditions: ["min_distance_traveled", "max_distance_traveled"]
      topic_output: "/dc/measurement/distance_traveled"

Only publish Fast DDS statistics once its discovered hosts list no longer matches the expected single-host fingerprint — flags an unexpected extra participant joining the DDS graph:

measurement_server:
  ros__parameters:
    condition_plugins: ["known_hosts"]
    known_hosts:
      plugin: "dc_conditions/Compare"
      key: "hosts"
      value: ["d:14058711922191368192"]
      comparison: "eq"
      order_matters: false
    fastdds_stats:
      plugin: "dc_measurements/FastddsStats"
      if_none_conditions: ["known_hosts"]
      topic_output: "/dc/measurement/fastdds_stats"

Only collect a Battery Record while it is actively charging (match uses a full regex match, and exists tests only that key is present, taking no value):

measurement_server:
  ros__parameters:
    condition_plugins: ["actively_charging", "inspected_exists"]
    actively_charging:
      plugin: "dc_conditions/Compare"
      key: "power_supply_status"
      comparison: "match"
      regex: "charging|full"
    inspected_exists:
      plugin: "dc_conditions/Compare"
      key: "inspected"
      comparison: "exists"
    battery:
      plugin: "dc_measurements/Battery"
      if_all_conditions: ["actively_charging", "inspected_exists"]
      topic_output: "/dc/measurement/battery"

Migration from the former per-operator plugins

Former plugincomparisonvalue typeNotes
dc_conditions/BoolEqualeqbool
dc_conditions/DoubleEqualeqfloat
dc_conditions/IntegerEqualeqint
dc_conditions/DoubleInferiorle or ltfloatle was include_value: true, lt false
dc_conditions/IntegerInferiorle or ltintsame include_value mapping
dc_conditions/DoubleSuperiorge or gtfloatge was include_value: true, gt false
dc_conditions/IntegerSuperiorge or gtintsame include_value mapping
dc_conditions/ListBoolEqualeqlist[bool]order_matters unchanged
dc_conditions/ListDoubleEqualeqlist[float]order_matters unchanged
dc_conditions/ListIntegerEqualeqlist[int]order_matters unchanged
dc_conditions/ListStringEqualeqlist[str]order_matters unchanged
dc_conditions/StringMatchmatchnoneregex parameter unchanged
dc_conditions/Existexistsnonekey only

ne (value differs) and scalar str equality are new with Compare.