Skip to content
Snippets Groups Projects
Commit 3c18c4e3 authored by Johannes Mey's avatar Johannes Mey
Browse files

autoformat code

parent 5ace313d
Branches
No related tags found
No related merge requests found
Showing
with 298 additions and 252 deletions
# make_tag
taken from [https://github.com/berndpfrommer/tagslam](https://github.com/berndpfrommer/tagslam/blob/master/src/make_tag.py) under Apache 2.0 license.
taken
from [https://github.com/berndpfrommer/tagslam](https://github.com/berndpfrommer/tagslam/blob/master/src/make_tag.py)
under Apache 2.0 license.
base tags (0-3):
```
python make_tag.py --draw_box --nx 2 --ny 2 --no-symm_corners --tsize 0.08 --borderbits 1 --startid 0 --tspace 0.03 --tfam t36h11 tags.pdf
```
large tags (4-27):
```
python make_tag.py --draw_box --nx 3 --ny 4 --no-symm_corners --tsize 0.052 --borderbits 1 --startid 4 --tspace 0.03 --tfam t36h11 tags.pdf
python make_tag.py --draw_box --nx 3 --ny 4 --no-symm_corners --tsize 0.052 --borderbits 1 --startid 16 --tspace 0.03 --tfam t36h11 tags.pdf
```
small tags (28-75):
```
python make_tag.py --draw_box --nx 6 --ny 8 --no-symm_corners --tsize 0.024 --borderbits 1 --startid 28 --tspace 0.06 --tfam t36h11 tags.pdf
```
\ No newline at end of file
......@@ -2,13 +2,12 @@
# Thomas Schneider, Sept 2013
# Codes from AprilTags C++ Library (http://people.csail.mit.edu/kaess/apriltags/)
from pyx import *
import argparse
import sys
import importlib
import math
import numpy as np
import sys
from pyx import *
class AprilTagCodes:
t16h5=[0x231b, 0x2ea5, 0x346a, 0x45b9, 0x79a6, 0x7f6b, 0xb358, 0xe745, 0xfe59, 0x156d, 0x380b, 0xf0ab, 0x0d84, 0x4736, 0x8c72, 0xaf10, 0x093c, 0x93b4, 0xa503, 0x468f, 0xe137, 0x5795, 0xdf42, 0x1c1d, 0xe9dc, 0x73ad, 0xad5f, 0xd530, 0x07ca, 0xaf2e]
......@@ -32,13 +31,16 @@ class AprilTagCodes:
print("[ERROR]: Unknown tag familiy.")
sys.exit(0)
# borderBits must be consitent with the variable "blackBorder" in the detector code in file ethz_apriltag2/src/TagFamily.cc
def generateAprilTag(canvas, position, metricSize, tagSpacing, tagID, tagFamililyData, rotation=2, symmCorners=True, borderBits=2, ccolor=color.rgb.black, drawBox=False):
def generateAprilTag(canvas, position, metricSize, tagSpacing, tagID, tagFamililyData, rotation=2, symmCorners=True,
borderBits=2, ccolor=color.rgb.black, drawBox=False):
# get the tag code
try:
tagCode = tagFamililyData.tagCodes[tagID]
except:
print("[ERROR]: Requested tag ID of {0} not available in the {1} TagFamiliy".format(tagID, tagFamililyData.chosenTagFamiliy))
print("[ERROR]: Requested tag ID of {0} not available in the {1} TagFamiliy".format(tagID,
tagFamililyData.chosenTagFamiliy))
# calculate the bit size of the tag
sqrtBits = (math.sqrt(tagFamililyData.totalBits))
......@@ -52,8 +54,10 @@ def generateAprilTag(canvas, position, metricSize, tagSpacing, tagID, tagFamilil
borderSize = borderBits / 2 * bitSquareSize
c.fill(path.rect(xPos + borderSize, yPos + borderSize, metricSize - 2 * borderSize, borderSize), [ccolor]) # bottom
c.fill(path.rect(xPos + borderSize, yPos+metricSize-2*borderSize, metricSize-2*borderSize, borderSize),[ccolor]) #top
c.fill(path.rect(xPos+metricSize-2*borderSize, yPos + borderSize, borderSize, metricSize-2*borderSize),[ccolor]) #left
c.fill(path.rect(xPos + borderSize, yPos + metricSize - 2 * borderSize, metricSize - 2 * borderSize, borderSize),
[ccolor]) # top
c.fill(path.rect(xPos + metricSize - 2 * borderSize, yPos + borderSize, borderSize, metricSize - 2 * borderSize),
[ccolor]) # left
c.fill(path.rect(xPos + borderSize, yPos + borderSize, borderSize, metricSize - 2 * borderSize), [ccolor]) # right
# draw name
......@@ -77,7 +81,9 @@ def generateAprilTag(canvas, position, metricSize, tagSpacing, tagID, tagFamilil
for i in range(0, int(sqrtBits)):
for j in range(0, int(sqrtBits)):
if codeMatrix[i, j]:
c.fill(path.rect(xPos+(j+borderBits)*bitSquareSize, yPos+((borderBits-1)+sqrtBits-i)*bitSquareSize, bitSquareSize, bitSquareSize),[ccolor])
c.fill(path.rect(xPos + (j + borderBits) * bitSquareSize,
yPos + ((borderBits - 1) + sqrtBits - i) * bitSquareSize, bitSquareSize,
bitSquareSize), [ccolor])
# add squares to make corners symmetric (decreases the effect of motion blur in the subpix refinement...)
if symmCorners:
......@@ -93,6 +99,7 @@ def generateAprilTag(canvas, position, metricSize, tagSpacing, tagID, tagFamilil
for point in corners:
c.fill(path.rect(point[0], point[1], metricSquareSize, metricSquareSize), [ccolor])
# tagSpaceing in % of tagSize
def generateAprilBoard(canvas, n_cols, n_rows, margx, margy, tagSize, tagSpacing=0.25, tagFamily="t36h11",
acolor="Black", startid=0, borderBits=2, symmCorners=False, drawBox=False):
......@@ -131,7 +138,8 @@ def generateAprilBoard(canvas, n_cols, n_rows, margx, margy, tagSize, tagSpacing
y_off = x_off
pos = (margx * 100 + x * (1 + tagSpacing) * tagSize + x_off,
margy * 100 + y * (1 + tagSpacing) * tagSize + y_off)
generateAprilTag(canvas, pos, tagSize, tagSpacing, id, tagFamilyData, rotation=2, borderBits=borderBits*2, ccolor=ccolor, symmCorners=symmCorners, drawBox=drawBox)
generateAprilTag(canvas, pos, tagSize, tagSpacing, id, tagFamilyData, rotation=2, borderBits=borderBits * 2,
ccolor=ccolor, symmCorners=symmCorners, drawBox=drawBox)
# c.text(pos[0]+0.45*tagSize, pos[1]-0.7*tagSize*tagSpacing, "{0}".format(id))
# draw axis
......@@ -157,26 +165,39 @@ if __name__ == "__main__":
outputOptions.add_argument('output', nargs="?", default="target", help='Output filename')
genericOptions = parser.add_argument_group('Generic grid options')
genericOptions.add_argument('--nx', type=int, default=6, dest='n_cols', help='The number of tags in x direction (default: %(default)s)\n')
genericOptions.add_argument('--ny', type=int, default=7, dest='n_rows', help='The number of tags in y direction (default: %(default)s)')
genericOptions.add_argument('--marginx', type=float, default=0, dest='marginx', help='Margin [m] in x direction (default: %(default)s)')
genericOptions.add_argument('--marginy', type=float, default=0, dest='marginy', help='Margin [m] in y direction (default: %(default)s)')
genericOptions.add_argument('--color', default="Black", dest='color', help='Color in cmyk space (default: %(default)s)')
genericOptions.add_argument('--nx', type=int, default=6, dest='n_cols',
help='The number of tags in x direction (default: %(default)s)\n')
genericOptions.add_argument('--ny', type=int, default=7, dest='n_rows',
help='The number of tags in y direction (default: %(default)s)')
genericOptions.add_argument('--marginx', type=float, default=0, dest='marginx',
help='Margin [m] in x direction (default: %(default)s)')
genericOptions.add_argument('--marginy', type=float, default=0, dest='marginy',
help='Margin [m] in y direction (default: %(default)s)')
genericOptions.add_argument('--color', default="Black", dest='color',
help='Color in cmyk space (default: %(default)s)')
aprilOptions = parser.add_argument_group('Apriltag arguments')
aprilOptions.add_argument('--tsize', type=float, default=0.08, dest='tsize', help='The size of one tag [m] (default: %(default)s)')
aprilOptions.add_argument('--tspace', type=float, default=0.3, dest='tagspacing', help='The space between the tags in fraction of the edge size [0..1] (default: %(default)s)')
aprilOptions.add_argument('--tfam', default='t36h11', dest='tagfamiliy', help='Familiy of April tags {0} (default: %(default)s)'.format(AprilTagCodes.TagFamilies.keys()))
aprilOptions.add_argument('--startid', default=0, type=int, dest='startid', help='Start number for apriltag (default: %(default)s)')
aprilOptions.add_argument('--borderbits', default=2, type=int, dest='borderBits', help='number of bits used for black border (default: %(default)s)')
aprilOptions.add_argument('--symm_corners', dest='symmCorners', action='store_true', help='add black corner squares')
aprilOptions.add_argument('--no-symm_corners', dest='symmCorners', action='store_false', help='do not add black corner squares (default)')
aprilOptions.add_argument('--tsize', type=float, default=0.08, dest='tsize',
help='The size of one tag [m] (default: %(default)s)')
aprilOptions.add_argument('--tspace', type=float, default=0.3, dest='tagspacing',
help='The space between the tags in fraction of the edge size [0..1] (default: %(default)s)')
aprilOptions.add_argument('--tfam', default='t36h11', dest='tagfamiliy',
help='Familiy of April tags {0} (default: %(default)s)'.format(
AprilTagCodes.TagFamilies.keys()))
aprilOptions.add_argument('--startid', default=0, type=int, dest='startid',
help='Start number for apriltag (default: %(default)s)')
aprilOptions.add_argument('--borderbits', default=2, type=int, dest='borderBits',
help='number of bits used for black border (default: %(default)s)')
aprilOptions.add_argument('--symm_corners', dest='symmCorners', action='store_true',
help='add black corner squares')
aprilOptions.add_argument('--no-symm_corners', dest='symmCorners', action='store_false',
help='do not add black corner squares (default)')
aprilOptions.add_argument('--draw_box', dest='drawBox', action='store_true', help='draw thin black bounding box')
aprilOptions.add_argument('--no-draw_box', dest='drawBox', action='store_false', help='do not draw thin black bounding box (default)')
aprilOptions.add_argument('--no-draw_box', dest='drawBox', action='store_false',
help='do not draw thin black bounding box (default)')
aprilOptions.set_defaults(symmCorners=False)
aprilOptions.set_defaults(drawBox=False)
if len(sys.argv) == 1:
parser.print_help()
sys.exit(0)
......@@ -190,7 +211,9 @@ if __name__ == "__main__":
# open a new canvas
c = canvas.canvas()
generateAprilBoard(canvas, parsed.n_cols, parsed.n_rows, parsed.marginx, parsed.marginy, parsed.tsize, parsed.tagspacing, parsed.tagfamiliy, parsed.color, parsed.startid, borderBits=parsed.borderBits, symmCorners=parsed.symmCorners, drawBox=parsed.drawBox)
generateAprilBoard(canvas, parsed.n_cols, parsed.n_rows, parsed.marginx, parsed.marginy, parsed.tsize,
parsed.tagspacing, parsed.tagfamiliy, parsed.color, parsed.startid, borderBits=parsed.borderBits,
symmCorners=parsed.symmCorners, drawBox=parsed.drawBox)
# write to file
c.writePDFfile(parsed.output)
<launch>
<!-- MQTT server for communication with client cells -->
<arg name="mqtt_server" default="tcp://127.0.0.1:1883" doc="address of the mqtt server for the connection to the controller"/>
<arg name="mqtt_server" default="tcp://127.0.0.1:1883"
doc="address of the mqtt server for the connection to the controller"/>
<arg name="connection_address" default="tcp://*:6576"/>
......@@ -10,7 +11,8 @@
<param name="arm" type="string" value="arm1"/>
<param name="other_cell" type="string" value="/ceti_cell_2_placeworld/scene/update"/>
<param name="mqtt_server" type="yaml" value="$(arg mqtt_server)"/>
<param name="scene" type="string" value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-placeworld.json"/>
<param name="scene" type="string"
value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-placeworld.json"/>
</node>
</launch>
<launch>
<!-- MQTT server for communication with client cells -->
<arg name="mqtt_server" default="tcp://192.168.0.122:1883" doc="address of the mqtt server for the connection to the controller"/>
<arg name="mqtt_server" default="tcp://192.168.0.122:1883"
doc="address of the mqtt server for the connection to the controller"/>
<arg name="connection_address" default="tcp://*:6576"/>
......@@ -11,7 +12,8 @@
<param name="arm" type="string" value="arm2"/>
<param name="other_cell" type="string" value="/ceti_cell_placeworld/scene/update"/>
<param name="mqtt_server" type="yaml" value="$(arg mqtt_server)"/>
<param name="scene" type="string" value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-placeworld.json"/>
<param name="scene" type="string"
value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-placeworld.json"/>
</node>
</launch>
<launch>
<!-- MQTT server for communication with client cells -->
<arg name="mqtt_server" default="tcp://localhost:1883" doc="address of the mqtt server for the connection to the controller"/>
<arg name="mqtt_server" default="tcp://localhost:1883"
doc="address of the mqtt server for the connection to the controller"/>
<include file="$(find ccf)/launch/simulation_setup.launch"/>
......@@ -9,7 +10,8 @@
<param name="arm" type="string" value="arm1"/>
<param name="other_cell" type="string" value="/ceti_cell_2_placeworld/scene/update"/>
<param name="mqtt_server" type="yaml" value="$(arg mqtt_server)"/>
<param name="scene" type="string" value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-placeworld.json"/>
<param name="scene" type="string"
value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-placeworld.json"/>
</node>
</launch>
<launch>
<!-- MQTT server for communication with client cells -->
<arg name="mqtt_server" default="tcp://192.168.0.122:1883" doc="address of the mqtt server for the connection to the controller"/>
<arg name="mqtt_server" default="tcp://192.168.0.122:1883"
doc="address of the mqtt server for the connection to the controller"/>
<!-- robot IP used by the robot controller -->
<arg name="robot_ip" default="172.31.1.13" doc="ip address if the robot"/>
......@@ -14,7 +15,8 @@
<param name="arm" type="string" value="arm2"/>
<param name="other_cell" type="string" value="/ceti_cell_placeworld/scene/update"/>
<param name="mqtt_server" type="yaml" value="$(arg mqtt_server)"/>
<param name="scene" type="string" value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-placeworld.json"/>
<param name="scene" type="string"
value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-placeworld.json"/>
</node>
</launch>
<launch>
<!-- MQTT server for communication with client cells -->
<arg name="mqtt_server" default="tcp://localhost:1883" doc="address of the mqtt server for the connection to the controller"/>
<arg name="mqtt_server" default="tcp://localhost:1883"
doc="address of the mqtt server for the connection to the controller"/>
<include file="$(find ccf)/launch/noop-sim_setup.launch"/>
......@@ -11,7 +12,8 @@
<param name="arm" type="string" value="arm"/>
<param name="scene_observer" type="string" value="object_locator/scene/update"/>
<param name="mqtt_server" type="yaml" value="$(arg mqtt_server)"/>
<param name="scene" type="string" value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-1-empty-coloured.json"/>
<param name="scene" type="string"
value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-1-empty-coloured.json"/>
</node>
</launch>
<launch>
<!-- MQTT server for communication with client cells -->
<arg name="mqtt_server" default="tcp://localhost:1883" doc="address of the mqtt server for the connection to the controller"/>
<arg name="mqtt_server" default="tcp://localhost:1883"
doc="address of the mqtt server for the connection to the controller"/>
<include file="$(find ccf)/launch/noop-sim_setup.launch"/>
......@@ -11,7 +12,8 @@
<param name="arm" type="string" value="arm"/>
<param name="scene_observer" type="string" value="object_locator/scene/update"/>
<param name="mqtt_server" type="yaml" value="$(arg mqtt_server)"/>
<param name="scene" type="string" value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-1-empty-grey.json"/>
<param name="scene" type="string"
value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-1-empty-grey.json"/>
</node>
</launch>
<launch>
<!-- MQTT server for communication with client cells -->
<arg name="mqtt_server" default="tcp://localhost:1883" doc="address of the mqtt server for the connection to the controller"/>
<arg name="mqtt_server" default="tcp://localhost:1883"
doc="address of the mqtt server for the connection to the controller"/>
<!-- Use rviz -->
<arg name="use_rviz" default="true" doc="use rviz"/>
......@@ -16,7 +17,8 @@
<param name="arm" type="string" value="arm1"/>
<param name="other_cell" type="string" value="/ceti_cell_2_placeworld/scene/delta-update"/>
<param name="mqtt_server" type="yaml" value="$(arg mqtt_server)"/>
<param name="scene" type="string" value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-placeworld.json"/>
<param name="scene" type="string"
value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-placeworld.json"/>
</node>
</launch>
<launch>
<!-- MQTT server for communication with client cells -->
<arg name="mqtt_server" default="tcp://192.168.0.122:1883" doc="address of the mqtt server for the connection to the controller"/>
<arg name="mqtt_server" default="tcp://192.168.0.122:1883"
doc="address of the mqtt server for the connection to the controller"/>
<include file="$(find ccf)/launch/noop-sim_setup.launch"/>
......@@ -11,7 +12,8 @@
<param name="arm" type="string" value="arm2"/>
<param name="other_cell" type="string" value="/ceti_cell_placeworld/scene/delta-update"/>
<param name="mqtt_server" type="yaml" value="$(arg mqtt_server)"/>
<param name="scene" type="string" value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-placeworld.json"/>
<param name="scene" type="string"
value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-placeworld.json"/>
</node>
</launch>
<launch>
<!-- MQTT server for communication with client cells -->
<arg name="mqtt_server" default="tcp://localhost:1883" doc="address of the mqtt server for the connection to the controller"/>
<arg name="mqtt_server" default="tcp://localhost:1883"
doc="address of the mqtt server for the connection to the controller"/>
<!-- robot IP used by the robot controller -->
<arg name="robot_ip" default="172.31.1.13" doc="ip address if the robot"/>
......@@ -17,7 +18,8 @@
<param name="arm" type="string" value="arm"/>
<param name="scene_observer" type="string" value="object_locator/scene/update"/>
<param name="mqtt_server" type="yaml" value="$(arg mqtt_server)"/>
<param name="scene" type="string" value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-1-empty-coloured.json"/>
<param name="scene" type="string"
value="$(find ccf_immersive_sorting)/config/config_scene_ceti-table-1-empty-coloured.json"/>
</node>
</launch>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment