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

Added Visual Python interface #950

Merged
merged 7 commits into from
Apr 22, 2022
Merged

Added Visual Python interface #950

merged 7 commits into from
Apr 22, 2022

Conversation

ahcorde
Copy link
Collaborator

@ahcorde ahcorde commented Apr 7, 2022

Signed-off-by: ahcorde ahcorde@gmail.com

🎉 New feature

This PR is part of this meta ticket #931

Require:

Summary

Added Visual Python interface

Test it

from sdformat import Visual

visual = Visual()

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • 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.

Signed-off-by: ahcorde <ahcorde@gmail.com>
@ahcorde ahcorde added the scripting Scripting interfaces to Ignition label Apr 7, 2022
@ahcorde ahcorde self-assigned this Apr 7, 2022
@ahcorde ahcorde mentioned this pull request Apr 7, 2022
62 tasks
@github-actions github-actions bot added the 🌱 garden Ignition Garden label Apr 7, 2022
@ahcorde ahcorde marked this pull request as draft April 7, 2022 15:08
@ahcorde ahcorde mentioned this pull request Apr 7, 2022
8 tasks
@ahcorde ahcorde marked this pull request as ready for review April 19, 2022 20:04
@codecov-commenter
Copy link

codecov-commenter commented Apr 19, 2022

Codecov Report

Merging #950 (ee75647) into main (bb84733) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #950   +/-   ##
=======================================
  Coverage   66.66%   66.66%           
=======================================
  Files           2        2           
  Lines          27       27           
=======================================
  Hits           18       18           
  Misses          9        9           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb84733...ee75647. Read the comment docs.

scpeters and others added 2 commits April 19, 2022 15:28
Copy link
Collaborator

@azeey azeey 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. I have question about return value policies that might affect our
other classes.

python/src/sdf/pyVisual.cc Outdated Show resolved Hide resolved
"Get the transparency value of the visual")
.def("set_transparency", &sdf::Visual::SetTransparency,
"Set the transparency value for the visual")
.def("geometry", &sdf::Visual::Geom,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The name of this function is different from the C++ version. Not sure what our policy is on this. @scpeters?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's ok to deviate from the C++ API. We could consider depreciating the C++ names and offering new APIs where it seems like an improvement (such as Geom -> Geometry)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good.

"Get a pointer to the collisions's geometry.")
.def("set_geometry", &sdf::Visual::SetGeom,
"Set the collision's geometry")
.def("raw_pose", &sdf::Visual::RawPose,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This uses return_value_policy::automatic, which makes a copy of lvalue references. Is that what we want? This applies to all the functions that return lvalue references.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But it's a const reference, I thought is fine to return this as a copy. @scpeters ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Most of the items we return are small objects, so returning a copy makes sense. I just wanted to make sure we were doing this intentionally. Technically, it would be a change in behavior in that if I get a raw pose by calling raw_pose then call set_raw_pose, it wouldn't affect the raw pose I obtained earlier whereas in C++ it would.

It would be good to document these kind of differences between the C++ and Python API somewhere. Are we generating python docs and uploading them somewhere for ign-math? If we don't have the infrastructure setup yet, maybe we should put a README in the src/python.

python/src/sdf/pyVisual.cc Outdated Show resolved Hide resolved
python/src/sdf/pyVisual.cc Outdated Show resolved Hide resolved
python/src/sdf/pyVisual.cc Outdated Show resolved Hide resolved
python/src/sdf/pyVisual.cc Outdated Show resolved Hide resolved
python/test/pyVisual_TEST.py Outdated Show resolved Hide resolved
python/test/pyVisual_TEST.py Outdated Show resolved Hide resolved
Signed-off-by: ahcorde <ahcorde@gmail.com>
"Get the transparency value of the visual")
.def("set_transparency", &sdf::Visual::SetTransparency,
"Set the transparency value for the visual")
.def("geometry", &sdf::Visual::Geom,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good.

"Get a pointer to the collisions's geometry.")
.def("set_geometry", &sdf::Visual::SetGeom,
"Set the collision's geometry")
.def("raw_pose", &sdf::Visual::RawPose,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Most of the items we return are small objects, so returning a copy makes sense. I just wanted to make sure we were doing this intentionally. Technically, it would be a change in behavior in that if I get a raw pose by calling raw_pose then call set_raw_pose, it wouldn't affect the raw pose I obtained earlier whereas in C++ it would.

It would be good to document these kind of differences between the C++ and Python API somewhere. Are we generating python docs and uploading them somewhere for ign-math? If we don't have the infrastructure setup yet, maybe we should put a README in the src/python.

@ahcorde ahcorde merged commit f5a9e19 into main Apr 22, 2022
@ahcorde ahcorde deleted the ahcorde/python/visual branch April 22, 2022 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱 garden Ignition Garden mujoco scripting Scripting interfaces to Ignition
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants