Skip to content

How does the AI Vision "exists" attribute work? #17

@touretzkyds

Description

@touretzkyds

Looking at the AI Vision documentation here: https://api.vex.com/aim/home/python/AI_Vision.html#exists

I can't make sense of the "exists" attribute. In the section on ball detection, the example code does this:

# Move forward if a sports ball is detected
while True:
    ball = robot.vision.get_data(SPORTS_BALL)
    if ball[0].exists:
        robot.move_for(10, 0)
    wait(50, MSEC)

But if there is no sports ball detected, get_data will return an empty list [ ], so ball[0] will cause an error.

Also, looking at the source code, the "exists" attribute is only mentioned once in the code, in aim.py, where it is set to True.

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions