Comments (12)
I would like to add a comment to this discussion line. Indeed it's very tricky to bind Eigen data with Numpy. During the period at IIT, I used SWIG to bind Eigen data. Basically you need to write an interface file, this file can be re-used for any project. Here you find the file:
https://github.com/robot-locomotion/dwl/blob/master/swig/eigen.i
from pinocchio.
I have a question related to this issue:
There seems to be an ongoing effort to provide Matlab support in swig. Did you give any thought to using swig for the python interface generation?
from pinocchio.
Hello,
Yes indeed. I lightly benchmarked several python interface systems in terms of ease of use and efficiency. Boost seemed to be the best option.
The binding of eigen and mummy is indeed quite tricky. I would be a priori very reluctant to spend time doing it a second time.
On the other hand, matlab interfaces are very light to implement. Do you really thing that swing would help, if not for capitalising on the python bindings?
N
Le 16 oct. 2015 19:14, Antonio El Khoury [email protected] a écrit :I have a question related to this issue:
There seems to be an ongoing effort to provide Matlab support in swig. Did you give any thought to using swig for the python interface generation?
—Reply to this email directly or view it on GitHub.
from pinocchio.
A couple of questions:
- What is mummy?
- Is Eigen memory alignment the only tricky part or did you encounter other problems?
I am neither familiar with matlab interfaces nor with swig (at least not yet), and I am quite happy with the current state of the python bindings. So I would give swig a try only if it would make writing matlab interfaces faster than doing a raw binding (through mexFunction I guess).
from pinocchio.
One quick answer: mummy is in fact numpy.
from pinocchio.
Mummy is indeed the best my phone could propose to correct Numpy, as already corrected by Justin. Sorry for the typo.
The tricky part in boost::python was the memory alignment (or more exactly, the memory allocation of Eigen memory by boost::python, that does not respect Eigen alignment). The tricky part in general is to bind Eigen data in C with Numpy data in Python. It would be more straightforward to wrap Eigen data in Python. Wrapping is for example what is done for Pinocchio::Model or Pinocchio::Force classes: you are not using a Python object to make the equivalence with the C object, but directly manipulating the C object in Python.
I think binding Eigen with Numpy provides better functionalities in the end, however is more difficult to implement. For what I benchmarked initially, it seems equality tricky with the various Python wrapping/binding frameworks.
Again in my opinion, wrapping is much easier in Matlab, because Matlab is not strongly typed. Programming the matlab bindings could be done with much effort with the native MEX system of Matlab.
from pinocchio.
Thanks for the clarification, I will give the matlab MEX a try.
from pinocchio.
Have you implemented any Matlab interface? If not, are you still interested by such feature?
from pinocchio.
Sadly I haven't had the time to implement anything, but we are still clearly interested in such a feature.
from pinocchio.
If anyone ever needs that, a possible strategy to test is to use the Pinocchio Python bindings in MATLAB. Recent version of MATLAB have quite advanced Python interoperability features, see https://www.mathworks.com/help/matlab/call-python-libraries.html, ami-iit/bipedal-locomotion-framework#53 (comment) and robotology/robotology-superbuild#760 .
from pinocchio.
Fantastic. I didn't know that.
We may give it a try once. @proyan Would you may give it a try?
@traversaro What is your feedback on it?
from pinocchio.
@traversaro What is your feedback on it?
We only tried it for some examples for now (see ami-iit/bipedal-locomotion-framework#53 (comment)) but it seems quite promising, but to be honest we never had any serious use of it (like, a student that did all the computation for a paper/thesis in it). To quickly test it, if you have access a possible option is to install pinocchio via conda in MATLAB Online. We have a simple script in https://github.com/robotology/robotology-superbuild/blob/0f82a33dca1fe46111945e09382df26e39c0efb5/doc/matlab-one-line-install.md#installation-on-matlab-online for installing conda packages in MATLAB Online with a few commands.
To use the script with Python Pinocchio bindings, probably it would be sufficient to:
- the script should be modified around https://github.com/robotology/robotology-superbuild/blob/d94d8ca32e5b1e446ad9ec835565e315cceb7bac/scripts/install_robotology_packages.m#L68 to install pinocchio via conda forge instead of the robotology packages
- the selection of the python interpreter of conda should be added to the activation script around https://github.com/robotology/robotology-superbuild/blob/d94d8ca32e5b1e446ad9ec835565e315cceb7bac/scripts/install_robotology_packages.m#L72 , adding a line such as
pyversion(fullfile(robotology_install_prefix,'/bin/python3'))
or something similar.
from pinocchio.
Related Issues (20)
- Homogenize internal namespace
- Use real ubuntu image in linux.yml worflow
- Add OpenUSD support
- Merge C++/Python context
- Find a way to use different explicit template instantiation C++ library in the same program
- Use boost::variant Python binding to bind JointModel and JointData
- Remove C++ warnings
- Parsing urdf - breaking change 2.7 - 3.0 HOT 3
- Installation of pinocchio 3.0 HOT 4
- pinocchio 3.0.0 build failure HOT 5
- Does Pinocchio support the dynamics computation for wheeled-legged structures? HOT 1
- test-cpp-algorithm-utils-force failure on aarch64-linux with nix HOT 4
- Python Binding Compilation Error HOT 1
- Unable to compile code with `pinocchio::computeCollisions()` with ROS 2 Humble binary install HOT 8
- Display issues with `hector` drone in pin3 HOT 7
- Merging models transformation issue HOT 1
- Issue: ArgumentError in cpin.aba function HOT 1
- test-cpp-contact-cholesky failure with GCC 13.3.0 HOT 7
- If a wheel is in contact with the ground, can I directly obtain the Jacobian and position information of the contact point using Pinocchio?
- On dDifference for continuous joints
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pinocchio.