Skip to content

Commit

Permalink
Pass locations and objects in add_metadata as list
Browse files Browse the repository at this point in the history
  • Loading branch information
kumar-sanjeeev committed Jan 4, 2025
1 parent 301e282 commit 4a836e4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
15 changes: 8 additions & 7 deletions pyrobosim/examples/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ def create_world(multirobot=False):

# Set the location and object metadata
world.add_metadata(
locations=os.path.join(data_folder, "example_location_data_furniture.yaml"),
objects=os.path.join(data_folder, "example_object_data_food.yaml"),
)

world.add_metadata(
locations=[os.path.join(data_folder, "example_location_data_accessories.yaml")],
objects=[os.path.join(data_folder, "example_object_data_drink.yaml")],
locations=[
os.path.join(data_folder, "example_location_data_furniture.yaml"),
os.path.join(data_folder, "example_location_data_accessories.yaml"),
],
objects=[
os.path.join(data_folder, "example_object_data_food.yaml"),
os.path.join(data_folder, "example_object_data_drink.yaml"),
],
)

# Add rooms
Expand Down
16 changes: 10 additions & 6 deletions pyrobosim/test/core/test_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@ def test_create_world_default():
"""Tests the creation of a world"""

TestWorldModeling.world = World()
# to reset the sources from previous testcases
TestWorldModeling.world.get_location_metadata().sources = []
TestWorldModeling.world.get_object_metadata().sources = []

data_folder = get_data_folder()
TestWorldModeling.world.set_metadata(
locations=os.path.join(data_folder, "example_location_data_furniture.yaml"),
objects=os.path.join(data_folder, "example_object_data_food.yaml"),
)
TestWorldModeling.world.add_metadata(
locations=[
os.path.join(data_folder, "example_location_data_accessories.yaml")
os.path.join(data_folder, "example_location_data_furniture.yaml"),
os.path.join(data_folder, "example_location_data_accessories.yaml"),
],
objects=[
os.path.join(data_folder, "example_object_data_food.yaml"),
os.path.join(data_folder, "example_object_data_drink.yaml"),
],
objects=[os.path.join(data_folder, "example_object_data_drink.yaml")],
)

assert isinstance(TestWorldModeling.world, World)
assert len(TestWorldModeling.world.get_location_metadata().sources) == 2
assert len(TestWorldModeling.world.get_object_metadata().sources) == 2
Expand Down
15 changes: 8 additions & 7 deletions pyrobosim_ros/examples/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ def create_world():

# Set the location and object metadata
world.add_metadata(
locations=os.path.join(data_folder, "example_location_data_furniture.yaml"),
objects=os.path.join(data_folder, "example_object_data_food.yaml"),
)

world.add_metadata(
locations=[os.path.join(data_folder, "example_location_data_accessories.yaml")],
objects=[os.path.join(data_folder, "example_object_data_drink.yaml")],
locations=[
os.path.join(data_folder, "example_location_data_furniture.yaml"),
os.path.join(data_folder, "example_location_data_accessories.yaml"),
],
objects=[
os.path.join(data_folder, "example_object_data_food.yaml"),
os.path.join(data_folder, "example_object_data_drink.yaml"),
],
)

# Add rooms
Expand Down

0 comments on commit 4a836e4

Please sign in to comment.