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

New CMake structure and plugin-based blocks architecture #137

Merged

Conversation

diegoferigo
Copy link
Member

New CMake structure

After the previous big refactorings (#56, #77, #115) the wb-toolbox became more modular and these modules have been kept as independent as possible.

After these changes to the C++ side, this PR split the components at the CMake level in the following components:

Component name Description
Core It contains core interfaces and classes such as Block, Signal, BlockInformation, Log
Mex It contains the S-Function that generates the mex file and the implementation of BlockInformation for using block libraries with Simulink
Coder Implementation of BlockInformation for using block libraries with Simulink Coder output
Library It contains all the implementations of Block

Core, Mex and Coder represent the real machinery of the toolbox (whose targets are named just Toolbox* for the time being). They will represent the new project described in #83.

New plugin-based blocks architecture

Simulink

Until now the mex generated from the S-Function was dynamically linked to the analogous of the Library component. The split introduced a problem due to the factory machinery. Since Mex is standalone, it doesn't know any information about the library containing the wbt::Block objects to allocate (they can also be different libraries) and hence the factory function was an unresolved symbol in the S-Function itself.

This PR introduces a new plugin-based approach to tackle this problem. The S-Function running in Simulink uses dlopen in a plugin fashion to get the Block object, which must know the name of the library file that contains it. This information is stored in the Simulink Library (.slx file).

Simulink Coder (C++)

Instead, the Library component can be linked either dynamically or statically with Coder and a main function in order to use it as a standalone C++ application after the code has been generated by Simulink Coder.

cc @traversaro @DanielePucci @pattacini

@diegoferigo diegoferigo self-assigned this Jun 22, 2018
@diegoferigo diegoferigo force-pushed the feature/newFactoryAndNewCMakeStructure branch from fc6064d to aefcd01 Compare June 22, 2018 13:45
@diegoferigo diegoferigo changed the base branch from master to devel June 22, 2018 13:48
@diegoferigo diegoferigo force-pushed the feature/newFactoryAndNewCMakeStructure branch 2 times, most recently from 85a25df to ec5adf7 Compare June 22, 2018 15:20
@diegoferigo diegoferigo force-pushed the feature/newFactoryAndNewCMakeStructure branch from 1a4d18f to de59b01 Compare June 25, 2018 07:49
@traversaro
Copy link
Member

@diegoferigo ping me when the PR is ready for review.

Destructors must be defined in the cpp due to sizeof issues caused by the pimpl implemented with unique pointer. The root of this error is related that the forward declaration of the impl type in the header.
Now wbt::Block instances are allocated by the S-Function using dlopen and they need to know the name of the library that contains them. This information is now stored in the Simulink Library as an additional parameter of every S-Function block.
@diegoferigo diegoferigo force-pushed the feature/newFactoryAndNewCMakeStructure branch from e620c8e to e6de553 Compare June 25, 2018 11:14
@diegoferigo
Copy link
Member Author

@traversaro It is already. I had the last minor edit in pipeline, just squashed it.

@diegoferigo
Copy link
Member Author

diegoferigo commented Jul 13, 2018

Despite there is some ongoing work on a standalone version of sharedlibpp used for a multiplatform dlopen, I'm going to merge this PR that ships it within wb-toolbox.

We might consider in the future to use a submodule pointing to the new library.

Merging as soon as Travis passes again against the latest yarp:devel if you don't have any concern. cc @traversaro

@diegoferigo diegoferigo deleted the feature/newFactoryAndNewCMakeStructure branch August 3, 2018 11:56
This was referenced Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants