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

can't set a Descartes pose sampler on Profile #50

Open
jf--- opened this issue Sep 22, 2023 · 8 comments
Open

can't set a Descartes pose sampler on Profile #50

jf--- opened this issue Sep 22, 2023 · 8 comments

Comments

@jf---
Copy link

jf--- commented Sep 22, 2023

Hi,

First, what a formidable library, so stoked having access to tesseract from python!

I'd like to contribute by porting examples from tesseract-robotics/tesseract_planning/tree/master/tesseract_examples/src to python. Also its a nice way to find my way around ;)

I'm porting a Descartes tutorial from ROS-I training ,

from tesseract_robotics.tesseract_motion_planners_descartes import (
    cast_DescartesPlanProfileD,
    DescartesDefaultPlanProfileD,
    sampleToolZAxis,
    PoseSamplerFn,
)


def test_zaxis_descartes():
    """

    implement the ROS-I tutotial on descartes
    basically is akin to the `puzzle_piece_example.py`, but using the `descartes` lib over `trajopt`

    https://industrial-training-master.readthedocs.io/en/melodic/_source/session5/Advanced-Descartes-Path-Planning.html

    """
    plan_profile = DescartesDefaultPlanProfileD()
    # DescartesDefaultPlanProfileD is not upcasting automatically, use helper function
    plan_profile1 = cast_DescartesPlanProfileD(plan_profile)
    pp = PoseSamplerFn(sampleToolZAxis)
    plan_profile.target_pose_sampler = pp


#     plan_profile.target_pose_sampler = pp
#     Traceback (most recent call last):
#     File "C:\Program Files (x86)\JetBrains\PyCharm 2022.3.3\plugins\python\helpers\pydev\_pydevd_bundle\pydevd_exec2.py", line 3, in Exec
#     exec(exp, global_vars, local_vars)
# File "<input>", line 1, in <module>
# File "C:\Users\jelle\miniconda3\envs\compas\lib\site-packages\tesseract_robotics\tesseract_motion_planners_descartes\tesseract_motion_planners_descartes_python.py", line 34, in set_instance_attr
# set(self, name, value)
# TypeError: in method 'DescartesDefaultPlanProfileD_target_pose_sampler_set', argument 2 of type 'tesseract_planning::PoseSamplerFn *'
# pp
@johnwason
Copy link
Contributor

Hi @jf---

First, what a formidable library, so stoked having access to tesseract from python!

I think there are over 4000 functions wrapped...

argument 2 of type 'tesseract_planning::PoseSamplerFn *'

Wrapping callback functions is very tricky. I will take a look when I have a chance to see what the issue is, but it may take some time before I have it fixed.

@jf---
Copy link
Author

jf--- commented Sep 22, 2023

Thanks @johnwason , I'm familiar with the limits of SWIG I've worked on pythonocc extensively, which is also SWIG based. The issue is mostly namespaces related, the set function doesn't really invoke much. pybind11 has an interesting approach to handling callbacks.

Any thoughts on how to move fwd regarding using the descartes planner?

@johnwason
Copy link
Contributor

I use SWIG "directors" to handle the callbacks. There are some macros that generate a base class, and then the Python wrapper class extends the base class.

There is a SWIG file with the macro definitions that make it all work:

https://github.com/tesseract-robotics/tesseract_python/blob/master/tesseract_python/swig/tesseract_std_function.i

It looks like the customized typemap is not being applied for the field target_pose_sampler. It is likely that function parameters are using the correct typemap, but not the field assignment.

@johnwason
Copy link
Contributor

@jf--- please send me a message on my website https://www.wasontech.com/contact-us

@jf---
Copy link
Author

jf--- commented Oct 12, 2023

✅ thx for the invite!

@johnwason
Copy link
Contributor

@jf--- can you try the wheels in

https://github.com/tesseract-robotics/tesseract_python/suites/18704221744/artifacts/1088812345

This should have the sampling function fixed. You can install wheel files using pip by pointing to the file absolute location. Make sure you use the right file for your system and python version.

@johnwason
Copy link
Contributor

I have tesseract running on Mac OSX arm64. See tesseract-robotics/tesseract#970

@johnwason
Copy link
Contributor

Hi @jf--- have you had a chance to test these fixes? The macos packages should have the callback function working.

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

No branches or pull requests

2 participants