topic_filter.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:openag_brain 作者: OpenAgInitiative 项目源码 文件源码
def filter_all_variable_topics(variables):
    """
    Given an iterator publishers, where each publisher is a two-tuple
    `(topic, type)`, publishes a filtered topic endpoint.
    """
    for env_var in variables:
        src_topic = "{}/raw".format(env_var)
        dest_topic = "{}/measured".format(env_var)
        # Ignore type associated with environmental variable type and
        # coerce to Float64

        # @FIXME this is a short-term fix for preventing boolean values from
        # being filtered by the EWMA filter.
        #
        # Explanation: right now all topics under `/environment/<id>` are
        # float64 type, with Boolean being 1 or 0. This was judged to be a
        # simpler architecture at the time. Values from sensors may be any
        # type, but are coerced to Float64. The same is true for actuators.
        # However, this assumption breaks down for filtering boolean values,
        # since the EWMA will produce fractional numbers that don't coerce
        # correctly back to boolean.
        #
        # In future, we should change the architecture of the system to support
        # standard ros types under `/environment/<id>`.
        if env_var.type is None or 'boolean' in env_var.type.lower():
            forward_topic(src_topic, dest_topic, Float64)
        else:
            filter_topic(src_topic, dest_topic, Float64)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号