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

Update matlab bindings adding inverse-kinematics #633

Merged

Conversation

lrapetti
Copy link
Member

With this PR bindings for inverse-kinematics are generated.

The commit has been done accordingly to the guidelines.

@traversaro is it ok to target master with the updated bindings or should devel be targeted instead?

@traversaro
Copy link
Member

@traversaro is it ok to target master with the updated bindings or should devel be targeted instead?

Let's target devel as this is a new feature, thanks. I cleaned up the release process for 1.0, so I think a 1.1 release should be faster.

@lrapetti lrapetti changed the base branch from master to devel January 16, 2020 10:16
@traversaro
Copy link
Member

Can you also update the Changelog at https://github.com/robotology/idyntree/blob/devel/CHANGELOG.md ? Thanks!

@lrapetti
Copy link
Member Author

Sorry, by mistake I committed also the change in #631, I'll clean it up

@lrapetti lrapetti force-pushed the add-inverse-kinematics-matlab-bindings branch from 0645894 to ea370f3 Compare January 16, 2020 10:24
@lrapetti
Copy link
Member Author

Sorry, by mistake I committed also the change in #631, I'll clean it up

Fixed

Let's target devel as this is a new feature, thanks. I cleaned up the release process for 1.0, so I think a 1.1 release should be faster.

Target changed to devel

Can you also update the Changelog at https://github.com/robotology/idyntree/blob/devel/CHANGELOG.md ? Thanks!

Done d7e2035

@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.0.1] - 2020-01-14

### Added
- Added `bindings` for `InverseKinematics` (https://github.com/robotology/idyntree/pull/633)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, probably editing the ChangeLog is still confusing. The release 1.0.1 has been already done, so this change will go in a currently unreleased version, so it should be added in the ## [Unreleased] section, see https://keepachangelog.com/en/1.0.0/ for more details.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok! Yes, actually in fact I was a bit confused and I was not sure about the position

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is now moved under Unreleased

@lrapetti lrapetti force-pushed the add-inverse-kinematics-matlab-bindings branch from d7e2035 to c297d56 Compare January 16, 2020 13:16
@traversaro
Copy link
Member

I just realized that unfortunately we can't merge the PR in its current form, sorry.

The main problem is that as it is now, we are breaking the following configuration (that is used, especially in Windows, in some repos, even if it is not tested by iDynTree's repo CI):

  • IDYNTREE_USES_IPOPT = OFF
  • IDYNTREE_USES_MATLAB = ON or IDYNTREE_USES_OCTAVE = ON

This is due to the fact that we commit the generated source code with the modified SWIG that supports matlab.
We faced this problem in the past also with other dependencies, in particular Irrlicht for the visualization library and Assimp for the solidshapes helpers library. In both cases, the solution was to compile a dummy version of the related libraries when the specified dependency is missing, that if used created an error at runtime, see:

In the case of InverseKinematics, I think the easiest option is to prepare a dummy InverseKinematics.cpp to compile when Ipopt is not available https://github.com/robotology/idyntree/blob/v1.0.1/src/inverse-kinematics/src/InverseKinematics.cpp , that in place of all the methods just prints an error that explains that IDYNTREE_USES_IPOPT should be enabled to use that class.
Sorry for the boring work, but without this or something equivalent it would be complicate to me to merge such a change.

@lrapetti
Copy link
Member Author

lrapetti commented Jan 16, 2020

In the case of InverseKinematics, I think the easiest option is to prepare a dummy InverseKinematics.cpp to compile when Ipopt is not available https://github.com/robotology/idyntree/blob/v1.0.1/src/inverse-kinematics/src/InverseKinematics.cpp , that in place of all the methods just prints an error that explains that IDYNTREE_USES_IPOPT should be enabled to use that class.
Sorry for the boring work, but without this or something equivalent it would be complicate to me to merge such a change.

@traversaro
Ok no worry, I can work this out. Does the "dummy class" need to implement all the actual methods of the class?

@traversaro
Copy link
Member

Ok no worry, I can work this out. Does the "dummy class" need to implement all the actual methods of the class?

Yes, otherwise you would get a linking error.

@lrapetti
Copy link
Member Author

With 0657826 I have implemented the dummy methods. However I was thinking that a possible cleaner solutions could be:

  • to define directly a dummy class InverseKinematicsDataDummy so we would move almost all the conditions in that class. So eventually in the future we may have a different solver working for windows and we can implemente the class for the other solver.
  • to use just a single if redefining all the methods. But I went for using multiple ifs because in this case if a new method is add this avoid forgetting adding it also in the NOT_USE_ASSIMP case.


if (IDYNTREE_USES_IPOPT)
set(IDYNTREE_BUILD_IK TRUE)
add_subdirectory(inverse-kinematics)
endif()

if (IDYNTREE_COMPILES_OPTIMALCONTROL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDYNTREE_USES_OPTIMALCONTROL instead ?

Copy link
Member Author

@lrapetti lrapetti Jan 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think currently the way the option are used is: IDYNTREE_USES_{dependency_name} (e.g. for IDYNTREE_USES_YARP or IDYNTREE_USES_IPOPT), and IDYNTREE_COMPILES_{IDynTree component} (e.g. IDYNTREE_COMPILES_TESTS). So in this case I would say IDYNTREE_COMPILES_OPTIMALCONTROL is coherent with the rest of the code, even we might want to change and use always USE.

Anyway, this part did not change within this PR, so eventually the discussion might be moved elsewhere.

@traversaro
Copy link
Member

But I went for using multiple ifs because in this case if a new method is add this avoid forgetting adding it also in the NOT_USE_ASSIMP case.

Yes, this make sense, thanks!

@@ -37,6 +37,7 @@ target_include_directories(${libraryname} SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR})
target_link_libraries(${libraryname} idyntree-core idyntree-high-level ${IPOPT_LIBRARIES})

target_compile_definitions(${libraryname} PRIVATE ${IPOPT_DEFINITIONS})
target_compile_definitions(${libraryname} PRIVATE IDYNTREE_USES_IPOPT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you can see from the GitHub Actions failures, you need to also modify the CMakeLists.txt of this library to link IPOPT, pass the IDYNTREE_USES_IPOPT definition, add the private sources that depend on IPOPT only if IDYNTREE_USES_IPOPT is set to FALSE, similarly to what is done for assimp in the solid-shapes lib, see https://github.com/robotology/idyntree/blob/v1.0.1/src/solid-shapes/CMakeLists.txt . Note that as we require CMake 3.5 now, if necessary you can also use target_sources command, see https://github.com/robotology/idyntree/blob/v1.0.1/src/solid-shapes/CMakeLists.txt .

@traversaro
Copy link
Member

See GitHub Actions failures and #633 (comment) .

@lrapetti
Copy link
Member Author

See GitHub Actions failures and #633 (comment) .

it should be fixed in ee3d335.


add_library(${libraryname} ${IDYN_TREE_IK_HEADERS} ${IDYN_TREE_IK_SOURCES}
${PRIVATE_IDYN_TREE_IK_SOURCES} ${PRIVATE_IDYN_TREE_IK_HEADERS})
if(IDYNTREE_USES_IPOPT)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had this if since those classes are not compiled in the dummy class.
@traversaro please check if it looks sound for you or if you think there is a better way to handle it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using target_sources you can avoid to duplicate the add_library call, in any case what you did is ok, thanks!

@lrapetti
Copy link
Member Author

Some tests, apparently not related to inverse-kinematics, are failing

@traversaro
Copy link
Member

Some tests, apparently not related to inverse-kinematics, are failing

Yes, those are probably not related to the PR and caused by robotology/yarp#2189 .

@traversaro
Copy link
Member

Some tests, apparently not related to inverse-kinematics, are failing

Failures are not related to PR, but it seems to be related to robotology/yarp#2189 .

@traversaro
Copy link
Member

Can you rebase all the commits except ea370f3 or in genear clean the history? After that, the change can be merged.

@lrapetti lrapetti force-pushed the add-inverse-kinematics-matlab-bindings branch 2 times, most recently from e0a1166 to f16f240 Compare January 23, 2020 14:57
@lrapetti lrapetti force-pushed the add-inverse-kinematics-matlab-bindings branch from f16f240 to ade4b8f Compare January 23, 2020 14:59
@lrapetti
Copy link
Member Author

Can you rebase all the commits except ea370f3 or in genear clean the history? After that, the change can be merged.

Done

@traversaro
Copy link
Member

Can you rebase all the commits except ea370f3 or in genear clean the history? After that, the change can be merged.

Done

Thanks!

@traversaro traversaro merged commit b87350a into robotology:devel Jan 24, 2020
@lrapetti lrapetti deleted the add-inverse-kinematics-matlab-bindings branch January 24, 2020 09:22
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

Successfully merging this pull request may close these issues.

3 participants