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

Expose TaskContactForceEquality python binding #247

Open
danielcostanzi18 opened this issue Dec 20, 2024 · 3 comments
Open

Expose TaskContactForceEquality python binding #247

danielcostanzi18 opened this issue Dec 20, 2024 · 3 comments

Comments

@danielcostanzi18
Copy link

Hello everyone,

First off, thanks a lot for the great work on TSID!
I want to use TSID to control the force at the end effector of a manipulator, to do so I want to use the task TaskContactForceEquality. The problem is that it's python binding is not exposed.
I tried to naively expose it with these changes.

When I try to instantiate the task I get the following error:

ArgumentError: Python argument types in
TaskContactForceEquality.init(TaskContactForceEquality, str, RobotWrapper, float, Contact6d)
did not match C++ signature:
init(_object*, std::__cxx11::basic_string<char, std::char_traits, std::allocator > name, tsid::robots::RobotWrapper {lvalue} robot, double dt, tsid::contacts::ContactBase {lvalue} contact)

It seems that the problem lies in the type of contact that I am passing, which is of type tsid.tsid_pywrap.Contact6d. From the C++ signature, it appears that the constructor expects tsid::contacts::ContactBase instead.

Could anyone shed light on how I might resolve this mismatch or if there's an alternative way to expose the correct binding for Contact6d?

If you want to reproduce the issue you can launch the example that I prepared exercizes/ex_5_ur5_force_task.py.

Thanks in advance for your help!

Best regards,
Daniel

@andreadelprete
Copy link
Collaborator

Hi @danielcostanzi18
it seems to me the problem is that in Python Contact6d is not recognized as a ContactBase, even though it is. Indeed if you take a look at how other Python bindings have been implemented (such as this one) you need to implement a different method for each possible child class of the input argument. In your case, you would need a constructor for each possible child of ContactBase (such as Contact6d).

@danielcostanzi18
Copy link
Author

danielcostanzi18 commented Jan 7, 2025

Hi @andreadelprete
Thanks a lot for your help, I'm now able to instantiate the task by passing a Contact6d.
These are the last changes.
I'd like to open a PR, but first would probably be better to have a working example, what do you think?
For that matter, I'd open another issue.

@andreadelprete
Copy link
Collaborator

Yes that would be ideal thanks!

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