def extract_perception_text(msg):
    for target in getattr(msg, "targets", []):
        text = getattr(target, "type", "")
        if text:
            return text
    return ""


def is_trigger_match(value, expected):
    try:
        return int(value) == int(expected)
    except (TypeError, ValueError):
        return False
