-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from methylDragon/ch3/author-namespaced-thumb…
…nails Support Author-namedspaced Thumbnails and Revamp building_map_generator
- Loading branch information
Showing
27 changed files
with
231 additions
and
112 deletions.
There are no files selected for viewing
File renamed without changes.
50 changes: 50 additions & 0 deletions
50
building_map_tools/building_map_generator/_init_argparse.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,50 @@ | ||
import argparse | ||
|
||
# Init overall parser and subparser | ||
parser = argparse.ArgumentParser( | ||
prog="building_map_generator", | ||
description="Generate .world files, map models, and navigation maps" | ||
"for running in Gazebo or Ignition!" | ||
) | ||
subparsers = parser.add_subparsers(help="Commands:", dest="command") | ||
|
||
# Init shared parser | ||
sim_parser = argparse.ArgumentParser(add_help=False) | ||
sim_parser.add_argument("INPUT", type=str, | ||
help="Input building.yaml file to process") | ||
sim_parser.add_argument("OUTPUT_WORLD", type=str, | ||
help="Name of the .world file to output") | ||
sim_parser.add_argument("OUTPUT_MODEL_DIR", type=str, | ||
help="Path to output the map model files") | ||
sim_parser.add_argument("-o", "--options", type=str, nargs='*', default=[], | ||
help="Generator options") | ||
|
||
# Create subparsers for Gazebo, Ignition, and Nav generation | ||
gazebo_parser = subparsers.add_parser( | ||
'gazebo', | ||
help='Generate .world file and map model.sdf for Gazebo', | ||
parents=[sim_parser] | ||
) | ||
gazebo_parser.add_argument("-n", "--no_download", default=False, | ||
const=True, action="store_const", | ||
help="Do not download missing models from Fuel") | ||
gazebo_parser.add_argument("-m", "--model_path", type=str, | ||
help="Gazebo model path to check for models") | ||
gazebo_parser.add_argument("-c", "--cache", type=str, | ||
help="Path to pit_crew model cache") | ||
|
||
|
||
ignition_parser = subparsers.add_parser( | ||
'ignition', | ||
help='Generate .world file and map model.sdf for Ignition', | ||
parents=[sim_parser] | ||
) | ||
|
||
nav_parser = subparsers.add_parser( | ||
'nav', | ||
help='Generate nav map .yaml file', | ||
) | ||
nav_parser.add_argument("INPUT", type=str, | ||
help="Input building.yaml file to process") | ||
nav_parser.add_argument("OUTPUT_DIR", type=str, | ||
help="Path to output the nav .yaml files") |
72 changes: 72 additions & 0 deletions
72
building_map_tools/building_map_generator/building_map_generator.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,72 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from building_map.generator import Generator | ||
from building_map_generator._init_argparse import parser | ||
|
||
import pit_crew | ||
import logging | ||
import sys | ||
|
||
handler = logging.StreamHandler(sys.stdout) | ||
handler.setFormatter(pit_crew.PitCrewFormatter()) | ||
logger = logging.getLogger() | ||
logger.addHandler(handler) | ||
logger.setLevel(logging.INFO) | ||
|
||
|
||
def main(): | ||
args = parser.parse_args() | ||
g = Generator() | ||
|
||
if args.command == "gazebo": | ||
# Construct model set | ||
model_set = set() | ||
|
||
if not args.no_download: | ||
building = g.parse_editor_yaml(args.INPUT) | ||
|
||
for _, level in building.levels.items(): | ||
for model in level.models: | ||
model_set.add(model.model_name) | ||
|
||
missing_models = pit_crew.get_missing_models( | ||
model_set, | ||
model_path=args.model_path, | ||
cache_file_path=args.cache | ||
) | ||
|
||
for downloadable_model in missing_models['downloadable']: | ||
model_name, author_name = downloadable_model | ||
|
||
# TODO: For now it just picks the first author | ||
# When model authors are put into the thumbnails, then we can | ||
# use that instead | ||
logger.info("\nDownloading %s by %s from Fuel" | ||
% (model_name, author_name[0])) | ||
|
||
pit_crew.download_model(model_name, author_name[0], | ||
download_path=args.model_path) | ||
|
||
logger.warning("\nUnavailable models (not in local or Fuel): %s" | ||
% missing_models['missing']) | ||
|
||
g.generate_gazebo_sdf( | ||
args.INPUT, | ||
args.OUTPUT_WORLD, | ||
args.OUTPUT_MODEL_DIR, | ||
args.options | ||
) | ||
|
||
if args.command == "ignition": | ||
g.generate_ignition_sdf( | ||
args.INPUT, | ||
args.OUTPUT_WORLD, | ||
args.OUTPUT_MODEL_DIR, | ||
args.options | ||
) | ||
|
||
if args.command == "nav": | ||
g.generate_nav(args.INPUT, args.OUTPUT_DIR) | ||
|
||
if __name__ == "__main__": | ||
main() |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
20 changes: 0 additions & 20 deletions
20
building_map_tools/building_map_generators/building_map_gazebo.py
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
building_map_tools/building_map_generators/building_map_ignition.py
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
building_map_tools/building_map_generators/building_map_nav.py
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
Oops, something went wrong.