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

Support Multiple Sources of Location and Object Metadata #315

Merged
merged 18 commits into from
Jan 6, 2025

Conversation

kumar-sanjeeev
Copy link
Contributor

This is a draft PR to showcase proof-of-concept of accepting multiple sources of locations an objects metadata.

  • add an add_metadata method to the World, Location, and Object classes, replacing the set_metadata method.
  • update the EntityMetadata class to support multiple sources of location and object metadata.
  • split the example_location_data.yaml and example_object_data.yaml files into separate files to simulate scenarios with multiple sources of metadata.
  • tested the functionality using the demo.py script with various test worlds specified in form of YAML files in data directory,

Note: Test cases have not been updated yet to reflect the new changes. Will do if this proof-of-concept is okay.

Copy link
Owner

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Left a combination of high- and low-level comments, let me know what you think.

pyrobosim/pyrobosim/core/locations.py Show resolved Hide resolved
pyrobosim/pyrobosim/core/locations.py Outdated Show resolved Hide resolved
pyrobosim/pyrobosim/core/objects.py Outdated Show resolved Hide resolved
pyrobosim/pyrobosim/core/yaml_utils.py Outdated Show resolved Hide resolved
pyrobosim/pyrobosim/core/yaml_utils.py Outdated Show resolved Hide resolved
pyrobosim/pyrobosim/data/example_location_data1.yaml Outdated Show resolved Hide resolved
pyrobosim/pyrobosim/utils/general.py Outdated Show resolved Hide resolved
pyrobosim/pyrobosim/utils/general.py Outdated Show resolved Hide resolved
pyrobosim/pyrobosim/utils/general.py Show resolved Hide resolved
pyrobosim/pyrobosim/utils/general.py Show resolved Hide resolved
@kumar-sanjeeev
Copy link
Contributor Author

Looks great! Left a combination of high- and low-level comments, let me know what you think.

Thanks for reviewing. I will go through the comments in detail and get back to you. In short, I agree with keeping set_metadata and also in favor of adding add_metadata as an additional functionality.

@kumar-sanjeeev
Copy link
Contributor Author

I tried to address all the comments and tested the changes with existing test cases and documentation generation. Everything seems fine. Please let me know if I missed anything. If all looks good, I will add new test cases for the add_metadata method.

Copy link
Owner

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! You can go ahead and add tests.

I think things could be further simplified all around if we allow set_metadata() and add_metadata() to accept lists of file paths in addition to single paths. See my comments throughout.

Also, remember to update docs as well:

pyrobosim/examples/demo.py Show resolved Hide resolved
pyrobosim/examples/demo.py Outdated Show resolved Hide resolved
pyrobosim/pyrobosim/core/locations.py Outdated Show resolved Hide resolved
pyrobosim/pyrobosim/core/objects.py Outdated Show resolved Hide resolved
pyrobosim/pyrobosim/core/objects.py Outdated Show resolved Hide resolved
pyrobosim/pyrobosim/core/yaml_utils.py Outdated Show resolved Hide resolved
pyrobosim/pyrobosim/utils/general.py Outdated Show resolved Hide resolved
pyrobosim/pyrobosim/utils/general.py Outdated Show resolved Hide resolved
pyrobosim/pyrobosim/utils/general.py Outdated Show resolved Hide resolved
@kumar-sanjeeev
Copy link
Contributor Author

Looks great! You can go ahead and add tests.

I think things could be further simplified all around if we allow set_metadata() and add_metadata() to accept lists of file paths in addition to single paths. See my comments throughout.

Also, remember to update docs as well:

Thanks for reviewing !

I reviewed the existing test cases and updated some of them to test the add_metadata method. However, I haven't added any entirely new test cases specifically for add_metadata. If we need to add new test-cases, could you please guide me where I should add them?

I have also updated the documentation and tried to address all the comments. Let me know if there's any room for improvement or if I missed anything.

Copy link
Owner

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks way cleaner -- awesome!

Besides my comments, I think that World.set_metadata() should also support the list option, for consistency with add_metadata().

docs/source/yaml/index.rst Outdated Show resolved Hide resolved
docs/source/yaml/world_schema.rst Outdated Show resolved Hide resolved
pyrobosim/examples/demo.py Outdated Show resolved Hide resolved
pyrobosim/pyrobosim/core/world.py Outdated Show resolved Hide resolved
pyrobosim_ros/examples/demo.py Outdated Show resolved Hide resolved
@kumar-sanjeeev
Copy link
Contributor Author

This looks way cleaner -- awesome!

Besides my comments, I think that World.set_metadata() should also support the list option, for consistency with add_metadata().

I modified World.set_metadata to support list option.

Copy link
Owner

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, just found one more thing and we should be good.

BTW, specifying a single metadata item in a world YAML file (without the - list syntax) still works, right?

pyrobosim/pyrobosim/core/world.py Outdated Show resolved Hide resolved
@kumar-sanjeeev
Copy link
Contributor Author

Cool, just found one more thing and we should be good.

BTW, specifying a single metadata item in a world YAML file (without the - list syntax) still works, right?

Yes it is working, I just checked once again to be sure.

@kumar-sanjeeev
Copy link
Contributor Author

One observation regarding World.add_metadata and World.set_metadata, in the new implementation, we rely on Location.add_metadata and Object.add_metadata. The set_metadata method in both of these classes appears redundant. Should we remove it?

@sea-bass
Copy link
Owner

sea-bass commented Jan 4, 2025

One observation regarding World.add_metadata and World.set_metadata, in the new implementation, we rely on Location.add_metadata and Object.add_metadata. The set_metadata method in both of these classes appears redundant. Should we remove it?

I think it's fine to remove since the add_metadata() and new clearout_metadata() methods will do the job.

by the way, can you rename to clear_metadata() instead? "clearout" isn't very standard naming.

@kumar-sanjeeev kumar-sanjeeev marked this pull request as ready for review January 5, 2025 15:37
@sea-bass sea-bass changed the title Draft: Proof-of-Concept for Supporting Multiple Sources of Location and Object Metadata Support Multiple Sources of Location and Object Metadata Jan 6, 2025
@sea-bass
Copy link
Owner

sea-bass commented Jan 6, 2025

I renamed the issue to remove the "Draft: Proof of Concept", as I saw you've taken this out of draft now.

Is there anything else remaining on your end (some tests or anything), or is this ready to go?

@kumar-sanjeeev
Copy link
Contributor Author

I renamed the issue to remove the "Draft: Proof of Concept", as I saw you've taken this out of draft now.

Is there anything else remaining on your end (some tests or anything), or is this ready to go?

Thanks for renaming.

From my-side it is ready, I have added one test case that you suggested above:

To this end, would be good to have at least one test that checks this by having non-empty metadata, calling set_metadata(), and verifying that anything set before this call is gone.

Copy link
Owner

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- thanks again @kumar-sanjeeev!

@sea-bass sea-bass merged commit 83ea6fd into sea-bass:main Jan 6, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants