genmap.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright (C) 2018 Copter Express Technologies
4 #
5 # Author: Oleg Kalachev <okalachev@gmail.com>
6 #
7 # Distributed under MIT License (available at https://opensource.org/licenses/MIT).
8 # The above copyright notice and this permission notice shall be included in all
9 # copies or substantial portions of the Software.
10 
11 """Markers map generator
12 
13 Generate map file for aruco_map nodelet.
14 
15 Usage:
16  genmap.py <length> <x> <y> <dist_x> <dist_y> [<first>] [<x0>] [<y0>] [--top-left | --bottom-left]
17  genmap.py (-h | --help)
18 
19 Options:
20  <length> Marker side length
21  <x> Marker count along X axis
22  <y> Marker count along Y axis
23  <dist_x> Distance between markers along X axis
24  <dist_y> Distance between markers along Y axis
25  <first> First marker ID [default: 0]
26  <x0> X coordinate for the first marker [default: 0]
27  <y0> Y coordinate for the first marker [default: 0]
28  --top-left First marker is on top-left (default)
29  --bottom-left First marker is on bottom-left
30 
31 Example:
32  rosrun aruco_pose genmap.py 0.33 2 4 1 1 0 > $(catkin_find aruco_pose map)/test_map.txt
33 """
34 
35 from __future__ import print_function
36 
37 from docopt import docopt
38 
39 
40 arguments = docopt(__doc__)
41 
42 length = float(arguments['<length>'])
43 first = int(arguments['<first>'] if arguments['<first>'] is not None else 0)
44 x0 = float(arguments['<x0>'] if arguments['<x0>'] is not None else 0)
45 y0 = float(arguments['<y0>'] if arguments['<y0>'] is not None else 0)
46 markers_x = int(arguments['<x>'])
47 markers_y = int(arguments['<y>'])
48 dist_x = float(arguments['<dist_x>'])
49 dist_y = float(arguments['<dist_y>'])
50 bottom_left = arguments['--bottom-left']
51 
52 max_y = y0 + (markers_y - 1) * dist_y
53 
54 print('# id\tlength\tx\ty\tz\trot_z\trot_y\trot_x')
55 for y in range(markers_y):
56  for x in range(markers_x):
57  pos_x = x0 + x * dist_x
58  pos_y = y0 + y * dist_y
59  if not bottom_left:
60  pos_y = max_y - pos_y
61  print('{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}'.format(first, length, pos_x, pos_y, 0, 0, 0, 0))
62  first += 1


aruco_pose
Author(s): Oleg Kalachev
autogenerated on Mon Feb 28 2022 22:08:24