Computer Vision allows your robots to understand their environment. For the competition, this is used to locate cubes and arena walls.
When you tell you robot to
see, it will give you a list of all the markers it can see. The objects it returns will give you information about the type of the marker, the distance/angle to the marker along with other assorted information.
Our documentation is not as complete as the Student Robotics vision documentation. As we share much of the same code for vision, you can use that too.
MarkerInfo object is slightly different from Student Robotics:
marker_typecan be one of:
- There's also a
token_typeproperty that can be one of:
robot.TOKEN_NONE(if the marker is not a token)
To look for markers call
markers = R.see()
markers is now a Python list of
marker objects. Each
marker object contains the following properties.
| ||Distance to the marker in metres|
| ||Angle to the marker in degrees|
| ||Numeric code of the marker|
| ||One of |
| ||One of |
By default the camera takes pictures at a resolution of 640x480px. You can change this by specifying a
res parameter to
R.see(). This can be helpful when trying to see things far away.
markers = R.see(res=(1920, 1088))
You must use one of the following resolutions:
Using a higher resolution will increase the amount of time it takes to process the image.
Here's a more complete example:
import robot R = robot.Robot() markers = R.see() for marker in markers: if marker.info.token_type == robot.TOKEN_GOLD: move(marker.dist)
Blocks for vision can be found in the Vision section.
Here's an example of a Blockly program that does some basic vision stuff: