Instructional Material: Exercise: Using Vuforia - VuMarks

Vuforia is a library of classes included in the FTC SDK that supports using the RC phone camera to locate objects in the camera field of view and return actionable information to your program. That information may allow your robot to locate and navigate to a visual target, locate an object or recognize images. In this lesson we are focusing on a feature of Vuforia called VuMarks. A VuMark is an image that is like a bar code. Contained in the image is encoded information. For instance, in the Relic Revcovery game, the temple images might look identical but each has identifying information (left, right and center) encoded in hexagonal dots. Vuforia can be used to detect VuMark images when in the camera field of view and read the encoded information and return it to your program. In the Relic Recovery game, your program can use the returned information to determine the relic stacking scheme to gain the most points.

VuMarks are defined by data files created with the Vuforia Target Manager. The data files are then embedded in your program by putting the data files in the assets directory of the FtcRobotController section of the SDK project. FIRST includes VuMark files in the SDK when VuMarks are are used in a game. Because they are embedded in the finished robot controller app, your code can read these files to get the VuMark identification information needed to identify images.

There are several examples in the FTC SDK examples section, but here is a simplified example. This example makes the VuMark finding code generic, meaning it can be used for any VuMark, and puts that code in its own class. This makes the opMode itself simple, it just looks for a VuMark and when found, converts the VuMarks id information to the form (enum) used by the Relic Recovery game. The example also shows X (left/right), Y (up/down) and Z (distance) offsets of the center of the Vumark image in relation to the center of the camera field of view.

Note: To use Vuforia you will need an API Key from the Vuforia Developer web site. You can register and get a free developer key to use in your program. If you plan to use a  webcam, be sure to get the API Key for external cameras.

The code supports both phone camera and USB webcam (Control Hub) by changing which constructor you use to create an instance of the VuMarkFinder class. Here is more about using web cams including the Driver Station camera preview feature.

 

Material Type: 
Lab Activity
Education Level: 
Middle School
High School
Focus Subject: 
Computing / Computer Science
Robotics Software
HW Platform: 
Tetrix
SW Platform: 
Java
Interactivity Style: 
Mixed