Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to customize the base world file #519

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions rmf_building_map_tools/building_map/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,15 @@ def generate_nav_graphs(self):
nav_graphs[f'{i}'] = g
return nav_graphs

def generate_sdf_world(self):
def generate_sdf_world(self, template_file):
""" Return an etree of this Building in SDF starting from a template"""
template_name = 'gz_world.sdf'

template_path = os.path.join(
get_package_share_directory('rmf_building_map_tools'),
f'templates/{template_name}')
if template_file == "":
template_name = 'gz_world.sdf'
template_path = os.path.join(
get_package_share_directory('rmf_building_map_tools'),
f'templates/{template_name}')
else:
template_path = template_file
tree = parse(template_path)
sdf = tree.getroot()

Expand Down
5 changes: 3 additions & 2 deletions rmf_building_map_tools/building_map/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def generate_sdf(
self,
input_filename,
output_filename,
output_models_dir
output_models_dir,
template_file
):
print('generating {} from {}'.format(output_filename, input_filename))

Expand All @@ -40,7 +41,7 @@ def generate_sdf(
building.generate_sdf_models(output_models_dir)

# generate a top-level SDF for convenience
sdf = building.generate_sdf_world()
sdf = building.generate_sdf_world(template_file)

indent_etree(sdf)
sdf_str = str(ElementToString(sdf), 'utf-8')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
help="Name of the .world file to output")
shared_parser.add_argument("OUTPUT_MODEL_DIR", type=str,
help="Path to output the map model files")

shared_parser.add_argument("--TEMPLATE_WORLD_FILE", type=str, default="",
help="Specify the template for"
+ " the base simulation.")
# Create subparsers for Gazebo and Nav generation
gazebo_parser = subparsers.add_parser(
'gazebo',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def main():
g.generate_sdf(
args.INPUT,
args.OUTPUT_WORLD,
args.OUTPUT_MODEL_DIR
args.OUTPUT_MODEL_DIR,
args.TEMPLATE_WORLD_FILE
)

if args.command == "nav":
Expand Down
Loading