AprilTest demo

From Tekkotsu Wiki

Jump to: navigation, search
Sample run of the AprilTest demo.

The AprilTest demo looks for AprilTags in the 16h5 family and reports what it sees.

Robot type: any platform with a camera

Where to find the demo: Root Control > Framework Demos > Vision Demos > AprilTest

Source code: Tekkotsu/Behaviors/Demos/Vision/AprilTest.cc.fsm

Contents

Setup Instructions

The 30 tags in the 16h5 tag family.

You will need to print out some AprilTags from the 16h5 family (not the 36h11 family used by the TagTest demo) to show to your robot. You can use the image at right, or look at the following files:

/usr/local/Tekkotsu/Vision/AprilTags/tag16h5/alltags.ps
/usr/local/Tekkotsu/Vision/AprilTags/tag16h5/mosaic.png
/usr/local/Tekkotsu/Vision/AprilTags/tag16h5/tag16_05_*.png

The alltags.ps file can be sent directly to a printer; it yields one large tag per page (30 tags total). The mosaic.png file can be blown up and printed as well; it shows all 30 tags on a single page.

Running the Demo

  1. Start Tekkotsu and bring up a RawCam viewer.
  2. Use the ControllerGUI to go to Root Control > Framework Demos > Vision
  3. Single-click on AprilTest to select it, but don't start the behavior yet.
  4. Hold up your paper with one or more AprilTags to the camera, and use the RawCam viewer to make sure the tags are visible.
  5. Hit Enter to start the AprilTest demo. As soon as it starts, you can put the paper down.
  6. When the demo finishes, click on the C button in the ControllerGUI to pop up a camera space SketchGUI to see the detected tags.
  7. Click on rawY in the SketchGUI window to see the grayscale image.
  8. To run the demo again, stop and then start the AprilTags behavior, then click the Reload button in the SketchGUI to view the new results.

Using the MapBuilder to Detect AprilTags

Below is the source code for the AprilTest demo. To ask the MapBuilder to search for AprilTags, you simply tell it what tag family to use. By default, Tekkotsu will use the smallest tag family it knows about, which currently is the 16h5 family. To use a different family, specify the bits and Hamming distance as arguments to the setAprilTagFamily call. The 16h5 and 36h11 families are built in; additional families may be added to Tekkotsu/Vision/AprilTags/TagFamily.cc.

#include "Behaviors/StateMachine.h"

$nodeclass AprilTest : VisualRoutinesStateNode {

  $nodeclass Look : MapBuilderNode($,MapBuilderRequest::cameraMap) : constructor {
    cout << "Point the camera at an April Tag before starting this demo." << endl;
    mapreq.setAprilTagFamily();  // Use the default tag family
   }

  $nodeclass Report : SpeechNode : doStart {
    NEW_SHAPEVEC(tags, AprilTagData, select_type<AprilTagData>(camShS));
    textstream << "I saw " << tags.size() << " april tag"
               << ( tags.size() == 1 ? "" : "s" );
  }

  $setupmachine{
    Look =MAP=> Report
  }

}

REGISTER_BEHAVIOR_MENU(AprilTest,DEFAULT_TK_MENU"/Vision Demos");

Learn More

See the AprilTags article for history, a real-time demo, and an explanation of how the algorithm works. See Lab: AprilTags for exercises using this software.