1 from docopt
import docopt
5 from .map_parser
import parse
6 from .marker
import Marker, generate_markers
8 from .world
import load_world, add_model, save_world
13 aruco_gen - Script for ArUco map/model generation. 14 Generates ArUco models from their description and optionally 15 adds them to an existing Gazebo world. 18 aruco_gen [--offset-x=<m>] [--offset-y=<m>] [--offset-z=<m>] 19 [--offset-roll=<rad>] [--offset-pitch=<rad>] [--offset-yaw=<rad>] 20 [--dictionary=<id>] [--single-model] 21 [--source-world=<path>] [--inplace] 27 -h, --help Show this screen. 28 --offset-x=<m> X offset in meters [default: 0]. 29 --offset-y=<m> Y offset in meters [default: 0]. 30 --offset-z=<m> Z offset in meters [default: 0]. 31 --offset-roll=<rad> roll offset in radians [default: 0]. 32 --offset-pitch=<rad> pitch offset in radians [default: 0]. 33 --offset-yaw=<rad> yaw offset in radians [default: 0]. 34 --dictionary=<id> ArUco dictionary ID [default: 2]. 35 --single-model Generate a single model instead of individual 37 --source-world=<path> Path to existing Gazebo world. 38 --inplace Modify source world. 39 --model-path=<path> Folder where generated models will be saved 40 [default: ~/.gazebo/models] 41 aruco_map_file Full path to the ArUco map file 49 dictionary_id = int(opts[
'--dictionary'])
50 mapfile = opts[
'<aruco_map_file>']
51 single_model = opts[
'--single-model']
52 source_world = opts[
'--source-world']
53 inplace = opts[
'--inplace']
55 off_x = float(opts[
'--offset-x'])
56 off_y = float(opts[
'--offset-y'])
57 off_z = float(opts[
'--offset-z'])
58 off_roll = float(opts[
'--offset-roll'])
59 off_pitch = float(opts[
'--offset-pitch'])
60 off_yaw = float(opts[
'--offset-yaw'])
62 model_base_path = path.expanduser(opts[
'--model-path'])
64 markers =
parse(mapfile)
67 mapname = path.split(mapfile)[-1]
68 model_path = path.join(model_base_path,
'aruco_{}'.format(mapname.replace(
'.',
'_')))
69 generate_markers(markers, model_path, dictionary_id=dictionary_id, map_source=mapname)
71 for marker
in markers:
72 model_name =
'aruco_{}_{}'.format(dictionary_id, marker.id_)
73 model_path = path.join(model_base_path, model_name)
75 model_path, dictionary_id=dictionary_id)
77 if source_world
is not None:
80 world_tree =
add_model(world_tree,
'aruco_{}'.format(mapname.replace(
'.',
'_')),
82 off_roll, off_pitch, off_yaw)
84 if (abs(off_roll) > 0.001)
or (abs(off_pitch) > 0.001)
or (abs(off_yaw) > 0.001):
85 raise NotImplementedError(
'Sorry, angular offsets are not currently implemented for multimodel generation')
86 for marker
in markers:
87 world_tree =
add_model(world_tree,
'aruco_{}_{}'.format(dictionary_id, marker.id_),
88 off_x + marker.x, off_y + marker.y, off_z + marker.z,
89 marker.roll, marker.pitch, marker.yaw)
91 output = open(source_world,
'w')
if inplace
else stdout
def generate_markers(markers, model_directory, dictionary_id=2, map_source='')
def load_world(world_file)
def add_model(world, model_name, x, y, z, roll, pitch, yaw, index=0)
def save_world(world, file)