-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate april-tag image and plate stl file
- Loading branch information
1 parent
e172251
commit 86af3fc
Showing
6 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
jsk_pr2_robot/jsk_pr2_accessories/pr2_hand_apriltag/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/build | ||
*.stl | ||
*.out | ||
*.log | ||
*.aux | ||
*.dvi |
32 changes: 32 additions & 0 deletions
32
jsk_pr2_robot/jsk_pr2_accessories/pr2_hand_apriltag/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
OPENSCAD_CHECK := $(shell command -v openscad 2> /dev/null) | ||
PDFLATEX_CHECK := $(shell command -v pdflatex 2> /dev/null) | ||
|
||
all: check-deps build/tag_plate.stl build/april_tag_print.pdf | ||
|
||
check-deps: | ||
ifndef OPENSCAD_CHECK | ||
$(error "OpenSCAD is required. Please install: sudo apt install openscad") | ||
endif | ||
ifndef PDFLATEX_CHECK | ||
$(error "pdflatex is required. Please install: sudo apt install texlive-base") | ||
endif | ||
|
||
build/tag_plate.stl: tag_plate.scad | ||
mkdir -p build | ||
openscad -o $@ $< | ||
echo "Generated $@" | ||
|
||
build/tag_with_margin.png: rotate_and_add_margin.py | ||
mkdir -p build | ||
python3 ./rotate_and_add_margin.py tag41_12_00000.png $@ | ||
echo "Generated $@" | ||
|
||
build/april_tag_print.pdf: april_tag_print.tex build/tag_with_margin.png | ||
mkdir -p build | ||
pdflatex -output-directory=build $< | ||
echo "Generated $@" | ||
|
||
clean: | ||
rm -rf build | ||
|
||
.PHONY: all clean check-deps |
19 changes: 19 additions & 0 deletions
19
jsk_pr2_robot/jsk_pr2_accessories/pr2_hand_apriltag/april_tag_print.tex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
\documentclass{article} | ||
\usepackage{graphicx} | ||
\usepackage[margin=1cm]{geometry} | ||
\usepackage{subfigure} | ||
\usepackage{xcolor} | ||
|
||
\begin{document} | ||
|
||
\setlength{\fboxsep}{0pt} | ||
\setlength{\fboxrule}{0.5pt} | ||
\definecolor{lightgray}{gray}{0.8} | ||
|
||
\begin{figure}[htbp] | ||
\centering | ||
\fcolorbox{lightgray}{white}{\includegraphics[scale=1.685]{./build/tag_with_margin.png}} | ||
\caption{5cm x 5cm AprilTags with white margin. Please print on A4 paper and cut along the gray lines.} | ||
\end{figure} | ||
|
||
\end{document} |
32 changes: 32 additions & 0 deletions
32
jsk_pr2_robot/jsk_pr2_accessories/pr2_hand_apriltag/rotate_and_add_margin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from PIL import Image | ||
import argparse | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('input', help='input image path') | ||
parser.add_argument('output', help='output image path') | ||
args = parser.parse_args() | ||
|
||
img = Image.open(args.input) | ||
img = img.rotate(90) | ||
|
||
if img.width != img.height: | ||
raise ValueError("Input image must be square") | ||
|
||
# increas the resolution of image by 10 times because the original image is too small! | ||
img = img.resize((img.width * 10, img.width * 10), Image.NEAREST) | ||
|
||
w = img.width | ||
w_B = int(w * (63 / 50)) | ||
h_B = int(w * (55 / 50)) | ||
margin_left = (w_B - w) // 2 | ||
margin_top = (h_B - w) // 2 | ||
|
||
new_img = Image.new('RGB', (w_B, h_B), (255, 255, 255)) | ||
new_img.paste(img, (margin_left, margin_top)) | ||
new_img.save(args.output) | ||
|
||
if __name__ == '__main__': | ||
main() |
Binary file added
BIN
+113 Bytes
jsk_pr2_robot/jsk_pr2_accessories/pr2_hand_apriltag/tag41_12_00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions
28
jsk_pr2_robot/jsk_pr2_accessories/pr2_hand_apriltag/tag_plate.scad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
board_width = 63; | ||
board_length = 55; | ||
board_height = 6.0; | ||
hole_diameter = 3.2; | ||
screw_head_diameter_with_margin = 6.3; | ||
screw_head_depth_with_margin = 3.2; | ||
|
||
hole_ypos = 15; | ||
hole_interval = 50; | ||
hole1_pos = [(board_width - hole_interval) * 0.5, hole_ypos]; | ||
hole2_pos = [(board_width + hole_interval) * 0.5, hole_ypos]; | ||
|
||
difference() { | ||
cube([board_width, board_length, board_height]); | ||
translate([hole1_pos[0], hole1_pos[1], 0]){ | ||
cylinder(h = board_height, d = hole_diameter, $fn = 32); | ||
} | ||
translate([hole2_pos[0], hole2_pos[1], 0]){ | ||
cylinder(h = board_height, d = hole_diameter, $fn = 32); | ||
} | ||
translate([hole1_pos[0], hole1_pos[1], 0]){ | ||
cylinder(h = screw_head_depth_with_margin, d = screw_head_diameter_with_margin, $fn = 32); | ||
} | ||
translate([hole2_pos[0], hole2_pos[1], 0]){ | ||
cylinder(h = screw_head_depth_with_margin, d = screw_head_diameter_with_margin, $fn = 32); | ||
} | ||
|
||
} |