Link Search Menu Expand Document

April Tags

  1. Make a printable grid of april tags in pdf form
  2. Setting up a test workspace
  3. Combining april tags with the rest of robot control

Make a printable grid of april tags in pdf form

There are a few PDFs floating around (like this one) with one april tag per page. This makes sense if you are going to hang them on a wall and use them for SLAM, but what if you want to print smaller tags to use with smaller-scale applications (like object tracking during manipulation for example)?

Solution: A bash script

I wrote a bash script to generate pdfs with grids of april tags at a specified real-world size:

resize_tags.sh

Using the script

  1. Download the pre-made apriltag images from thier repo. These images are all tiny (each square in the tag is one pixel)
  2. Fix ImageMagick’s pdf write permissions per these instructions
    • sudo gedit /etc/ImageMagick-6/policy.xml
    • Change PDF rights to rights="read|write"
  3. Increase ImageMagick’s memory allowance per these instructions
    • sudo gedit /etc/ImageMagick-6/policy.xml
    • Change memory value to value="32GB". This should give you enough RAM allowance for lots of high-res images. (Even if you don’t have that amount of ram, your computer should be fine.)
  4. Download my “resize_tags.sh” file, and move it into the root folder of the apriltag-imgs repo.
  5. Open “resize_tags.sh” in a text editor and set the parameters at the top.
     # Set the folder to use
     FILES=tag36h11/*.png  # Set the folder to convert from
    
     # Set the desired width of your tags
     width=30.0         # [mm]  Set the desired width in real units
     dpi=300            # [ppi] Set the dpi (to control the print quality)
     extra_margin=1     # [px]  Add an extra margin around your tags
     default_width=10.0 # [px]  The pixel width of the original images
    
     # Set the grid size your want to make
     grid_h=4           # [num] Number of rows
     grid_w=6           # [num] Number of columns
     grid_filetype=pdf  # [png, jpg, pdf] Set the filetype for the grids
    
     # Decide whether to keep intermediate files
     keep_single_tag_images=false
    
  6. Run the script from a terminal.
    • bash resize_tags.sh
    • A new folder (named by the tag dimension) will be generated inside the folder of whichever tag type you set to resize.
    • Larger images of all individual tags are stored in the new folder.
    • Printable grids are also generated according to your settings.
  7. Print grids. When printing the grid pdfs, be sure to turn off “auto-scaling” and “document scaling” everywhere in the print dialog to ensure all the tags come out the correct real-world size.

Result: PDFs for the standard tags

Since I use the “tag36h11” variant often, I have already generated sets of printable tags in PDF form at various useful dimensions.

30 mm Side Length 60 mm Side Length 100 mm Side Length

The first 24 april tags with side lengths of 30mm in a nice printable grid The first 24 april tags with side lengths of 60mm in a nice printable grid The first 24 april tags with side lengths of 100mm in a nice printable grid

Setting up a test workspace

Building the catkin workspace

  1. Build the workspace: catkin_make_isolated

  2. Add the source to the ~/.bashrc file: source devel_isolated/setup.sh

Run the apriltag detection algorithm

roslaunch usb_cam usb_cam-test.launch roslaunch apriltag_ros continuous_detection.launch

  1. Calibrate the camera (luckily NVidia has the characteristics for the Logitech C920 webcam)

Combining april tags with the rest of robot control

You need to use a separate workspace for apriltags due to some conflicts in the way the apriltags ros package needs to be built.

You can see how to do that in the ROS page