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 python bindings for sdf::Element and sdf::Param #1303

Merged
merged 10 commits into from
Aug 22, 2023

Conversation

azeey
Copy link
Collaborator

@azeey azeey commented Jul 28, 2023

🎉 New feature

Addition to #931

Summary

My intention was to add just sdf::Element, but sdf::Param was needed for many of the useful APIs. Similarly, PrintConfig was also added here.

Test it

ctest -R pyElement
ctest -R pyParam
ctest -R pyPrintConfig

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@github-actions github-actions bot added 🌱 garden Ignition Garden 🎵 harmonic Gazebo Harmonic labels Jul 28, 2023
@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

Merging #1303 (3f080d9) into main (88e343b) will decrease coverage by 0.30%.
The diff coverage is 74.65%.

❗ Current head 3f080d9 differs from pull request most recent head fefd53c. Consider uploading reports for the commit fefd53c to get more accurate results

@@            Coverage Diff             @@
##             main    #1303      +/-   ##
==========================================
- Coverage   87.64%   87.35%   -0.30%     
==========================================
  Files         128      133       +5     
  Lines       16837    17133     +296     
==========================================
+ Hits        14757    14966     +209     
- Misses       2080     2167      +87     
Files Changed Coverage Δ
src/Exception.cc 77.14% <ø> (-20.08%) ⬇️
python/src/sdf/pyPrintConfig.cc 64.28% <64.28%> (ø)
python/src/sdf/pyParam.cc 70.93% <70.93%> (ø)
python/src/sdf/pyElement.cc 73.72% <73.72%> (ø)
python/src/sdf/pybind11_helpers.hh 91.66% <91.66%> (ø)
include/sdf/Param.hh 78.49% <100.00%> (-3.44%) ⬇️
python/src/sdf/_gz_sdformat_pybind11.cc 100.00% <100.00%> (ø)
python/src/sdf/pyParam.hh 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

python/src/sdf/pyElement.cc Show resolved Hide resolved
Comment on lines 204 to 209
// get_attributes
// get_attribute (index)
// get_element_description_count
// get_element_description (index)
// get_element_description (string)
// has_element_description
Copy link
Collaborator

Choose a reason for hiding this comment

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

are these TODOs ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I've implemented some of them. The rest, I have commented why I didn't think we need to implement them.

python/test/pyElement_TEST.py Outdated Show resolved Hide resolved
@azeey azeey added the beta Targeting beta release of upcoming collection label Jul 31, 2023
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
@azeey azeey changed the base branch from sdf13 to main August 17, 2023 15:29
@azeey azeey marked this pull request as ready for review August 17, 2023 15:30
@azeey azeey requested a review from scpeters as a code owner August 17, 2023 15:30
@azeey azeey removed the 🌱 garden Ignition Garden label Aug 17, 2023
@azeey
Copy link
Collaborator Author

azeey commented Aug 17, 2023

I've retargeted this to main to speed up development in gz-sim. Will backport to sdf13 later.

@azeey azeey changed the title Add python bindings for sdf::Element Add python bindings for sdf::Element and sdf::Param Aug 17, 2023
@azeey azeey requested a review from Voldivh August 17, 2023 15:34
Copy link
Contributor

@Voldivh Voldivh left a comment

Choose a reason for hiding this comment

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

Overall looks good, left couple of comments.

python/src/sdf/pyPrintConfig.cc Show resolved Hide resolved
Comment on lines +64 to +67
.def("clone", ErrorWrappedCast<>(&Element::Clone, py::const_),
"Create a copy of this Element.")
.def("copy", ErrorWrappedCast<ElementPtr>(&Element::Copy),
"Copy values from an Element.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment here, is this wrapper enough for both implementations of the methods?

python/src/sdf/pyElement.cc Show resolved Hide resolved
python/src/sdf/pyParam.cc Show resolved Hide resolved
python/test/pyElement_TEST.py Outdated Show resolved Hide resolved
python/test/pyElement_TEST.py Show resolved Hide resolved
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Copy link
Contributor

@Voldivh Voldivh left a comment

Choose a reason for hiding this comment

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

LGTM!

@azeey azeey merged commit c7560db into gazebosim:main Aug 22, 2023
5 checks passed
@azeey azeey deleted the elemement_python branch August 22, 2023 19:36
@azeey azeey mentioned this pull request Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Targeting beta release of upcoming collection 🎵 harmonic Gazebo Harmonic
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants