robotology / idyntree

Multibody Dynamics Library designed for Free Floating Robots
BSD 3-Clause "New" or "Revised" License
176 stars 67 forks source link

Generate bindings for inverse-kinematics class #632

Closed lrapetti closed 4 years ago

lrapetti commented 4 years ago

Today we tried to generate the bindings also for the inverse-kinematics class. Following the guidelines, we modified the iDynTree.i file by adding:

#include "iDynTree/InverseKinematics.h"

and

%include "iDynTree/InverseKinematics.h"

But the generation of the binding failed with the following error:

/Users/lorenzorapetti/Software/robotology-superbuild/robotology/iDynTree/bindings/matlab/autogenerated/iDynTreeMATLAB_wrap.cxx:84083:5: warning: delete called on 'iDynTree::DiscreteExtendedKalmanFilterHelper' that is abstract but has non-virtual
      destructor [-Wdelete-non-virtual-dtor]
    delete arg1;
    ^
/Users/lorenzorapetti/Software/robotology-superbuild/robotology/iDynTree/bindings/matlab/autogenerated/iDynTreeMATLAB_wrap.cxx:97006:3: error: unknown type name 'Polygon2D'; did you mean 'iDynTree::Polygon2D'?
  Polygon2D *arg2 = 0 ;
  ^~~~~~~~~
  iDynTree::Polygon2D
/Users/lorenzorapetti/Software/robotology-superbuild/robotology/iDynTree/src/inverse-kinematics/include/iDynTree/ConvexHullHelpers.h:85:11: note: 'iDynTree::Polygon2D' declared here
    class Polygon2D
          ^
/Users/lorenzorapetti/Software/robotology-superbuild/robotology/iDynTree/bindings/matlab/autogenerated/iDynTreeMATLAB_wrap.cxx:97029:28: error: unknown type name 'Polygon2D'; did you mean 'iDynTree::Polygon2D'?
  arg2 = reinterpret_cast< Polygon2D * >(argp2);
                           ^~~~~~~~~
                           iDynTree::Polygon2D
/Users/lorenzorapetti/Software/robotology-superbuild/robotology/iDynTree/src/inverse-kinematics/include/iDynTree/ConvexHullHelpers.h:85:11: note: 'iDynTree::Polygon2D' declared here
    class Polygon2D
          ^
1 warning and 2 errors generated.

the error seems related to Polygon2D class definition.


@traversaro answered

I remember having similar problems in the past, that are due to the C++ parser used by SWIG to generate the code. I remember fixing them by adding iDynTree:: to some declarations. However, to be more constructive, I suggest you to add:

#include "iDynTree/ConvexHullHelpers.h"

and

%include "iDynTree/ConvexHullHelpers.h"

to iDynTree.i as well, as this header is included by InverseKinematics.h and so ensuring that it is wrapper correctly could help.

lrapetti commented 4 years ago

I suggest you to add:

#include "iDynTree/ConvexHullHelpers.h"

and

%include "iDynTree/ConvexHullHelpers.h"

to iDynTree.i as well, as this header is included by InverseKinematics.h and so ensuring that it is wrapper correctly could help.

Adding ConvexHullHelpers.h I no longer experience the error and I was able to generate the bindings.

lrapetti commented 4 years ago

PR opened at https://github.com/robotology/idyntree/pull/633

traversaro commented 4 years ago

There was also issue https://github.com/robotology/idyntree/issues/498 that tracked the same problem.

lrapetti commented 4 years ago

PR opened at #633

merged.