From 4c65cda9d55d15351d1b66d3252aab89207723a2 Mon Sep 17 00:00:00 2001 From: Alberto Casas Ortiz Date: Tue, 19 Jul 2022 20:20:43 +0200 Subject: [PATCH 1/4] Removed BTK from opensim-core. --- Bindings/CMakeLists.txt | 3 - Bindings/Java/Matlab/tests/CMakeLists.txt | 2 +- Bindings/Java/tests/CMakeLists.txt | 2 +- Bindings/common.i | 2 +- CMakeLists.txt | 42 +-- DEVELOPING.md | 6 +- OpenSim/Common/Adapters.h | 2 +- OpenSim/Common/C3DFileAdapter.cpp | 279 +------------------- OpenSim/Common/C3DFileAdapter.h | 4 +- OpenSim/Common/CMakeLists.txt | 12 +- OpenSim/Common/DataAdapter.cpp | 2 +- OpenSim/Common/Test/CMakeLists.txt | 5 +- OpenSim/Common/Test/testC3DFileAdapter.cpp | 4 +- OpenSim/Common/Test/testStorage.cpp | 2 +- OpenSim/Examples/DataAdapter/CMakeLists.txt | 2 +- README.md | 36 +-- cmake/OpenSimConfig.cmake.in | 4 +- cmake/OpenSimMacros.cmake | 2 +- dependencies/CMakeLists.txt | 7 - doc/doxyfile_shared.in | 1 - 20 files changed, 40 insertions(+), 379 deletions(-) diff --git a/Bindings/CMakeLists.txt b/Bindings/CMakeLists.txt index a3aed67b77..7f78947276 100644 --- a/Bindings/CMakeLists.txt +++ b/Bindings/CMakeLists.txt @@ -3,9 +3,6 @@ if(BUILD_PYTHON_WRAPPING OR BUILD_JAVA_WRAPPING) endif() # Flags are both Python and Java bindings will use. -if(WITH_BTK) - set(SWIG_FLAGS "-DWITH_BTK") -endif() if(WITH_EZC3D) set(SWIG_FLAGS "-DWITH_EZC3D") endif() diff --git a/Bindings/Java/Matlab/tests/CMakeLists.txt b/Bindings/Java/Matlab/tests/CMakeLists.txt index 6b699d078e..60a62f880c 100644 --- a/Bindings/Java/Matlab/tests/CMakeLists.txt +++ b/Bindings/Java/Matlab/tests/CMakeLists.txt @@ -92,7 +92,7 @@ OpenSimAddMatlabTest(AccessSubcomponents testAccessSubcomponents.m) OpenSimAddMatlabTest(Simbody testSimbody.m) OpenSimAddMatlabTest(osimTableStruct testosimTableStruct.m) OpenSimAddMatlabTest(testOsimVec3 testOsimVec3.m) -if(WITH_BTK OR WITH_EZC3D) +if(WITH_EZC3D) OpenSimAddMatlabTest(testOsimC3D testOsimC3D.m) endif() OpenSimAddMatlabTest(testOsimList2MatlabCell testOsimList2MatlabCell.m) diff --git a/Bindings/Java/tests/CMakeLists.txt b/Bindings/Java/tests/CMakeLists.txt index 16ba5fe959..75777b8743 100644 --- a/Bindings/Java/tests/CMakeLists.txt +++ b/Bindings/Java/tests/CMakeLists.txt @@ -143,7 +143,7 @@ OpenSimAddJavaTest(TestTables) OpenSimAddJavaTest(TestModelBuilding) OpenSimAddJavaTest(TestEditMarkers) OpenSimAddJavaTest(TestIKInterfaces) -if(WITH_BTK OR WITH_EZC3D) +if(WITH_EZC3D) OpenSimAddJavaTest(TestC3DFileAdapter) endif() OpenSimAddJavaTest(TestReporter) diff --git a/Bindings/common.i b/Bindings/common.i index 059ae953ea..917844c2d4 100644 --- a/Bindings/common.i +++ b/Bindings/common.i @@ -420,7 +420,7 @@ namespace OpenSim { %include %include -#if defined WITH_EZC3D || defined (WITH_BTK) +#if defined (WITH_EZC3D) %include %extend OpenSim::C3DFileAdapter { diff --git a/CMakeLists.txt b/CMakeLists.txt index 64fabe1297..bfaf39b612 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,7 +135,7 @@ from the internet, we turn this option OFF." ON) set(SIMBODY_HOME $ENV{SIMBODY_HOME} CACHE PATH "The location of the Simbody installation to use; you can change this. Set as empty to let CMake search for Simbody automatically.") -option(OPENSIM_COPY_DEPENDENCIES "Copy Simbody, ezc3d and BTK into the +option(OPENSIM_COPY_DEPENDENCIES "Copy Simbody and ezc3d into the OpenSim installation. This should be set to ON when making a relocatable distribution, and should be set to OFF when packaging for Homebrew, Debian, etc. On Linux and macOS: we use relative RPATHs when ON, and absolute RPATHs @@ -144,7 +144,7 @@ BUILD_PYTHON_WRAPPING is ON, so if this OFF, a warning is thrown." ON) mark_as_advanced(OPENSIM_COPY_DEPENDENCIES) option(OPENSIM_PYTHON_STANDALONE "Make the Python package standalone, meaning -the OpenSim (and Simbody, ezc3d and BTK) shared libraries it depends on are copied +the OpenSim (and Simbody and ezc3d) shared libraries it depends on are copied into the package. If you are building OpenSim on the same machine on which you plan to use it, you can leave this OFF. If you are distributing OpenSim to other computers, you should turn this ON. If macOS, this option affects how @@ -640,9 +640,9 @@ if(UNIX) # Linux and macOS # Add the automatically determined parts of the RPATH which point # to directories outside the build tree to the install RPATH. # If we are copying Simbody into OpenSim's installation, then - # there's no need to link to the libraries in Simbody's, ezc3d's or BTK's + # there's no need to link to the libraries in Simbody's or ezc3d's # original installations. Furthermore, we may be distributing OpenSim - # to other computers that will not have our original Simbody, ezc3d or BTK + # to other computers that will not have our original Simbody or ezc3d # installations, and so the RPATH would point to a nonexistant # directory on others' computers. set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) @@ -696,11 +696,10 @@ endif() set(OPENSIM_C3D_PARSER None CACHE STRING - "Compile OpenSim with a C3D parser ? ezc3d or BTK provide C3D reading.") -set_property(CACHE OPENSIM_C3D_PARSER PROPERTY STRINGS "ezc3d" "BTK" "None") + "Compile OpenSim with a C3D parser ? ezc3d provide C3D reading.") +set_property(CACHE OPENSIM_C3D_PARSER PROPERTY STRINGS "ezc3d" "None") if(${OPENSIM_C3D_PARSER} STREQUAL "ezc3d") set(WITH_EZC3D true) - set(WITH_BTK false) set(ezc3d_hint "${OPENSIM_DEPENDENCIES_DIR}/ezc3d/lib/cmake/ezc3d") find_package(ezc3d REQUIRED HINTS "${ezc3d_hint}") add_definitions(-DWITH_EZC3D) @@ -716,32 +715,12 @@ if(${OPENSIM_C3D_PARSER} STREQUAL "ezc3d") OpenSimInstallDependencyLibraries(ezc3d "${ezc3d_DIR}/../../../bin" "${ezc3d_DIR}/../../../lib" "${OPENSIM_INSTALL_PYTHONDIR}/opensim") endif() -elseif(${OPENSIM_C3D_PARSER} STREQUAL "BTK") - set(WITH_EZC3D false) - unset(ezc3d_LIBRARY_DIR CACHE) - unset(ezc3d_LIBRARY) - unset(ezc3d_INCLUDE_DIR CACHE) - set(WITH_BTK true) - - # If compiling with BTK, find and use it. - find_package(BTK - REQUIRED - HINTS "${OPENSIM_DEPENDENCIES_DIR}/BTK/share/btk-0.4dev") - include(${BTK_USE_FILE}) - add_definitions(-DWITH_BTK) - OpenSimCopyDependencyDLLsForWin(DEP_NAME BTK - DEP_BIN_DIR ${BTK_INSTALL_PREFIX}/bin) - if(BUILD_PYTHON_WRAPPING AND OPENSIM_PYTHON_STANDALONE) - OpenSimInstallDependencyLibraries(BTK "${BTK_INSTALL_PREFIX}" - "${BTK_LIBRARY_DIRS}" "${OPENSIM_INSTALL_PYTHONDIR}/opensim") - endif() else() set(WITH_EZC3D false) unset(ezc3d_LIBRARY_DIR CACHE) unset(ezc3d_LIBRARY) unset(ezc3d_INCLUDE_DIR CACHE) - set(WITH_BTK false) endif() find_package(spdlog REQUIRED @@ -930,15 +909,6 @@ if(${OPENSIM_COPY_DEPENDENCIES}) DESTINATION "${CMAKE_INSTALL_LIBDIR}") endif() - # BTK - # --- - if(NOT WIN32) - # LIB: .so files on Linux, .dylib on macOS - file(GLOB btk_desired_lib_files "${BTK_LIBRARY_DIRS}/*BTK*") - install(FILES ${btk_desired_lib_files} - DESTINATION "${CMAKE_INSTALL_LIBDIR}") - endif() - # spdlog # ------ install(DIRECTORY "${spdlog_DIR}/../../../" diff --git a/DEVELOPING.md b/DEVELOPING.md index 2d2a84eac9..7897abbe07 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -74,7 +74,7 @@ documentation online. The layout of the distribution on Windows is as follows: - - `bin/` OpenSim, SimTK, and BTK DLLs, opensim-cmd.exe, simbody-visualizer.exe + - `bin/` OpenSim and SimTK DLLs, opensim-cmd.exe, simbody-visualizer.exe - `cmake/` OpenSimConfig.cmake, etc. - `sdk/` - `APIExamples/`: C++ examples. @@ -99,7 +99,7 @@ if `OPENSIM_INSTALL_UNIX_FHS` is `ON`, as follows: - `include/` - `OpenSim/` OpenSim (and Lepton) headers. - `simbody/` Simbody headers. - - `lib/` (on some Linux variants, `lib//`) OpenSim, SimTK, and BTK shared libraries. + - `lib/` (on some Linux variants, `lib//`) OpenSim and SimTK shared libraries. - `cmake/` OpenSimConfig.cmake, SimbodyConfig.cmake, etc. - `python2.7/site-packages/` OpenSim Python bindings. - `libexec/simbody/simbody-visualizer` @@ -151,7 +151,7 @@ interchangeably. There are two types of dependencies: public, or those exposed through OpenSim's API (e.g., Simbody), and private, or those used internally by OpenSim -(e.g., BTK and ezc3d): +(e.g., ezc3d): - **private**: OpenSim's binary distribution need only contain the dependency's dynamic libraries. diff --git a/OpenSim/Common/Adapters.h b/OpenSim/Common/Adapters.h index af097317ee..9754349141 100644 --- a/OpenSim/Common/Adapters.h +++ b/OpenSim/Common/Adapters.h @@ -27,7 +27,7 @@ #include "STOFileAdapter.h" #include "CSVFileAdapter.h" -#if defined (WITH_EZC3D) || defined (WITH_BTK) +#if defined (WITH_EZC3D) #include "C3DFileAdapter.h" diff --git a/OpenSim/Common/C3DFileAdapter.cpp b/OpenSim/Common/C3DFileAdapter.cpp index f2b05a478b..2ae02ccb55 100644 --- a/OpenSim/Common/C3DFileAdapter.cpp +++ b/OpenSim/Common/C3DFileAdapter.cpp @@ -2,11 +2,6 @@ #ifdef WITH_EZC3D #include "ezc3d/ezc3d_all.h" -#else -#include "btkAcquisitionFileReader.h" -#include "btkAcquisition.h" -#include "btkForcePlatformsExtractor.h" -#include "btkGroundReactionWrenchFilter.h" #endif namespace { @@ -41,23 +36,6 @@ convertToSimtkMatrix(const std::vector& all_vec) { return simtkMat; } - -#else // WITH_BTK. -// Function to convert Eigen matrix to SimTK matrix. This can become a lambda -// function inside extendRead in future. -template -SimTK::Matrix_ -convertToSimtkMatrix(const Eigen::Matrix<_Scalar, _Rows, _Cols>& - eigenMat) { - SimTK::Matrix_ simtkMat{static_cast(eigenMat.rows()), - static_cast(eigenMat.cols())}; - - for(int r = 0; r < eigenMat.rows(); ++r) - for(int c = 0; c < eigenMat.cols(); ++c) - simtkMat(r, c) = eigenMat(r, c); - - return simtkMat; -} #endif } // anonymous namespace @@ -225,8 +203,7 @@ C3DFileAdapter::extendRead(const std::string& fileName) const { .parameter("TYPE").valuesAsInt()){ if (type == 1){ log_warn("C3DFileAdapter::extendRead::ezc3d: " - "Type 1 force platform detected. Please note that " - "results will vary between BTK and ezc3d backends."); + "Type 1 force platform detected."); } } std::vector labels{}; @@ -343,260 +320,6 @@ C3DFileAdapter::extendRead(const std::string& fileName) const { tables.emplace(_forces, emptyforcesTable); } return tables; - -#else // WITH_BTK. - auto reader = btk::AcquisitionFileReader::New(); - reader->SetFilename(fileName); - reader->Update(); - auto acquisition = reader->GetOutput(); - - EventTable event_table{}; - auto events = acquisition->GetEvents(); - for (auto it = events->Begin(); - it != events->End(); - ++it) { - auto et = *it; - event_table.push_back({ et->GetLabel(), - et->GetTime(), - et->GetFrame(), - et->GetDescription() }); - } - OutputTables tables{}; - - auto marker_pts = btk::PointCollection::New(); - - for(auto it = acquisition->BeginPoint(); - it != acquisition->EndPoint(); - ++it) { - auto pt = *it; - if(pt->GetType() == btk::Point::Marker) - marker_pts->InsertItem(pt); - } - int numFrames(marker_pts->GetFrontItem()->GetFrameNumber()); - int numMarkers(marker_pts->GetItemNumber()); - double pointFrequency(acquisition->GetPointFrequency()); - - if(numMarkers != 0) { - - int marker_nrow = numFrames; - int marker_ncol = numMarkers; - - std::vector marker_times(marker_nrow); - SimTK::Matrix_ marker_matrix(marker_nrow, marker_ncol); - - std::vector marker_labels{}; - for (auto it = marker_pts->Begin(); it != marker_pts->End(); ++it) { - marker_labels.push_back(SimTK::Value((*it)->GetLabel())); - } - - double time_step{1.0 / pointFrequency}; - for(int f = 0; f < marker_nrow; ++f) { - SimTK::RowVector_ row{ numMarkers, - SimTK::Vec3(SimTK::NaN) }; - int m{0}; - // C3D standard is to read empty values as zero, but sets a - // "residual" value to -1 and it is how it knows to export these - // values as blank, instead of 0, when exporting to .trc - // See: C3D documention 3D Point Residuals - // Read in value if it is not zero or residual is not -1 - for(auto it = marker_pts->Begin(); it != marker_pts->End(); ++it) { - // See: BTKCore/Code/IO/btkTRCFileIO.cpp#L359-L360 - auto pt = *it; - if (!pt->GetValues().row(f).isZero() || //not precisely zero - (pt->GetResiduals().coeff(f) != -1) ) {//residual is not -1 - row[m] = SimTK::Vec3{ pt->GetValues().coeff(f, 0), - pt->GetValues().coeff(f, 1), - pt->GetValues().coeff(f, 2) }; - } - ++m; - } - - marker_matrix.updRow(f) = row; - marker_times[f] = 0 + f * time_step; //TODO: 0 should be start_time - } - - // Create the data - auto marker_table = - std::make_shared(marker_times, - marker_matrix, - marker_labels); - - marker_table-> - updTableMetaData(). - setValueForKey("DataRate", - std::to_string(pointFrequency)); - - std::string units = acquisition->GetPointUnit(); - marker_table->updTableMetaData().setValueForKey("Units", units); - - marker_table->updTableMetaData().setValueForKey("events", event_table); - - tables.emplace(_markers, marker_table); - } - else { // insert empty table - std::vector emptyTimes; - std::vector emptyLabels; - SimTK::Matrix_ noData; - auto emptyMarkersTable = - std::make_shared( - emptyTimes, noData, emptyLabels); - tables.emplace(_markers, emptyMarkersTable); - } - - std::vector> fpCalMatrices{}; - std::vector> fpCorners{}; - std::vector> fpOrigins{}; - std::vector fpTypes{}; - // This is probably the right way to get the raw forces data from force - // platforms. Extract the collection of force platforms. - auto force_platforms_extractor = btk::ForcePlatformsExtractor::New(); - force_platforms_extractor->SetInput(acquisition); - auto force_platform_collection = force_platforms_extractor->GetOutput(); - force_platforms_extractor->Update(); - - auto fp_force_pts = btk::PointCollection::New(); - auto fp_moment_pts = btk::PointCollection::New(); - auto fp_position_pts = btk::PointCollection::New(); - - for(auto platform = force_platform_collection->Begin(); - platform != force_platform_collection->End(); - ++platform) { - const auto& calMatrix = (*platform)->GetCalMatrix(); - const auto& corners = (*platform)->GetCorners(); - const auto& origins = (*platform)->GetOrigin(); - auto type = (*platform)->GetType(); - - fpCalMatrices.push_back(convertToSimtkMatrix(calMatrix)); - fpCorners.push_back(convertToSimtkMatrix(corners)); - fpOrigins.push_back(convertToSimtkMatrix(origins)); - fpTypes.push_back(static_cast(type)); - - // Get ground reaction wrenches for the force platform. - auto ground_reaction_wrench_filter = - btk::GroundReactionWrenchFilter::New(); - ground_reaction_wrench_filter->setLocation( - btk::GroundReactionWrenchFilter::Location(getLocationForForceExpression())); - ground_reaction_wrench_filter->SetInput(*platform); - auto wrench_collection = ground_reaction_wrench_filter->GetOutput(); - ground_reaction_wrench_filter->Update(); - - for(auto wrench = wrench_collection->Begin(); - wrench != wrench_collection->End(); - ++wrench) { - // Forces time series. - fp_force_pts->InsertItem((*wrench)->GetForce()); - // Moment time series. - fp_moment_pts->InsertItem((*wrench)->GetMoment()); - // Position time series. - fp_position_pts->InsertItem((*wrench)->GetPosition()); - } - } - auto numPlatform(fp_force_pts->GetItemNumber()); - - if(numPlatform != 0) { - std::vector labels{}; - ValueArray units{}; - for(int fp = 1; fp <= numPlatform; ++fp) { - auto fp_str = std::to_string(fp); - - auto force_unit = acquisition->GetPointUnits(). - at(_unit_index.at("force")); - auto position_unit = acquisition->GetPointUnits(). - at(_unit_index.at("marker")); - auto moment_unit = acquisition->GetPointUnits(). - at(_unit_index.at("moment")); - - labels.push_back(SimTK::Value("f" + fp_str)); - units.upd().push_back(SimTK::Value(force_unit)); - - labels.push_back(SimTK::Value("p" + fp_str)); - units.upd().push_back(SimTK::Value(position_unit)); - - labels.push_back(SimTK::Value("m" + fp_str)); - units.upd().push_back(SimTK::Value(moment_unit)); - } - - const int nf = fp_force_pts->GetFrontItem()->GetFrameNumber(); - auto analogFrequency = acquisition->GetAnalogFrequency(); - - std::vector force_times(nf); - SimTK::Matrix_ force_matrix(nf, (int)labels.size()); - - double time_step{1.0 / analogFrequency}; - - for(int f = 0; f < nf; ++f) { - SimTK::RowVector_ - row{numPlatform * 3}; - int col{0}; - for(auto fit = fp_force_pts->Begin(), - mit = fp_moment_pts->Begin(), - pit = fp_position_pts->Begin(); - fit != fp_force_pts->End(); - ++fit, - ++mit, - ++pit) { - row[col] = SimTK::Vec3{(*fit)->GetValues().coeff(f, 0), - (*fit)->GetValues().coeff(f, 1), - (*fit)->GetValues().coeff(f, 2)}; - ++col; - row[col] = SimTK::Vec3{(*pit)->GetValues().coeff(f, 0), - (*pit)->GetValues().coeff(f, 1), - (*pit)->GetValues().coeff(f, 2)}; - ++col; - row[col] = SimTK::Vec3{(*mit)->GetValues().coeff(f, 0), - (*mit)->GetValues().coeff(f, 1), - (*mit)->GetValues().coeff(f, 2)}; - ++col; - } - force_matrix.updRow(f) = row; - force_times[f] = 0 + f * time_step; //TODO: 0 should be start_time - } - - auto& force_table = - *(new TimeSeriesTableVec3(force_times, force_matrix, labels)); - - TimeSeriesTableVec3::DependentsMetaData force_dep_metadata - = force_table.getDependentsMetaData(); - - // add units to the dependent meta data - force_dep_metadata.setValueArrayForKey("units", units); - force_table.setDependentsMetaData(force_dep_metadata); - - force_table. - updTableMetaData(). - setValueForKey("CalibrationMatrices", std::move(fpCalMatrices)); - - force_table. - updTableMetaData(). - setValueForKey("Corners", std::move(fpCorners)); - - force_table. - updTableMetaData(). - setValueForKey("Origins", std::move(fpOrigins)); - - force_table. - updTableMetaData(). - setValueForKey("Types", std::move(fpTypes)); - - force_table. - updTableMetaData(). - setValueForKey("DataRate", - std::to_string(analogFrequency)); - - tables.emplace(_forces, - std::shared_ptr(&force_table)); - - force_table.updTableMetaData().setValueForKey("events", event_table); - } - else { // insert empty table - std::vector emptyTimes; - std::vector emptyLabels; - SimTK::Matrix_ noData; - auto emptyforcesTable = std::make_shared( - emptyTimes, noData, emptyLabels); - tables.emplace(_forces, emptyforcesTable); - } - return tables; #endif } diff --git a/OpenSim/Common/C3DFileAdapter.h b/OpenSim/Common/C3DFileAdapter.h index fed6fbd5ed..377313f739 100644 --- a/OpenSim/Common/C3DFileAdapter.h +++ b/OpenSim/Common/C3DFileAdapter.h @@ -22,7 +22,7 @@ #ifndef OPENSIM_C3D_FILE_ADAPTER_H_ #define OPENSIM_C3D_FILE_ADAPTER_H_ -#if defined (WITH_EZC3D) || defined (WITH_BTK) +#if defined (WITH_EZC3D) #include "FileAdapter.h" #include "TimeSeriesTable.h" @@ -153,6 +153,6 @@ class OSIMCOMMON_API C3DFileAdapter : public FileAdapter { } // namespace OpenSim -#endif // WITH_BTK || WITH_EZC3D +#endif // WITH_EZC3D #endif // OPENSIM_C3D_FILE_ADAPTER_H_ diff --git a/OpenSim/Common/CMakeLists.txt b/OpenSim/Common/CMakeLists.txt index 432c5e4121..026fea33e5 100644 --- a/OpenSim/Common/CMakeLists.txt +++ b/OpenSim/Common/CMakeLists.txt @@ -2,7 +2,7 @@ file(GLOB INCLUDES *.h gcvspl.h) file(GLOB SOURCES *.cpp gcvspl.c) -if(NOT WITH_EZC3D AND NOT WITH_BTK) +if(NOT WITH_EZC3D) file(GLOB C3D_HEADER *C3DFileAdapter.h) file(GLOB C3D_SOURCE *C3DFileAdapter.cpp) list(REMOVE_ITEM INCLUDES ${C3D_HEADER}) @@ -11,16 +11,13 @@ endif() if (NOT WITH_EZC3D) unset(ezc3d_LIBRARY) endif() -if (NOT WITH_BTK) - unset(BTK_LIBRARIES) -endif() OpenSimAddLibrary( KIT Common AUTHORS "Clay_Anderson-Ayman_Habib-Peter_Loan" - # Clients of osimCommon need not link to BTK or ezc3d. + # Clients of osimCommon need not link to ezc3d. LINKLIBS PUBLIC ${Simbody_LIBRARIES} spdlog::spdlog - PRIVATE ${BTK_LIBRARIES} ${ezc3d_LIBRARY} + PRIVATE ${ezc3d_LIBRARY} INCLUDES ${INCLUDES} SOURCES ${SOURCES} TESTDIRS "Test" @@ -36,8 +33,5 @@ if(WIN32) if(WITH_EZC3D) add_dependencies(osimCommon Copy_ezc3d_DLLs) endif() - if(WITH_BTK) - add_dependencies(osimCommon Copy_BTK_DLLs) - endif() endif() diff --git a/OpenSim/Common/DataAdapter.cpp b/OpenSim/Common/DataAdapter.cpp index 5179340181..004830f314 100644 --- a/OpenSim/Common/DataAdapter.cpp +++ b/OpenSim/Common/DataAdapter.cpp @@ -44,7 +44,7 @@ bool registerAdapters{DataAdapter::registerDataAdapter("trc", TRCFileAdapter{}) && DataAdapter::registerDataAdapter("mot", STOFileAdapter_{}) && DataAdapter::registerDataAdapter("csv", CSVFileAdapter{}) -#if defined (WITH_EZC3D) || defined (WITH_BTK) +#if defined (WITH_EZC3D) && DataAdapter::registerDataAdapter("c3d", C3DFileAdapter{}) #endif }; diff --git a/OpenSim/Common/Test/CMakeLists.txt b/OpenSim/Common/Test/CMakeLists.txt index 989d49ae1c..ab0a5b17dd 100644 --- a/OpenSim/Common/Test/CMakeLists.txt +++ b/OpenSim/Common/Test/CMakeLists.txt @@ -12,15 +12,14 @@ list(APPEND TRC_TEST_FILES list(APPEND MOT_TEST_FILES "${OPENSIM_SHARED_TEST_FILES_DIR}/gait10dof18musc_ik_CRLF_line_ending.mot") -if(NOT WITH_EZC3D AND NOT WITH_BTK) +if(NOT WITH_EZC3D) file(GLOB C3D_TESTPROG *testC3DFileAdapter.cpp) list(REMOVE_ITEM TEST_PROGS ${C3D_TESTPROG}) - unset(BTK_LIBRARIES) endif() OpenSimAddTests( TESTPROGRAMS ${TEST_PROGS} DATAFILES ${TEST_FILES} ${C3D_TEST_FILES} ${TRC_TEST_FILES} ${XSENS_TEST_FILES} ${APDM_TEST_FILES} ${MOT_TEST_FILES} - LINKLIBS ${BTK_LIBRARIES} osimCommon ${SIMTK_ALL_LIBS} + LINKLIBS osimCommon ${SIMTK_ALL_LIBS} ) diff --git a/OpenSim/Common/Test/testC3DFileAdapter.cpp b/OpenSim/Common/Test/testC3DFileAdapter.cpp index d39d2f9391..c079218ed1 100644 --- a/OpenSim/Common/Test/testC3DFileAdapter.cpp +++ b/OpenSim/Common/Test/testC3DFileAdapter.cpp @@ -78,7 +78,7 @@ void test(const std::string filename) { using namespace std; // The walking C3D files included in this test should not take more - // than 40ms (BTK) or 200ms (ezc3d) on most hardware. + // than 200ms (ezc3d) on most hardware. // We make the max time 200ms to account for potentially slower CI machines. const long long MaximumLoadTimeInNs = SimTK::secToNs(0.200); @@ -173,7 +173,7 @@ void test(const std::string filename) { << watch.formatNs(loadTime) << endl; // on ci-biulds will define SKIP_TIMING as it is unpredictably slow on some // machines - #if defined(NDEBUG) && !defined(SKIP_TIMING) && defined(WITH_BTK) + #if defined(NDEBUG) && !defined(SKIP_TIMING) ASSERT(loadTime < MaximumLoadTimeInNs, __FILE__, __LINE__, "Unable to load '" + filename + "' within " + to_string(MaximumLoadTimeInNs) + "ns."); diff --git a/OpenSim/Common/Test/testStorage.cpp b/OpenSim/Common/Test/testStorage.cpp index 58183e56d0..4e04f864a3 100644 --- a/OpenSim/Common/Test/testStorage.cpp +++ b/OpenSim/Common/Test/testStorage.cpp @@ -185,7 +185,7 @@ int main() { // Verify the loading of marker data (14 markers) from .trc into a Storage SimTK_SUBTEST2(testStorageLoadingFromFile, "dataWithNaNsOfDifferentCases.trc", 43); - #if defined (WITH_EZC3D) || defined (WITH_BTK) + #if defined (WITH_EZC3D) // Verify the loading of forces from .c3d into a Storage. Includes 2 // force-plates with force, point, moment vectors (Vec3 flattened) SimTK_SUBTEST2(testStorageLoadingFromFile, "walking2.c3d", 3*6+1); diff --git a/OpenSim/Examples/DataAdapter/CMakeLists.txt b/OpenSim/Examples/DataAdapter/CMakeLists.txt index 4b87261dc7..7b1c84662d 100644 --- a/OpenSim/Examples/DataAdapter/CMakeLists.txt +++ b/OpenSim/Examples/DataAdapter/CMakeLists.txt @@ -4,7 +4,7 @@ set_target_properties(exampleTRCFileAdapter PROPERTIES FOLDER "Examples") file(COPY ${CMAKE_SOURCE_DIR}/OpenSim/Common/Test/dataWithNaNsOfDifferentCases.trc DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -if(WITH_BTK OR WITH_EZC3D) +if(WITH_EZC3D) add_executable(exampleC3DFileAdapter exampleC3DFileAdapter.cpp) target_link_libraries(exampleC3DFileAdapter ${Simbody_LIBRARIES} osimCommon) set_target_properties(exampleC3DFileAdapter PROPERTIES FOLDER "Examples") diff --git a/README.md b/README.md index dd3b22bd30..9ab78cf42e 100644 --- a/README.md +++ b/README.md @@ -443,7 +443,7 @@ Building from the source code ----------------------------- **NOTE**: On all platforms (Windows, OSX, Linux), you should -build all OpenSim dependencies (Simbody, BTK, etc) with the +build all OpenSim dependencies (Simbody, etc) with the same *CMAKE_BUILD_TYPE* (Linux) / *CONFIGURATION* (MSVC/Xcode) (e.g., Release, Debug) as OpenSim. Failing to do so *may* result in mysterious runtime errors like @@ -606,15 +606,11 @@ On Windows using Visual Studio * Obtained on your own: 1. Simbody: Set the `SIMBODY_HOME` variable to where you installed Simbody (e.g., `C:/Simbody`). - 2. BTK: Set the variable `BTK_DIR` to the directory containing - `BTKConfig.cmake`. If the root directory of your BTK installation is - `C:/BTKCore-install`, then set this variable to - `C:/BTKCore-install/share/btk-0.4dev`. - 3. docopt.cpp: Set the variable `docopt_DIR` to the directory + 2. docopt.cpp: Set the variable `docopt_DIR` to the directory containing `docopt-config.cmake`. If the root directory of your docopt.cpp installation is `C:/docopt.cpp-install`, then set this variable to `C:/docopt.cpp-install/lib/cmake`. - 4. spdlog: Set the variable `spdlog_DIR` to the directory containing + 3. spdlog: Set the variable `spdlog_DIR` to the directory containing `spdlogConfig.cmake`. If the root directory of your spdlog installation is `C:/spdlog-install`, then set this variable to `C:/spdlog-install/lib/spdlog/cmake`. @@ -710,8 +706,7 @@ directory to your `PATH` environment variable. -DCMAKE_INSTALL_PREFIX="..\opensim_install" ` -DOPENSIM_DEPENDENCIES_DIR="..\opensim_dependencies_install" ` -DBUILD_JAVA_WRAPPING=ON ` - -DBUILD_PYTHON_WRAPPING=ON ` - -DWITH_BTK=ON + -DBUILD_PYTHON_WRAPPING=ON cmake --build . --config RelWithDebInfo -- /maxcpucount:8 ctest --build-config RelWithDebInfo --parallel 8 cmake --build . --config RelWithDebInfo --target install -- /maxcpucount:8 @@ -750,8 +745,7 @@ cmake ../opensim-core \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DBUILD_PYTHON_WRAPPING=ON \ -DBUILD_JAVA_WRAPPING=ON \ - -DOPENSIM_DEPENDENCIES_DIR="~/opensim_dependencies_install" \ - -DWITH_BTK=ON + -DOPENSIM_DEPENDENCIES_DIR="~/opensim_dependencies_install" make -j8 ctest -j8 ``` @@ -885,14 +879,11 @@ You can get most of these dependencies using [Homebrew](http://brew.sh): 1. Simbody: Set the `SIMBODY_HOME` variable to where you installed Simbody (e.g., `~/simbody`). If you installed Simbody using `brew`, then CMake will find Simbody automatically. - 2. BTK: Set the `BTK_DIR` variable to the directory containing - `BTKConfig.cmake`. If you installed BTK in `~/BTKCore-install`, then - set `BTK_DIR` to `~/BTKCore-install/share/btk-0.4dev` - 3. docopt.cpp: Set the variable `docopt_DIR` to the directory + 2. docopt.cpp: Set the variable `docopt_DIR` to the directory containing `docopt-config.cmake`. If the root directory of your docopt.cpp installation is `~/docopt.cpp-install`, then set this variable to `~/docopt.cpp-install/lib/cmake`. - 4. spdlog: Set the variable `spdlog_DIR` to the directory containing + 3. spdlog: Set the variable `spdlog_DIR` to the directory containing `spdlogConfig.cmake`. If the root directory of your spdlog installation is `~/spdlog-install`, then set this variable to `~/spdlog-install/lib/spdlog/cmake`. @@ -975,7 +966,6 @@ specific Ubuntu versions under 'For the impatient' below. * [Build on your own](https://github.com/simbody/simbody#installing). * **C3D file support**: Biomechanical-ToolKit Core. Two options: * Let OpenSim get this for you using superbuild (see below). - * [Build on your own](https://github.com/klshrinidhi/BTKCore). * **command-line argument parsing**: docopt.cpp. Two options: * Let OpenSim get this for you using superbuild (see below); much easier! * [Build on your own](https://github.com/docopt/docopt.cpp) (no instructions). @@ -1095,14 +1085,11 @@ And you could get all the optional dependencies via: * Obatained on your own: 1. Simbody: Set the `SIMBODY_HOME` variable to where you installed Simbody (e.g., `~/simbody`). - 2. BTK: Set the `BTK_DIR` variable to the directory containing - `BTKConfig.cmake`. If you installed BTK in `~/BTK-install`, then set - `BTK-DIR` to `~/BTK-install/share/btk-0.4dev`. - 3. docopt.cpp: Set the variable `docopt_DIR` to the directory + 2. docopt.cpp: Set the variable `docopt_DIR` to the directory containing `docopt-config.cmake`. If the root directory of your docopt.cpp installation is `~/docopt.cpp-install`, then set this variable to `~/docopt.cpp-install/lib/cmake`. - 4. spdlog: Set the variable `spdlog_DIR` to the directory containing + 3. spdlog: Set the variable `spdlog_DIR` to the directory containing `spdlogConfig.cmake`. If the root directory of your spdlog installation is `~/spdlog-install`, then set this variable to `~/spdlog-install/lib/spdlog/cmake`. @@ -1134,7 +1121,7 @@ And you could get all the optional dependencies via: * `OPENSIM_PYTHON_VERSION` to choose if the Python wrapping is built for Python 2 or Python 3. * `BUILD_API_ONLY` if you don't want to build the command-line applications. - * `OPENSIM_COPY_DEPENDENCIES` to decide if Simbody and BTK are copied into + * `OPENSIM_COPY_DEPENDENCIES` to decide if Simbody is copied into the OpenSim installation; you want this off if you're installing OpenSim into `/usr/` or `/usr/local/`. 9. Click the **Configure** button again. Then, click **Generate** to create @@ -1204,8 +1191,7 @@ cmake ../opensim-core \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DOPENSIM_DEPENDENCIES_DIR="~/opensim_dependencies_install" \ -DBUILD_PYTHON_WRAPPING=ON \ - -DBUILD_JAVA_WRAPPING=ON \ - -DWITH_BTK=ON + -DBUILD_JAVA_WRAPPING=ON make -j8 ctest -j8 make -j8 install diff --git a/cmake/OpenSimConfig.cmake.in b/cmake/OpenSimConfig.cmake.in index 80e86b81e7..24c2e276f7 100644 --- a/cmake/OpenSimConfig.cmake.in +++ b/cmake/OpenSimConfig.cmake.in @@ -32,8 +32,8 @@ # # This file will also find Simbody; you do not # need to use `find_package(Simbody)` in your own project. If OpenSim's -# installation does *not* contain Simbody (and ezc3d or BTK), you might need to set -# CMAKE_PREFIX_PATH to the directory containing Simbody, and make sure that ezc3d or BTK +# installation does *not* contain Simbody (and ezc3d), you might need to set +# CMAKE_PREFIX_PATH to the directory containing Simbody, and make sure that ezc3d # libraries are available during runtime. # # Adapted from SimbodyConfig.cmake diff --git a/cmake/OpenSimMacros.cmake b/cmake/OpenSimMacros.cmake index 1404d61480..3282964956 100644 --- a/cmake/OpenSimMacros.cmake +++ b/cmake/OpenSimMacros.cmake @@ -555,7 +555,7 @@ endfunction() # Function to install shared libraries (any platform) from a dependency install # directory into the OpenSim installation. One use case is to install libraries # into the python package. -# PREFIX: A common part of the library file names (e.g., 'SimTK', 'ezc3d' or 'BTK'). +# PREFIX: A common part of the library file names (e.g., 'SimTK' or 'ezc3d'). # This is to avoid copying unrelated files from a folder like /usr/lib. # DEP_LIBS_DIR_WIN: Directory to search for the dependency's library, on # Windows. diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt index 0231bb4e5f..312e55e2b6 100644 --- a/dependencies/CMakeLists.txt +++ b/dependencies/CMakeLists.txt @@ -173,13 +173,6 @@ AddDependency(NAME ezc3d GIT_TAG Release_1.5.0 CMAKE_ARGS -DBUILD_EXAMPLE:BOOL=OFF) -AddDependency(NAME BTK - DEFAULT OFF - # GIT_URL https://github.com/Biomechanical-ToolKit/BTKCore.git - GIT_URL https://github.com/opensim-org/BTKCore.git - GIT_TAG 6d787d0be223851a8f454f2ee8c7d9e47b84cbbe - CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=ON) - AddDependency(NAME simbody DEFAULT ON GIT_URL https://github.com/simbody/simbody.git diff --git a/doc/doxyfile_shared.in b/doc/doxyfile_shared.in index 37943a81cc..7f0b0b30e7 100644 --- a/doc/doxyfile_shared.in +++ b/doc/doxyfile_shared.in @@ -2203,7 +2203,6 @@ INCLUDE_FILE_PATTERNS = "@PROJECT_SOURCE_DIR@/OpenSim/Common/Property.h" PREDEFINED = FINAL_11=final \ OVERRIDE_11=override \ OpenSim_DOXYGEN_Q_PROPERTY=Q_PROPERTY \ - WITH_BTK=1 \ DEPRECATED_14(x)= # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this From b2fdc4613f1b4e5540e19e3d46fa7323d8f4024a Mon Sep 17 00:00:00 2001 From: Alberto Casas Ortiz Date: Tue, 16 Aug 2022 04:08:39 +0200 Subject: [PATCH 2/4] Removed block of code that only was executed with BTK. --- OpenSim/Common/Test/testC3DFileAdapter.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/OpenSim/Common/Test/testC3DFileAdapter.cpp b/OpenSim/Common/Test/testC3DFileAdapter.cpp index c079218ed1..59caea1da2 100644 --- a/OpenSim/Common/Test/testC3DFileAdapter.cpp +++ b/OpenSim/Common/Test/testC3DFileAdapter.cpp @@ -171,13 +171,7 @@ void test(const std::string filename) { loadTime = watch.getElapsedTimeInNs(); cout << "\tC3DFileAdapter '" << filename << "' read with forces at COP in " << watch.formatNs(loadTime) << endl; - // on ci-biulds will define SKIP_TIMING as it is unpredictably slow on some - // machines - #if defined(NDEBUG) && !defined(SKIP_TIMING) - ASSERT(loadTime < MaximumLoadTimeInNs, __FILE__, __LINE__, - "Unable to load '" + filename + "' within " + - to_string(MaximumLoadTimeInNs) + "ns."); - #endif + std::shared_ptr force_table_cop = c3dFileAdapter.getForcesTable(tables2); downsample_table(*force_table_cop, 100); From 568c4a78d2f4021c63051bae7e5bc8f4fe23e1ed Mon Sep 17 00:00:00 2001 From: Alberto Casas Ortiz Date: Wed, 17 Aug 2022 00:10:48 +0200 Subject: [PATCH 3/4] Updated CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8bb6323cb..4217cf4780 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ v4.4.1 - Made `Component::getSocketNames` a `const` member method (previously: non-const) - Modifed the swig interface files to make OpenSim::PathPointSet adopt new PathPoints inserted into it. (Issue #3276) +- Remove BTK dependency and switched completely to ezc3d. v4.4 ==== From 6c7f6022c510722c6cacf6ee8502ad7cee2ec3a9 Mon Sep 17 00:00:00 2001 From: Alberto Date: Wed, 17 Aug 2022 19:30:37 +0100 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4d8a09039..5759711899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ v4.4.1 - Made `Component::getSocketNames` a `const` member method (previously: non-const) - Modifed the swig interface files to make OpenSim::PathPointSet adopt new PathPoints inserted into it. (Issue #3276) -- Remove BTK dependency and switched completely to ezc3d. +- Remove references to obsoleted dependency BTK, use ezc3d exclusively. - Fixed an issue with IPOPT libraries when building OpenSim with `OPENSIM_WITH_CASADI = ON` but `OPENSIM_WITH_TROPTER = OFF` (Issue #3267). v4.4