ami-iit / bipedal-locomotion-framework

Suite of libraries for achieving bipedal locomotion on humanoid robots
https://ami-iit.github.io/bipedal-locomotion-framework/
BSD 3-Clause "New" or "Revised" License
132 stars 36 forks source link

Add basic test for YarpRobotLoggerDevice #862

Open traversaro opened 1 week ago

traversaro commented 1 week ago

Discussing with @GiulioRomualdi, it turns out that the YarpRobotLoggerDevice is an important and critical piece of software, that has almost zero test coverage, making it complex to make (or review) any change to it.

As an initial (and by far non complete) solution for this, in this PR I add a basic test for the YarpRobotLoggerDevice, that logs the encoders and the imu of a fake robot, and check that the value saved in the .mat files are indeed correct.

In the future, the test can be made more complex to test more functionality of the YarpRobotLoggerDevice (log of YARP ports, textual logging), but I guess we can start simple.

For what regards the technicalities, this has been implemented with this key ideas:

cc @nicktrem @xela-95 that could be interested to this PR as well.

traversaro commented 1 week ago

There is CI failure:

CMake Error at /usr/share/miniconda3/envs/test/lib/cmake/BipedalLocomotionFramework/BipedalLocomotionFrameworkTargets.cmake:123 (set_target_properties):
  The link interface of target "BipedalLocomotion::VectorsCollection"
  contains:

    YARP::YARP_robotinterface

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  /usr/share/miniconda3/envs/test/lib/cmake/BipedalLocomotionFramework/BipedalLocomotionFrameworkConfig.cmake:47 (include)
  CMakeLists.txt:5 (find_package)

I guess the problem is to put all ${YARP_LIBRARIES} as public dependency, let me clean that.

traversaro commented 1 week ago

There is CI failure:

CMake Error at /usr/share/miniconda3/envs/test/lib/cmake/BipedalLocomotionFramework/BipedalLocomotionFrameworkTargets.cmake:123 (set_target_properties):
  The link interface of target "BipedalLocomotion::VectorsCollection"
  contains:

    YARP::YARP_robotinterface

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  /usr/share/miniconda3/envs/test/lib/cmake/BipedalLocomotionFramework/BipedalLocomotionFrameworkConfig.cmake:47 (include)
  CMakeLists.txt:5 (find_package)

I guess the problem is to put all ${YARP_LIBRARIES} as public dependency, let me clean that.

Argh, that cleanup went out of hand, I will probably cleanup the PR in the next days.

traversaro commented 1 week ago

Argh, that cleanup went out of hand, I will probably cleanup the PR in the next days.

Fixed and rebased, CI should be happy.

GiulioRomualdi commented 6 days ago

Thank you!! This was an important missing point!

traversaro commented 6 days ago

A few jobs fail, I will check them when I have a laptop.

traversaro commented 5 days ago

Windows build is failing with:

[282/463] Building CXX object devices\VectorsCollectionWrapper\CMakeFiles\VectorsCollectionWrapper.dir\yarp_plugin_VectorsCollectionWrapper.cpp.obj
C:\Miniconda3\envs\test\Library\include\yarp/os/api.h(53) : warning:"The YARP::YARP_OS target is deprecated. Use YARP::YARP_os instead"
[283/463] Building CXX object devices\YarpRobotLoggerDevice\tests\CMakeFiles\YarpRobotLoggerDeviceUnitTests.dir\YarpRobotLoggerDeviceTest.cpp.obj
FAILED: devices/YarpRobotLoggerDevice/tests/CMakeFiles/YarpRobotLoggerDeviceUnitTests.dir/YarpRobotLoggerDeviceTest.cpp.obj 
C:\PROGRA~2\MICROS~2\2019\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\cl.exe  /nologo /TP -DCATCH_CONFIG_DISABLE_MATCHERS -DCATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER -DCATCH_CONFIG_FAST_COMPILE -DCMAKE_BINARY_DIR=\"D:/a/bipedal-locomotion-framework/bipedal-locomotion-framework/build\" -DCMAKE_CURRENT_SOURCE_DIR=\"D:/a/bipedal-locomotion-framework/bipedal-locomotion-framework/devices/YarpRobotLoggerDevice/tests\" -D_USE_MATH_DEFINES -Dcasadi_VERSION=3.6.5 -ID:\a\bipedal-locomotion-framework\bipedal-locomotion-framework\build\_deps\catch2-src\src\catch2\.. -ID:\a\bipedal-locomotion-framework\bipedal-locomotion-framework\build\generated-includes -external:IC:\Miniconda3\envs\test\Library\include -external:IC:\Miniconda3\envs\test\Library\include\eigen3 -external:W0 /DWIN32 /D_WINDOWS /GR /EHsc /O2 /Ob2 /DNDEBUG -std:c++17 -MD /showIncludes /Fodevices\YarpRobotLoggerDevice\tests\CMakeFiles\YarpRobotLoggerDeviceUnitTests.dir\YarpRobotLoggerDeviceTest.cpp.obj /Fddevices\YarpRobotLoggerDevice\tests\CMakeFiles\YarpRobotLoggerDeviceUnitTests.dir\ /FS -c D:\a\bipedal-locomotion-framework\bipedal-locomotion-framework\devices\YarpRobotLoggerDevice\tests\YarpRobotLoggerDeviceTest.cpp
D:\a\bipedal-locomotion-framework\bipedal-locomotion-framework\devices\YarpRobotLoggerDevice\tests\YarpRobotLoggerDeviceTest.cpp(186): error C2679: binary '=': no operator found which takes a right-hand operand of type 'std::filesystem::path' (or there is no acceptable conversion)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\xstring(3061): note: could be 'std::basic_string<char,std::char_traits<char>,std::allocator<char>> &std::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator =(const _Elem)'
traversaro commented 5 days ago

