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

Pose3 return type not valid for pybind11 #1129

Closed
willstott101 opened this issue Sep 7, 2022 · 7 comments
Closed

Pose3 return type not valid for pybind11 #1129

willstott101 opened this issue Sep 7, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@willstott101
Copy link
Contributor

willstott101 commented Sep 7, 2022

Environment

  • OS Version: Custom poky-based distro (via Ubuntu 20.04)
  • Source or binary build: Source from 1bf1aa4e511d3efe0f97a6c14048a35dbcde26ce on sdf13

Description

  • Expected behavior: Python bindings allow me to get resolved (joint) poses
  • Actual behavior: PyBind11 cannot convert the type

Steps to reproduce

  1. Load an sdf using the python module
  2. Try to access a method that returns gz::math::v7::Pose3<double> such as SemanticPose.resolve

Output

>>> p.raw_pose()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Unable to convert function return value to a Python type! The signature was
	(self: sdformat.SemanticPose) -> gz::math::v7::Pose3<double>

Possible Solution

I suspect gz-math needs to provide python object access as described here: pybind/pybind11#616

This means:

  • Dev headers for the gz-math python library
  • Cmake config to allow linking against that python module
  • libsdformat's python library linking against it and returning gz-math python types

I'm going to see if I can get that to work and will post an example if it does - but I don't think I'll have time to put together a proper PR.

@willstott101 willstott101 added the bug Something isn't working label Sep 7, 2022
@ahcorde
Copy link
Collaborator

ahcorde commented Sep 7, 2022

Did you try to import from gz.math import Pose3d ?

@willstott101
Copy link
Contributor Author

Ah no I didn't... that works. Thanks!

Should the sdformat library import that automatically?

@ahcorde
Copy link
Collaborator

ahcorde commented Sep 7, 2022

it seems that is not bringing the dependency, I will try to review this when I have some time.

Feel free to open a PR and tag me if you find a solution.

@ahcorde
Copy link
Collaborator

ahcorde commented Sep 7, 2022

Hi @willstott101,

do you mind to open a PR with your fix ?

willstott101 added a commit to willstott101/sdformat that referenced this issue Sep 7, 2022
willstott101 added a commit to willstott101/sdformat that referenced this issue Sep 7, 2022
@willstott101
Copy link
Contributor Author

#1130 Opened one - but haven't gone through all the red tape yet - might get round to that some time but really not that interested in filling in a bunch of forms

willstott101 added a commit to willstott101/sdformat that referenced this issue Sep 8, 2022
Signed-off-by: Will Stott <willstott101@gmail.com>
azeey added a commit that referenced this issue Sep 30, 2022
* python: Don't import more than is used in the tests - should cause a failure due to gz.math not always being imported.
* python: Import gz.math at startup to fix #1129

Signed-off-by: Will Stott <willstott101@gmail.com>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org>
@ahcorde
Copy link
Collaborator

ahcorde commented Oct 3, 2022

The fix is merged. Closing this

@ahcorde ahcorde closed this as completed Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

2 participants