robotology / blockfactory

A tiny framework to wrap algorithms for dataflow programming
https://robotology.github.io/blockfactory
GNU Lesser General Public License v2.1
40 stars 16 forks source link

Add blockfactory-exists command line tool #61

Closed traversaro closed 3 years ago

traversaro commented 3 years ago

Add a simple command line tool to check if a given block exists in a given plugin.

Added Tools CMake component to contain command line tools.

For example, if WB-Toolbox is installed correctly and BLOCKFACTORY_PLUGIN_PATH is set correctly, this are the output of the command:

STraversaro@IITICUBLAP102 MINGW64 /c/src/robotology-superbuild/build/src/BlockFactory (master)
$ blockfactory-exists WBToolbox ForwardKinematics
SUCCESS: Block "ForwardKinematics" found and loaded from plugin "WBToolbox".

STraversaro@IITICUBLAP102 MINGW64 /c/src/robotology-superbuild/build/src/BlockFactory (master)
$ echo $?
0

STraversaro@IITICUBLAP102 MINGW64 /c/src/robotology-superbuild/build/src/BlockFactory (master)
$ blockfactory-exists WBToolbox BlockThatDoesNotExists
ERROR: Failed to get factory object (blockName=BlockThatDoesNotExists,pluginName=WBToolbox)
STraversaro@IITICUBLAP102 MINGW64 /c/src/robotology-superbuild/build/src/BlockFactory (master)
$ echo $?
1
traversaro commented 3 years ago

cc @nunoguedelha

traversaro commented 3 years ago

Great idea @traversaro, this simple command line tool will be very useful for debugging plugins!

Yes, I think it could also be used to define a new test_blockfactory_plugin CMake macro in https://github.com/robotology/blockfactory/blob/master/cmake/BlockFactoryPlugin.cmake that can be used by downstream projects (such as WBToobox) a to a CTest test for each block to ensure that they load fine and they are not tricky linking issue that will appear just at runtime. In any case, even just the command tool is useful to test https://github.com/robotology/wb-toolbox/issues/197 .

diegoferigo commented 3 years ago

I agree on the CMake macro, it would be a great addition.

traversaro commented 3 years ago

@diegoferigo please let me know if there is anything I can do to merge this PR, thanks!

traversaro commented 3 years ago

By the way, the tools proved useful in debugging in https://github.com/robotology/wb-toolbox/issues/197 .