Ubuntu 20.04 ci is failing with:

YarpRobotLoggerDeviceUnitTests is a Catch2 v3.0.1 host application.
Run with -? for options

-------------------------------------------------------------------------------
Launch simple logger
-------------------------------------------------------------------------------
/home/runner/work/bipedal-locomotion-framework/bipedal-locomotion-framework/devices/YarpRobotLoggerDevice/tests/YarpRobotLoggerDeviceTest.cpp:60
...............................................................................

/home/runner/work/bipedal-locomotion-framework/bipedal-locomotion-framework/devices/YarpRobotLoggerDevice/tests/YarpRobotLoggerDeviceTest.cpp:60: FAILED:
due to unexpected exception with message:
  basic_string::_M_construct null not valid
traversaro commented 5 days ago

Windows build is failing with:

[282/463] Building CXX object devices\VectorsCollectionWrapper\CMakeFiles\VectorsCollectionWrapper.dir\yarp_plugin_VectorsCollectionWrapper.cpp.obj
C:\Miniconda3\envs\test\Library\include\yarp/os/api.h(53) : warning:"The YARP::YARP_OS target is deprecated. Use YARP::YARP_os instead"
[283/463] Building CXX object devices\YarpRobotLoggerDevice\tests\CMakeFiles\YarpRobotLoggerDeviceUnitTests.dir\YarpRobotLoggerDeviceTest.cpp.obj
FAILED: devices/YarpRobotLoggerDevice/tests/CMakeFiles/YarpRobotLoggerDeviceUnitTests.dir/YarpRobotLoggerDeviceTest.cpp.obj 
C:\PROGRA~2\MICROS~2\2019\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\cl.exe  /nologo /TP -DCATCH_CONFIG_DISABLE_MATCHERS -DCATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER -DCATCH_CONFIG_FAST_COMPILE -DCMAKE_BINARY_DIR=\"D:/a/bipedal-locomotion-framework/bipedal-locomotion-framework/build\" -DCMAKE_CURRENT_SOURCE_DIR=\"D:/a/bipedal-locomotion-framework/bipedal-locomotion-framework/devices/YarpRobotLoggerDevice/tests\" -D_USE_MATH_DEFINES -Dcasadi_VERSION=3.6.5 -ID:\a\bipedal-locomotion-framework\bipedal-locomotion-framework\build\_deps\catch2-src\src\catch2\.. -ID:\a\bipedal-locomotion-framework\bipedal-locomotion-framework\build\generated-includes -external:IC:\Miniconda3\envs\test\Library\include -external:IC:\Miniconda3\envs\test\Library\include\eigen3 -external:W0 /DWIN32 /D_WINDOWS /GR /EHsc /O2 /Ob2 /DNDEBUG -std:c++17 -MD /showIncludes /Fodevices\YarpRobotLoggerDevice\tests\CMakeFiles\YarpRobotLoggerDeviceUnitTests.dir\YarpRobotLoggerDeviceTest.cpp.obj /Fddevices\YarpRobotLoggerDevice\tests\CMakeFiles\YarpRobotLoggerDeviceUnitTests.dir\ /FS -c D:\a\bipedal-locomotion-framework\bipedal-locomotion-framework\devices\YarpRobotLoggerDevice\tests\YarpRobotLoggerDeviceTest.cpp
D:\a\bipedal-locomotion-framework\bipedal-locomotion-framework\devices\YarpRobotLoggerDevice\tests\YarpRobotLoggerDeviceTest.cpp(186): error C2679: binary '=': no operator found which takes a right-hand operand of type 'std::filesystem::path' (or there is no acceptable conversion)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\xstring(3061): note: could be 'std::basic_string<char,std::char_traits<char>,std::allocator<char>> &std::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator =(const _Elem)'

Probably fixed by @S-Dafarra suggestion in https://github.com/ami-iit/bipedal-locomotion-framework/pull/862#discussion_r1665394620 .