From fe96467e93169965a0fff0edb272492f47d30b8f Mon Sep 17 00:00:00 2001 From: dmronga Date: Wed, 21 Feb 2024 16:00:52 +0100 Subject: [PATCH] Use cmake options for including optional solvers and robot models, Move test case to subfolders for easier cmake structure --- CMakeLists.txt | 10 ++- scripts/full_install.sh | 5 +- scripts/install.sh | 2 +- scripts/run_tests.sh | 62 +++++++++++++------ src/controllers/CMakeLists.txt | 2 + .../controllers/test}/CMakeLists.txt | 7 ++- .../test}/test_pid_controllers.cpp | 5 +- .../test}/test_pos_pd_controllers.cpp | 9 +-- .../test}/test_pot_field_controllers.cpp | 11 ++-- src/core/CMakeLists.txt | 2 + src/core/test/CMakeLists.txt | 5 ++ {test/core => src/core/test}/test_core.cpp | 3 +- src/robot_models/CMakeLists.txt | 6 +- src/robot_models/hyrodyn/CMakeLists.txt | 2 + .../robot_models/hyrodyn/test}/CMakeLists.txt | 4 +- .../test}/test_robot_model_hyrodyn.cpp | 54 ++++++++-------- src/robot_models/kdl/CMakeLists.txt | 2 + .../robot_models/kdl/test}/CMakeLists.txt | 4 +- .../kdl/test}/test_robot_model_kdl.cpp | 34 +++++----- src/robot_models/pinocchio/CMakeLists.txt | 1 + .../pinocchio/test}/CMakeLists.txt | 3 +- .../test}/test_robot_model_pinocchio.cpp | 24 +++---- src/robot_models/rbdl/CMakeLists.txt | 2 + .../robot_models/rbdl/test}/CMakeLists.txt | 4 +- .../rbdl/test}/test_robot_model_rbdl.cpp | 16 ++--- src/robot_models/test/CMakeLists.txt | 7 +++ .../test}/test_model_consistency.cpp | 2 + .../robot_models/test}/test_robot_model.cpp | 0 .../robot_models/test}/test_robot_model.hpp | 2 +- src/scenes/acceleration/CMakeLists.txt | 2 + src/scenes/acceleration/test/CMakeLists.txt | 7 +++ .../test}/test_acceleration_scene.cpp | 4 +- .../acceleration_reduced_tsid/CMakeLists.txt | 2 + .../test/CMakeLists.txt | 7 +++ .../test_acceleration_scene_reduced_tsid.cpp | 4 +- src/scenes/acceleration_tsid/CMakeLists.txt | 2 + .../acceleration_tsid/test/CMakeLists.txt | 7 +++ .../test}/test_acceleration_scene_tsid.cpp | 4 +- src/scenes/velocity/CMakeLists.txt | 2 + src/scenes/velocity/test/CMakeLists.txt | 8 +++ .../velocity/test}/test_velocity_scene.cpp | 14 ++--- src/scenes/velocity_qp/CMakeLists.txt | 2 + src/scenes/velocity_qp/test/CMakeLists.txt | 8 +++ .../test_velocity_scene_quadratic_cost.cpp | 4 +- src/solvers/CMakeLists.txt | 7 +-- src/solvers/eiquadprog/CMakeLists.txt | 2 + .../solvers/eiquadprog/test}/CMakeLists.txt | 3 +- .../test}/test_eiquadprog_solver.cpp | 6 +- src/solvers/hls/CMakeLists.txt | 2 + src/solvers/hls/test/CMakeLists.txt | 5 ++ .../solvers/hls/test}/test_hls_solver.cpp | 2 + src/solvers/proxqp/CMakeLists.txt | 2 + src/solvers/proxqp/test/CMakeLists.txt | 5 ++ .../proxqp/test}/test_proxqp_solver.cpp | 8 ++- src/solvers/qpoases/CMakeLists.txt | 2 + src/solvers/qpoases/test/CMakeLists.txt | 5 ++ .../qpoases/test}/test_qpoases_solver.cpp | 4 +- src/solvers/qpswift/CMakeLists.txt | 2 + src/solvers/qpswift/QPSwiftSolver.cpp | 12 ++-- src/solvers/qpswift/test/CMakeLists.txt | 5 ++ .../qpswift/test}/test_qpswift_solver.cpp | 10 +-- test/CMakeLists.txt | 7 --- test/core/CMakeLists.txt | 4 -- test/robot_models/CMakeLists.txt | 22 ------- test/scenes/CMakeLists.txt | 36 ----------- test/solvers/CMakeLists.txt | 11 ---- test/solvers/hls/CMakeLists.txt | 4 -- test/solvers/proxqp/CMakeLists.txt | 4 -- test/solvers/qpoases/CMakeLists.txt | 4 -- test/solvers/qpswift/CMakeLists.txt | 4 -- test/suite.cpp | 3 - tutorials/rh5/CMakeLists.txt | 2 +- tutorials/rh5v2/CMakeLists.txt | 2 +- 73 files changed, 306 insertions(+), 246 deletions(-) rename {test/controllers => src/controllers/test}/CMakeLists.txt (76%) rename {test/controllers => src/controllers/test}/test_pid_controllers.cpp (97%) rename {test/controllers => src/controllers/test}/test_pos_pd_controllers.cpp (98%) rename {test/controllers => src/controllers/test}/test_pot_field_controllers.cpp (98%) create mode 100644 src/core/test/CMakeLists.txt rename {test/core => src/core/test}/test_core.cpp (98%) rename {test/robot_models/hyrodyn => src/robot_models/hyrodyn/test}/CMakeLists.txt (61%) rename {test/robot_models/hyrodyn => src/robot_models/hyrodyn/test}/test_robot_model_hyrodyn.cpp (79%) rename {test/robot_models/kdl => src/robot_models/kdl/test}/CMakeLists.txt (62%) rename {test/robot_models/kdl => src/robot_models/kdl/test}/test_robot_model_kdl.cpp (85%) rename {test/robot_models/pinocchio => src/robot_models/pinocchio/test}/CMakeLists.txt (71%) rename {test/robot_models/pinocchio => src/robot_models/pinocchio/test}/test_robot_model_pinocchio.cpp (88%) rename {test/robot_models/rbdl => src/robot_models/rbdl/test}/CMakeLists.txt (61%) rename {test/robot_models/rbdl => src/robot_models/rbdl/test}/test_robot_model_rbdl.cpp (91%) create mode 100644 src/robot_models/test/CMakeLists.txt rename {test/robot_models => src/robot_models/test}/test_model_consistency.cpp (99%) rename {test/robot_models => src/robot_models/test}/test_robot_model.cpp (100%) rename {test/robot_models => src/robot_models/test}/test_robot_model.hpp (95%) create mode 100644 src/scenes/acceleration/test/CMakeLists.txt rename {test/scenes => src/scenes/acceleration/test}/test_acceleration_scene.cpp (95%) create mode 100644 src/scenes/acceleration_reduced_tsid/test/CMakeLists.txt rename {test/scenes => src/scenes/acceleration_reduced_tsid/test}/test_acceleration_scene_reduced_tsid.cpp (97%) create mode 100644 src/scenes/acceleration_tsid/test/CMakeLists.txt rename {test/scenes => src/scenes/acceleration_tsid/test}/test_acceleration_scene_tsid.cpp (96%) create mode 100644 src/scenes/velocity/test/CMakeLists.txt rename {test/scenes => src/scenes/velocity/test}/test_velocity_scene.cpp (94%) create mode 100644 src/scenes/velocity_qp/test/CMakeLists.txt rename {test/scenes => src/scenes/velocity_qp/test}/test_velocity_scene_quadratic_cost.cpp (96%) rename {test/solvers/eiquadprog => src/solvers/eiquadprog/test}/CMakeLists.txt (68%) rename {test/solvers/eiquadprog => src/solvers/eiquadprog/test}/test_eiquadprog_solver.cpp (98%) create mode 100644 src/solvers/hls/test/CMakeLists.txt rename {test/solvers/hls => src/solvers/hls/test}/test_hls_solver.cpp (97%) create mode 100644 src/solvers/proxqp/test/CMakeLists.txt rename {test/solvers/proxqp => src/solvers/proxqp/test}/test_proxqp_solver.cpp (98%) create mode 100644 src/solvers/qpoases/test/CMakeLists.txt rename {test/solvers/qpoases => src/solvers/qpoases/test}/test_qpoases_solver.cpp (99%) create mode 100644 src/solvers/qpswift/test/CMakeLists.txt rename {test/solvers/qpswift => src/solvers/qpswift/test}/test_qpswift_solver.cpp (97%) delete mode 100644 test/CMakeLists.txt delete mode 100644 test/core/CMakeLists.txt delete mode 100644 test/robot_models/CMakeLists.txt delete mode 100644 test/scenes/CMakeLists.txt delete mode 100644 test/solvers/CMakeLists.txt delete mode 100644 test/solvers/hls/CMakeLists.txt delete mode 100644 test/solvers/proxqp/CMakeLists.txt delete mode 100644 test/solvers/qpoases/CMakeLists.txt delete mode 100644 test/solvers/qpswift/CMakeLists.txt delete mode 100644 test/suite.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index bbadce53..ddb31c9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,11 +7,19 @@ set(PROJECT_VERSION 0.2) set(API_VERSION ${PROJECT_VERSION}) list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) + +option(ROBOT_MODEL_PINOCCHIO "Build the Pinocchio-based robot model" OFF) +option(ROBOT_MODEL_KDL "Build the KDL-based robot model" OFF) +option(ROBOT_MODEL_HYRODYN "Build the HyRoDyn-based robot model" OFF) +option(SOLVER_PROXQP "Build the ProxQP-based solver" OFF) +option(SOLVER_EIQUADPROG "Build the Eiquadprog-based solver" OFF) +option(SOLVER_QPSWIFT "Build the QPSwift-based solver" OFF) + add_subdirectory(src) -add_subdirectory(test) add_subdirectory(tutorials) find_package(Doxygen) + if(DOXYGEN_FOUND) set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile) set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) diff --git a/scripts/full_install.sh b/scripts/full_install.sh index ca06b4cc..739a7529 100644 --- a/scripts/full_install.sh +++ b/scripts/full_install.sh @@ -91,6 +91,7 @@ make -j8 && sudo make install && cd ../.. # WBC mkdir wbc/build && cd wbc/build -cmake .. -DUSE_EIQUADPROG=1 -DUSE_KDL=1 -DUSE_PINOCCHIO=1 -DUSE_QPSWIFT=1 -DUSE_PROXQP=1 -make -j8 && sudo make install && cd ../.. +cmake .. -DROBOT_MODEL_PINOCCHIO=ON -DROBOT_MODEL_KDL=ON -DSOLVER_PROXQP=ON -DSOLVER_EIQUADPROG=ON -DSOLVER_QPSWIFT=ON -DCMAKE_BUILD_TYPE=RELEASE +make -j8 && sudo make install && cd .. + sudo ldconfig diff --git a/scripts/install.sh b/scripts/install.sh index 8d99f428..df715251 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -44,6 +44,6 @@ cmake .. && make -j8 && sudo make install && cd ../.. # WBC mkdir wbc/build && cd wbc/build -cmake .. +cmake .. -DCMAKE_BUILD_TYPE=RELEASE make -j8 && sudo make install sudo ldconfig diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index bc4cfeb1..387baabd 100644 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -1,77 +1,99 @@ # Controllers echo "Testing controllers ..." -cd build/test/controllers +cd build/src +cd controllers/test ./test_pid_controllers ./test_pos_pd_controllers ./test_pot_field_controllers +cd ../.. # Core echo "Testing core library ..." -cd ../core +cd core/test ./test_core +cd ../.. # Robot Models echo "Testing robot models ..." echo "Testing RobotModelRBDL ..." -cd ../robot_models/rbdl +cd robot_models/rbdl/test ./test_robot_model_rbdl -cd .. +cd ../.. if [ -d "kdl" ]; then echo "Testing RobotModelKDL ..." - cd kdl + cd kdl/test ./test_robot_model_kdl - cd .. + cd ../.. fi if [ -d "pinocchio" ]; then echo "Testing RobotModelPinocchio ..." - cd ../robot_models/pinocchio + cd pinocchio/test ./test_robot_model_pinocchio - cd .. + cd ../.. fi if [ -d "hyrodyn" ]; then echo "Testing RobotModelHyrodyn ..." - cd hyrodyn + cd hyrodyn/test ./test_robot_model_hyrodyn - cd .. + cd ../.. fi +cd .. # Scenes echo "Testing scenes ..." -cd ../scenes + echo "Testing VelocityScene ..." +cd scenes/velocity/test ./test_velocity_scene +cd ../.. + echo "Testing VelocitySceneQuadraticCost ..." +cd velocity_qp/test ./test_velocity_scene_quadratic_cost +cd ../.. + + echo "Testing AccelerationScene ..." +cd acceleration/test ./test_acceleration_scene +cd ../.. + echo "Testing AccelerationSceneTSID ..." +cd acceleration_tsid/test ./test_acceleration_scene_tsid +cd ../.. + echo "Testing AccelerationSceneReducedTSID ..." +cd acceleration_reduced_tsid/test ./test_acceleration_scene_reduced_tsid +cd ../../.. # Solvers echo "Testing hls ..." -cd ../solvers/hls +cd solvers/hls/test ./test_hls_solver +cd ../.. + echo "Testing QPOasesSolver ..." -cd ../qpoases +cd qpoases/test ./test_qpoases_solver -cd .. +cd ../.. if [ -d "eiquadprog" ]; then echo "Testing EiquadprogSolver ..." - cd eiquadprog + cd eiquadprog/test ./test_eiquadprog_solver - cd .. + cd ../.. fi if [ -d "proxqp" ]; then echo "Testing ProxQPSolver ..." - cd proxqp + cd proxqp/test ./test_proxqp_solver - cd .. + cd ../.. fi if [ -d "qpswift" ]; then echo "Testing QPSwiftSolver ..." - cd qpswift + cd qpswift/test ./test_qpswift_solver - cd ../../.. + cd ../.. fi +cd .. diff --git a/src/controllers/CMakeLists.txt b/src/controllers/CMakeLists.txt index 8930d085..cd8b4e35 100644 --- a/src/controllers/CMakeLists.txt +++ b/src/controllers/CMakeLists.txt @@ -20,3 +20,5 @@ install(TARGETS ${TARGET_NAME} CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${HEADERS} DESTINATION include/wbc/controllers) + +add_subdirectory(test) diff --git a/test/controllers/CMakeLists.txt b/src/controllers/test/CMakeLists.txt similarity index 76% rename from test/controllers/CMakeLists.txt rename to src/controllers/test/CMakeLists.txt index 04e172da..9dddbcc0 100644 --- a/test/controllers/CMakeLists.txt +++ b/src/controllers/test/CMakeLists.txt @@ -1,15 +1,16 @@ -add_executable(test_pot_field_controllers test_pot_field_controllers.cpp ../suite.cpp) +find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) +add_executable(test_pot_field_controllers test_pot_field_controllers.cpp) target_link_libraries(test_pot_field_controllers wbc-controllers Boost::unit_test_framework) -add_executable(test_pos_pd_controllers test_pos_pd_controllers.cpp ../suite.cpp) +add_executable(test_pos_pd_controllers test_pos_pd_controllers.cpp) target_link_libraries(test_pos_pd_controllers wbc-controllers Boost::unit_test_framework) -add_executable(test_pid_controllers test_pid_controllers.cpp ../suite.cpp) +add_executable(test_pid_controllers test_pid_controllers.cpp) target_link_libraries(test_pid_controllers wbc-controllers Boost::unit_test_framework) diff --git a/test/controllers/test_pid_controllers.cpp b/src/controllers/test/test_pid_controllers.cpp similarity index 97% rename from test/controllers/test_pid_controllers.cpp rename to src/controllers/test/test_pid_controllers.cpp index 98b64a42..6e781512 100644 --- a/test/controllers/test_pid_controllers.cpp +++ b/src/controllers/test/test_pid_controllers.cpp @@ -1,7 +1,9 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include #include -#include "controllers/JointTorquePIDController.hpp" +#include "../JointTorquePIDController.hpp" #include using namespace std; @@ -86,4 +88,3 @@ BOOST_AUTO_TEST_CASE(joint_torque_controller_test){ usleep(dt*1000*1000); } } - diff --git a/test/controllers/test_pos_pd_controllers.cpp b/src/controllers/test/test_pos_pd_controllers.cpp similarity index 98% rename from test/controllers/test_pos_pd_controllers.cpp rename to src/controllers/test/test_pos_pd_controllers.cpp index 6293c7a9..8d10c9aa 100644 --- a/test/controllers/test_pos_pd_controllers.cpp +++ b/src/controllers/test/test_pos_pd_controllers.cpp @@ -1,10 +1,12 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include #include #include -#include "controllers/CartesianPosPDController.hpp" -#include "controllers/JointPosPDController.hpp" -#include +#include "../CartesianPosPDController.hpp" +#include "../JointPosPDController.hpp" +#include "../ControllerTools.hpp" #include using namespace std; @@ -176,4 +178,3 @@ BOOST_AUTO_TEST_CASE(jnt_pos_pd_controller){ usleep(dt*1000*1000); } } - diff --git a/test/controllers/test_pot_field_controllers.cpp b/src/controllers/test/test_pot_field_controllers.cpp similarity index 98% rename from test/controllers/test_pot_field_controllers.cpp rename to src/controllers/test/test_pot_field_controllers.cpp index 694d0482..e77912d2 100644 --- a/test/controllers/test_pot_field_controllers.cpp +++ b/src/controllers/test/test_pot_field_controllers.cpp @@ -1,11 +1,13 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include #include #include -#include "controllers/CartesianPotentialFieldsController.hpp" -#include "controllers/RadialPotentialField.hpp" -#include "controllers/PlanarPotentialField.hpp" -#include "controllers/JointLimitAvoidanceController.hpp" +#include "../CartesianPotentialFieldsController.hpp" +#include "../RadialPotentialField.hpp" +#include "../PlanarPotentialField.hpp" +#include "../JointLimitAvoidanceController.hpp" using namespace std; using namespace ctrl_lib; @@ -307,4 +309,3 @@ BOOST_AUTO_TEST_CASE(joint_limit_avoidance) usleep(dt*1000*1000); } } - diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index cfc80559..2eb3c5b0 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -21,3 +21,5 @@ install(TARGETS ${TARGET_NAME} CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${HEADERS} DESTINATION include/wbc/core) + +add_subdirectory(test) diff --git a/src/core/test/CMakeLists.txt b/src/core/test/CMakeLists.txt new file mode 100644 index 00000000..0577417d --- /dev/null +++ b/src/core/test/CMakeLists.txt @@ -0,0 +1,5 @@ +find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) +add_executable(test_core test_core.cpp) +target_link_libraries(test_core + wbc-core + Boost::unit_test_framework) diff --git a/test/core/test_core.cpp b/src/core/test/test_core.cpp similarity index 98% rename from test/core/test_core.cpp rename to src/core/test/test_core.cpp index 52948db3..88bfdc9a 100644 --- a/test/core/test_core.cpp +++ b/src/core/test/test_core.cpp @@ -1,3 +1,5 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include #include #include @@ -110,4 +112,3 @@ BOOST_AUTO_TEST_CASE(scene_factory){ BOOST_CHECK_NO_THROW(scene = SceneFactory::createInstance("velocity", robot_model, solver, 1e-3)); BOOST_CHECK(scene != 0); } - diff --git a/src/robot_models/CMakeLists.txt b/src/robot_models/CMakeLists.txt index 590e4ce2..e1ffbdd5 100644 --- a/src/robot_models/CMakeLists.txt +++ b/src/robot_models/CMakeLists.txt @@ -1,11 +1,11 @@ add_subdirectory(rbdl) -if(USE_PINOCCHIO) +if(ROBOT_MODEL_PINOCCHIO) add_subdirectory(pinocchio) endif() -if(USE_HYRODYN) +if(ROBOT_MODEL_HYRODYN) add_subdirectory(hyrodyn) endif() -if(USE_KDL) +if(ROBOT_MODEL_KDL) add_subdirectory(kdl) endif() diff --git a/src/robot_models/hyrodyn/CMakeLists.txt b/src/robot_models/hyrodyn/CMakeLists.txt index d25fe175..993ddd2b 100644 --- a/src/robot_models/hyrodyn/CMakeLists.txt +++ b/src/robot_models/hyrodyn/CMakeLists.txt @@ -24,3 +24,5 @@ install(TARGETS ${TARGET_NAME} CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${HEADERS} DESTINATION include/wbc/robot_models/hyrodyn) + +add_subdirectory(test) diff --git a/test/robot_models/hyrodyn/CMakeLists.txt b/src/robot_models/hyrodyn/test/CMakeLists.txt similarity index 61% rename from test/robot_models/hyrodyn/CMakeLists.txt rename to src/robot_models/hyrodyn/test/CMakeLists.txt index 06e3df93..c8d70644 100644 --- a/test/robot_models/hyrodyn/CMakeLists.txt +++ b/src/robot_models/hyrodyn/test/CMakeLists.txt @@ -1,5 +1,5 @@ -add_executable(test_robot_model_hyrodyn test_robot_model_hyrodyn.cpp ../../suite.cpp ../test_robot_model.cpp) +find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) +add_executable(test_robot_model_hyrodyn test_robot_model_hyrodyn.cpp ../../test/test_robot_model.cpp) target_link_libraries(test_robot_model_hyrodyn wbc-robot_models-hyrodyn Boost::unit_test_framework) - diff --git a/test/robot_models/hyrodyn/test_robot_model_hyrodyn.cpp b/src/robot_models/hyrodyn/test/test_robot_model_hyrodyn.cpp similarity index 79% rename from test/robot_models/hyrodyn/test_robot_model_hyrodyn.cpp rename to src/robot_models/hyrodyn/test/test_robot_model_hyrodyn.cpp index f7de5748..9d6aebfd 100644 --- a/test/robot_models/hyrodyn/test_robot_model_hyrodyn.cpp +++ b/src/robot_models/hyrodyn/test/test_robot_model_hyrodyn.cpp @@ -1,6 +1,8 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include "robot_models/hyrodyn/RobotModelHyrodyn.hpp" #include -#include "../test_robot_model.hpp" +#include "../../test/test_robot_model.hpp" using namespace std; using namespace wbc; @@ -25,8 +27,8 @@ BOOST_AUTO_TEST_CASE(configure_and_update){ "floating_base_rot_x", "floating_base_rot_y", "floating_base_rot_z"}; // Valid config - config = RobotModelConfig("../../../../models/kuka/urdf/kuka_iiwa.urdf"); - config.submechanism_file = "../../../../models/kuka/hyrodyn/kuka_iiwa.yml"; + config = RobotModelConfig("../../../../../models/kuka/urdf/kuka_iiwa.urdf"); + config.submechanism_file = "../../../../../models/kuka/hyrodyn/kuka_iiwa.yml"; BOOST_CHECK(robot_model.configure(config) == true); for(size_t i = 0; i < robot_model.noOfJoints(); i++){ BOOST_CHECK(joint_names[i] == robot_model.jointNames()[i]); @@ -45,17 +47,17 @@ BOOST_AUTO_TEST_CASE(configure_and_update){ } // Invalid filename - config = RobotModelConfig("../../../../models/kuka/urdf/kuka_iiwa.urd"); + config = RobotModelConfig("../../../../../models/kuka/urdf/kuka_iiwa.urd"); BOOST_CHECK(robot_model.configure(config) == false); // Invalid submechanism file - config = RobotModelConfig("../../../../models/kuka/urdf/kuka_iiwa.urdf"); - config.submechanism_file = "../../../../models/kuka/hyrodyn/kuka_iiwa.ym"; + config = RobotModelConfig("../../../../../models/kuka/urdf/kuka_iiwa.urdf"); + config.submechanism_file = "../../../../../models/kuka/hyrodyn/kuka_iiwa.ym"; BOOST_CHECK(robot_model.configure(config) == false); // Valid config with floating base - config = RobotModelConfig("../../../../models/kuka/urdf/kuka_iiwa.urdf"); - config.submechanism_file = "../../../../models/kuka/hyrodyn/kuka_iiwa_floating_base.yml"; + config = RobotModelConfig("../../../../../models/kuka/urdf/kuka_iiwa.urdf"); + config.submechanism_file = "../../../../../models/kuka/hyrodyn/kuka_iiwa_floating_base.yml"; config.floating_base = true; BOOST_CHECK(robot_model.configure(config) == true); for(size_t i = 0; i < 6; i++){ @@ -90,15 +92,15 @@ BOOST_AUTO_TEST_CASE(configure_and_update){ } // Config with contact points - config = RobotModelConfig("../../../../models/kuka/urdf/kuka_iiwa.urdf"); - config.submechanism_file = "../../../../models/kuka/hyrodyn/kuka_iiwa.yml"; + config = RobotModelConfig("../../../../../models/kuka/urdf/kuka_iiwa.urdf"); + config.submechanism_file = "../../../../../models/kuka/hyrodyn/kuka_iiwa.yml"; config.contact_points.names.push_back("kuka_lbr_l_tcp"); config.contact_points.elements.push_back(wbc::ActiveContact(1,0.6)); BOOST_CHECK(robot_model.configure(config) == true); // Config with invalid contact points - config = RobotModelConfig("../../../../models/kuka/urdf/kuka_iiwa.urdf"); - config.submechanism_file = "../../../../models/kuka/hyrodyn/kuka_iiwa.yml"; + config = RobotModelConfig("../../../../../models/kuka/urdf/kuka_iiwa.urdf"); + config.submechanism_file = "../../../../../models/kuka/hyrodyn/kuka_iiwa.yml"; config.contact_points.names.push_back("XYZ"); config.contact_points.elements.push_back(wbc::ActiveContact(1,0.6)); BOOST_CHECK(robot_model.configure(config) == false); @@ -106,12 +108,12 @@ BOOST_AUTO_TEST_CASE(configure_and_update){ BOOST_AUTO_TEST_CASE(fk){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; string tip_frame = "kuka_lbr_l_tcp"; RobotModelPtr robot_model = make_shared(); RobotModelConfig cfg(urdf_file); - cfg.submechanism_file = "../../../../models/kuka/hyrodyn/kuka_iiwa_floating_base.yml"; + cfg.submechanism_file = "../../../../../models/kuka/hyrodyn/kuka_iiwa_floating_base.yml"; cfg.floating_base = true; BOOST_CHECK(robot_model->configure(cfg)); @@ -120,12 +122,12 @@ BOOST_AUTO_TEST_CASE(fk){ BOOST_AUTO_TEST_CASE(space_jacobian){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; string tip_frame = "kuka_lbr_l_tcp"; RobotModelPtr robot_model = make_shared(); RobotModelConfig cfg(urdf_file); - cfg.submechanism_file = "../../../../models/kuka/hyrodyn/kuka_iiwa_floating_base.yml"; + cfg.submechanism_file = "../../../../../models/kuka/hyrodyn/kuka_iiwa_floating_base.yml"; cfg.floating_base = true; BOOST_CHECK(robot_model->configure(cfg)); @@ -133,12 +135,12 @@ BOOST_AUTO_TEST_CASE(space_jacobian){ } BOOST_AUTO_TEST_CASE(body_jacobian){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; string tip_frame = "kuka_lbr_l_tcp"; RobotModelPtr robot_model = make_shared(); RobotModelConfig cfg(urdf_file); - cfg.submechanism_file = "../../../../models/kuka/hyrodyn/kuka_iiwa_floating_base.yml"; + cfg.submechanism_file = "../../../../../models/kuka/hyrodyn/kuka_iiwa_floating_base.yml"; cfg.floating_base = true; BOOST_CHECK(robot_model->configure(cfg)); @@ -146,12 +148,12 @@ BOOST_AUTO_TEST_CASE(body_jacobian){ } BOOST_AUTO_TEST_CASE(com_jacobian){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; string tip_frame = "kuka_lbr_l_tcp"; RobotModelPtr robot_model = make_shared(); RobotModelConfig cfg(urdf_file); - cfg.submechanism_file = "../../../../models/kuka/hyrodyn/kuka_iiwa.yml"; + cfg.submechanism_file = "../../../../../models/kuka/hyrodyn/kuka_iiwa.yml"; cfg.floating_base = false; BOOST_CHECK(robot_model->configure(cfg)); @@ -160,11 +162,11 @@ BOOST_AUTO_TEST_CASE(com_jacobian){ BOOST_AUTO_TEST_CASE(dynamics){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; RobotModelPtr robot_model = make_shared(); RobotModelConfig cfg(urdf_file); - cfg.submechanism_file = "../../../../models/kuka/hyrodyn/kuka_iiwa.yml"; + cfg.submechanism_file = "../../../../../models/kuka/hyrodyn/kuka_iiwa.yml"; cfg.floating_base = false; BOOST_CHECK(robot_model->configure(cfg)); @@ -182,14 +184,14 @@ BOOST_AUTO_TEST_CASE(compare_serial_vs_hybrid_model){ string tip = "LLAnklePitch_Link"; RobotModelHyrodyn robot_model_hybrid; - RobotModelConfig config_hybrid("../../../../models/rh5/urdf/rh5_single_leg_hybrid.urdf"); - config_hybrid.submechanism_file = "../../../../models/rh5/hyrodyn/rh5_single_leg_hybrid.yml"; + RobotModelConfig config_hybrid("../../../../../models/rh5/urdf/rh5_single_leg_hybrid.urdf"); + config_hybrid.submechanism_file = "../../../../../models/rh5/hyrodyn/rh5_single_leg_hybrid.yml"; BOOST_CHECK(robot_model_hybrid.configure(config_hybrid) == true); RobotModelHyrodyn robot_model_serial; - RobotModelConfig config_serial("../../../../models/rh5/urdf/rh5_single_leg.urdf"); - config_serial.submechanism_file = "../../../../models/rh5/hyrodyn/rh5_single_leg.yml"; + RobotModelConfig config_serial("../../../../../models/rh5/urdf/rh5_single_leg.urdf"); + config_serial.submechanism_file = "../../../../../models/rh5/hyrodyn/rh5_single_leg.yml"; BOOST_CHECK(robot_model_serial.configure(config_serial) == true); base::samples::Joints joint_state; diff --git a/src/robot_models/kdl/CMakeLists.txt b/src/robot_models/kdl/CMakeLists.txt index 2b3dd15b..1d0f7fb4 100644 --- a/src/robot_models/kdl/CMakeLists.txt +++ b/src/robot_models/kdl/CMakeLists.txt @@ -24,3 +24,5 @@ install(TARGETS ${TARGET_NAME} CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${HEADERS} DESTINATION include/wbc/robot_models/kdl) + +add_subdirectory(test) diff --git a/test/robot_models/kdl/CMakeLists.txt b/src/robot_models/kdl/test/CMakeLists.txt similarity index 62% rename from test/robot_models/kdl/CMakeLists.txt rename to src/robot_models/kdl/test/CMakeLists.txt index fdf675c5..e7d3147c 100644 --- a/test/robot_models/kdl/CMakeLists.txt +++ b/src/robot_models/kdl/test/CMakeLists.txt @@ -1,5 +1,5 @@ -add_executable(test_robot_model_kdl test_robot_model_kdl.cpp ../../suite.cpp ../test_robot_model.cpp) +find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) +add_executable(test_robot_model_kdl test_robot_model_kdl.cpp ../../test/test_robot_model.cpp) target_link_libraries(test_robot_model_kdl wbc-robot_models-kdl Boost::unit_test_framework) - diff --git a/test/robot_models/kdl/test_robot_model_kdl.cpp b/src/robot_models/kdl/test/test_robot_model_kdl.cpp similarity index 85% rename from test/robot_models/kdl/test_robot_model_kdl.cpp rename to src/robot_models/kdl/test/test_robot_model_kdl.cpp index 5a702939..0e3756a6 100644 --- a/test/robot_models/kdl/test_robot_model_kdl.cpp +++ b/src/robot_models/kdl/test/test_robot_model_kdl.cpp @@ -1,13 +1,15 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include -#include "robot_models/kdl/RobotModelKDL.hpp" -#include "robot_models/kdl/KinematicChainKDL.hpp" -#include "core/RobotModelConfig.hpp" +#include "../RobotModelKDL.hpp" +#include "../KinematicChainKDL.hpp" +#include #include #include #include -#include "tools/URDFTools.hpp" +#include #include -#include "../test_robot_model.hpp" +#include "../../test/test_robot_model.hpp" using namespace std; using namespace wbc; @@ -32,7 +34,7 @@ BOOST_AUTO_TEST_CASE(configure_and_update){ "floating_base_rot_x", "floating_base_rot_y", "floating_base_rot_z"}; // Valid config - config = RobotModelConfig("../../../../models/kuka/urdf/kuka_iiwa.urdf"); + config = RobotModelConfig("../../../../../models/kuka/urdf/kuka_iiwa.urdf"); BOOST_CHECK(robot_model.configure(config) == true); for(size_t i = 0; i < robot_model.noOfJoints(); i++){ BOOST_CHECK(joint_names[i] == robot_model.jointNames()[i]); @@ -55,7 +57,7 @@ BOOST_AUTO_TEST_CASE(configure_and_update){ } // Invalid filename - config = RobotModelConfig("../../../../models/kuka/urdf/kuka_iiwa.urd"); + config = RobotModelConfig("../../../../../models/kuka/urdf/kuka_iiwa.urd"); BOOST_CHECK(robot_model.configure(config) == false); // Empty filename @@ -63,8 +65,8 @@ BOOST_AUTO_TEST_CASE(configure_and_update){ BOOST_CHECK(robot_model.configure(config) == false); // Valid config with floating base - config = RobotModelConfig("../../../../models/kuka/urdf/kuka_iiwa.urdf"); - config.submechanism_file = "../../../../models/kuka/hyrodyn/kuka_iiwa_floating_base.yml"; + config = RobotModelConfig("../../../../../models/kuka/urdf/kuka_iiwa.urdf"); + config.submechanism_file = "../../../../../models/kuka/hyrodyn/kuka_iiwa_floating_base.yml"; config.floating_base = true; BOOST_CHECK(robot_model.configure(config) == true); for(size_t i = 0; i < 6; i++){ @@ -99,13 +101,13 @@ BOOST_AUTO_TEST_CASE(configure_and_update){ } // Config with contact points - config = RobotModelConfig("../../../../models/kuka/urdf/kuka_iiwa.urdf"); + config = RobotModelConfig("../../../../../models/kuka/urdf/kuka_iiwa.urdf"); config.contact_points.names.push_back("kuka_lbr_l_tcp"); config.contact_points.elements.push_back(ActiveContact(1,0.6)); BOOST_CHECK(robot_model.configure(config) == true); // Config with invalid contact points - config = RobotModelConfig("../../../../models/kuka/urdf/kuka_iiwa.urdf"); + config = RobotModelConfig("../../../../../models/kuka/urdf/kuka_iiwa.urdf"); config.contact_points.names.push_back("XYZ"); config.contact_points.elements.push_back(ActiveContact(1,0.6)); BOOST_CHECK(robot_model.configure(config) == false); @@ -113,7 +115,7 @@ BOOST_AUTO_TEST_CASE(configure_and_update){ } BOOST_AUTO_TEST_CASE(fk){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; string tip_frame = "kuka_lbr_l_tcp"; RobotModelPtr robot_model = make_shared(); @@ -126,7 +128,7 @@ BOOST_AUTO_TEST_CASE(fk){ BOOST_AUTO_TEST_CASE(space_jacobian){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; string tip_frame = "kuka_lbr_l_tcp"; RobotModelPtr robot_model = make_shared(); @@ -138,7 +140,7 @@ BOOST_AUTO_TEST_CASE(space_jacobian){ } BOOST_AUTO_TEST_CASE(body_jacobian){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; string tip_frame = "kuka_lbr_l_tcp"; RobotModelPtr robot_model = make_shared(); @@ -150,7 +152,7 @@ BOOST_AUTO_TEST_CASE(body_jacobian){ } BOOST_AUTO_TEST_CASE(com_jacobian){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; string tip_frame = "kuka_lbr_l_tcp"; RobotModelPtr robot_model = make_shared(); @@ -163,7 +165,7 @@ BOOST_AUTO_TEST_CASE(com_jacobian){ BOOST_AUTO_TEST_CASE(dynamics){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; RobotModelPtr robot_model = make_shared(); RobotModelConfig cfg(urdf_file); diff --git a/src/robot_models/pinocchio/CMakeLists.txt b/src/robot_models/pinocchio/CMakeLists.txt index ea2ba992..288fe291 100644 --- a/src/robot_models/pinocchio/CMakeLists.txt +++ b/src/robot_models/pinocchio/CMakeLists.txt @@ -27,3 +27,4 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.pc.in ${CMAKE_CURRENT_ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${HEADERS} DESTINATION include/wbc/robot_models/pinocchio) +add_subdirectory(test) diff --git a/test/robot_models/pinocchio/CMakeLists.txt b/src/robot_models/pinocchio/test/CMakeLists.txt similarity index 71% rename from test/robot_models/pinocchio/CMakeLists.txt rename to src/robot_models/pinocchio/test/CMakeLists.txt index e8fec11b..c1f48e0f 100644 --- a/test/robot_models/pinocchio/CMakeLists.txt +++ b/src/robot_models/pinocchio/test/CMakeLists.txt @@ -1,4 +1,5 @@ -add_executable(test_robot_model_pinocchio test_robot_model_pinocchio.cpp ../../suite.cpp ../test_robot_model.cpp) +find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) +add_executable(test_robot_model_pinocchio test_robot_model_pinocchio.cpp ../../test/test_robot_model.cpp) target_link_libraries(test_robot_model_pinocchio wbc-robot_models-pinocchio Boost::unit_test_framework diff --git a/test/robot_models/pinocchio/test_robot_model_pinocchio.cpp b/src/robot_models/pinocchio/test/test_robot_model_pinocchio.cpp similarity index 88% rename from test/robot_models/pinocchio/test_robot_model_pinocchio.cpp rename to src/robot_models/pinocchio/test/test_robot_model_pinocchio.cpp index e1d3f6ab..2e02c02b 100644 --- a/test/robot_models/pinocchio/test_robot_model_pinocchio.cpp +++ b/src/robot_models/pinocchio/test/test_robot_model_pinocchio.cpp @@ -1,8 +1,10 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include -#include "robot_models/pinocchio/RobotModelPinocchio.hpp" -#include "core/RobotModelConfig.hpp" -#include "tools/URDFTools.hpp" -#include "../test_robot_model.hpp" +#include "../RobotModelPinocchio.hpp" +#include +#include +#include "../../test/test_robot_model.hpp" using namespace std; using namespace wbc; @@ -26,7 +28,7 @@ BOOST_AUTO_TEST_CASE(configure_and_update){ std::vector floating_base_names = {"floating_base_trans_x", "floating_base_trans_y", "floating_base_trans_z", "floating_base_rot_x", "floating_base_rot_y", "floating_base_rot_z"}; // Valid config - config = RobotModelConfig("../../../../models/kuka/urdf/kuka_iiwa.urdf"); + config = RobotModelConfig("../../../../../models/kuka/urdf/kuka_iiwa.urdf"); BOOST_CHECK(robot_model.configure(config) == true); for(size_t i = 0; i < robot_model.noOfJoints(); i++){ @@ -46,7 +48,7 @@ BOOST_AUTO_TEST_CASE(configure_and_update){ } // Valid config with floating base - config = RobotModelConfig("../../../../models/kuka/urdf/kuka_iiwa.urdf"); + config = RobotModelConfig("../../../../../models/kuka/urdf/kuka_iiwa.urdf"); config.submechanism_file = "../../../../models/kuka/hyrodyn/kuka_iiwa_floating_base.yml"; config.floating_base = true; BOOST_CHECK(robot_model.configure(config) == true); @@ -84,7 +86,7 @@ BOOST_AUTO_TEST_CASE(configure_and_update){ BOOST_AUTO_TEST_CASE(fk){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; string tip_frame = "kuka_lbr_l_tcp"; RobotModelPtr robot_model = make_shared(); @@ -97,7 +99,7 @@ BOOST_AUTO_TEST_CASE(fk){ BOOST_AUTO_TEST_CASE(space_jacobian){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; string tip_frame = "kuka_lbr_l_tcp"; RobotModelPtr robot_model = make_shared(); @@ -109,7 +111,7 @@ BOOST_AUTO_TEST_CASE(space_jacobian){ } BOOST_AUTO_TEST_CASE(body_jacobian){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; string tip_frame = "kuka_lbr_l_tcp"; RobotModelPtr robot_model = make_shared(); @@ -121,7 +123,7 @@ BOOST_AUTO_TEST_CASE(body_jacobian){ } BOOST_AUTO_TEST_CASE(com_jacobian){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; string tip_frame = "kuka_lbr_l_tcp"; RobotModelPtr robot_model = make_shared(); @@ -134,7 +136,7 @@ BOOST_AUTO_TEST_CASE(com_jacobian){ BOOST_AUTO_TEST_CASE(dynamics){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; RobotModelPtr robot_model = make_shared(); RobotModelConfig cfg(urdf_file); diff --git a/src/robot_models/rbdl/CMakeLists.txt b/src/robot_models/rbdl/CMakeLists.txt index 16184a65..e444cc5d 100644 --- a/src/robot_models/rbdl/CMakeLists.txt +++ b/src/robot_models/rbdl/CMakeLists.txt @@ -29,3 +29,5 @@ install(TARGETS ${TARGET_NAME} CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${HEADERS} DESTINATION include/wbc/robot_models/rbdl) + +add_subdirectory(test) diff --git a/test/robot_models/rbdl/CMakeLists.txt b/src/robot_models/rbdl/test/CMakeLists.txt similarity index 61% rename from test/robot_models/rbdl/CMakeLists.txt rename to src/robot_models/rbdl/test/CMakeLists.txt index 0a389f48..6ad23705 100644 --- a/test/robot_models/rbdl/CMakeLists.txt +++ b/src/robot_models/rbdl/test/CMakeLists.txt @@ -1,5 +1,5 @@ -add_executable(test_robot_model_rbdl test_robot_model_rbdl.cpp ../../suite.cpp ../test_robot_model.cpp) +find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) +add_executable(test_robot_model_rbdl test_robot_model_rbdl.cpp ../../test/test_robot_model.cpp) target_link_libraries(test_robot_model_rbdl wbc-robot_models-rbdl Boost::unit_test_framework) - diff --git a/test/robot_models/rbdl/test_robot_model_rbdl.cpp b/src/robot_models/rbdl/test/test_robot_model_rbdl.cpp similarity index 91% rename from test/robot_models/rbdl/test_robot_model_rbdl.cpp rename to src/robot_models/rbdl/test/test_robot_model_rbdl.cpp index c520937d..c02b6bf7 100644 --- a/test/robot_models/rbdl/test_robot_model_rbdl.cpp +++ b/src/robot_models/rbdl/test/test_robot_model_rbdl.cpp @@ -1,8 +1,10 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include #include #include "tools/URDFTools.hpp" #include "robot_models/rbdl/RobotModelRBDL.hpp" -#include "../test_robot_model.hpp" +#include "../../test/test_robot_model.hpp" using namespace std; using namespace wbc; @@ -25,7 +27,7 @@ BOOST_AUTO_TEST_CASE(configure_and_update){ // Valid config RobotModelRBDL robot_model; - RobotModelConfig cfg("../../../../models/rh5/urdf/rh5.urdf"); + RobotModelConfig cfg("../../../../../models/rh5/urdf/rh5.urdf"); BOOST_CHECK(robot_model.configure(cfg)); for(size_t i = 0; i < robot_model.noOfJoints(); i++){ BOOST_CHECK(joint_names[i] == robot_model.jointNames()[i]); @@ -79,7 +81,7 @@ BOOST_AUTO_TEST_CASE(configure_and_update){ } BOOST_AUTO_TEST_CASE(fk){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; string tip_frame = "kuka_lbr_l_tcp"; RobotModelPtr robot_model = make_shared(); @@ -91,7 +93,7 @@ BOOST_AUTO_TEST_CASE(fk){ } BOOST_AUTO_TEST_CASE(space_jacobian){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; string tip_frame = "kuka_lbr_l_tcp"; RobotModelPtr robot_model = make_shared(); @@ -103,7 +105,7 @@ BOOST_AUTO_TEST_CASE(space_jacobian){ } BOOST_AUTO_TEST_CASE(body_jacobian){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; string tip_frame = "kuka_lbr_l_tcp"; RobotModelPtr robot_model = make_shared(); @@ -115,7 +117,7 @@ BOOST_AUTO_TEST_CASE(body_jacobian){ } BOOST_AUTO_TEST_CASE(com_jacobian){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; string tip_frame = "kuka_lbr_l_tcp"; RobotModelPtr robot_model = make_shared(); @@ -128,7 +130,7 @@ BOOST_AUTO_TEST_CASE(com_jacobian){ BOOST_AUTO_TEST_CASE(dynamics){ - string urdf_file = "../../../../models/kuka/urdf/kuka_iiwa.urdf"; + string urdf_file = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; RobotModelPtr robot_model = make_shared(); RobotModelConfig cfg(urdf_file); diff --git a/src/robot_models/test/CMakeLists.txt b/src/robot_models/test/CMakeLists.txt new file mode 100644 index 00000000..95ffdc29 --- /dev/null +++ b/src/robot_models/test/CMakeLists.txt @@ -0,0 +1,7 @@ +add_executable(test_model_consistency test_model_consistency.cpp test_robot_model.cpp) +target_link_libraries(test_model_consistency + wbc-robot_models-hyrodyn + wbc-robot_models-kdl + wbc-robot_models-rbdl + wbc-robot_models-pinocchio + Boost::unit_test_framework) diff --git a/test/robot_models/test_model_consistency.cpp b/src/robot_models/test/test_model_consistency.cpp similarity index 99% rename from test/robot_models/test_model_consistency.cpp rename to src/robot_models/test/test_model_consistency.cpp index 05566f4f..99fb68ab 100644 --- a/test/robot_models/test_model_consistency.cpp +++ b/src/robot_models/test/test_model_consistency.cpp @@ -1,3 +1,5 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include #include "robot_models/hyrodyn/RobotModelHyrodyn.hpp" #include "robot_models/rbdl/RobotModelRBDL.hpp" diff --git a/test/robot_models/test_robot_model.cpp b/src/robot_models/test/test_robot_model.cpp similarity index 100% rename from test/robot_models/test_robot_model.cpp rename to src/robot_models/test/test_robot_model.cpp diff --git a/test/robot_models/test_robot_model.hpp b/src/robot_models/test/test_robot_model.hpp similarity index 95% rename from test/robot_models/test_robot_model.hpp rename to src/robot_models/test/test_robot_model.hpp index b814b6ce..34590367 100644 --- a/test/robot_models/test_robot_model.hpp +++ b/src/robot_models/test/test_robot_model.hpp @@ -3,7 +3,7 @@ #include #include -#include "core/RobotModel.hpp" +#include namespace wbc { void printRbs(base::samples::RigidBodyStateSE3 rbs); diff --git a/src/scenes/acceleration/CMakeLists.txt b/src/scenes/acceleration/CMakeLists.txt index 18c9d451..0e8a056d 100644 --- a/src/scenes/acceleration/CMakeLists.txt +++ b/src/scenes/acceleration/CMakeLists.txt @@ -24,3 +24,5 @@ install(TARGETS ${TARGET_NAME} CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${HEADERS} DESTINATION include/wbc/scenes/acceleration) + +add_subdirectory(test) diff --git a/src/scenes/acceleration/test/CMakeLists.txt b/src/scenes/acceleration/test/CMakeLists.txt new file mode 100644 index 00000000..86e93639 --- /dev/null +++ b/src/scenes/acceleration/test/CMakeLists.txt @@ -0,0 +1,7 @@ +find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) +add_executable(test_acceleration_scene test_acceleration_scene.cpp) +target_link_libraries(test_acceleration_scene + wbc-scenes-acceleration + wbc-robot_models-rbdl + wbc-solvers-qpoases + Boost::unit_test_framework) diff --git a/test/scenes/test_acceleration_scene.cpp b/src/scenes/acceleration/test/test_acceleration_scene.cpp similarity index 95% rename from test/scenes/test_acceleration_scene.cpp rename to src/scenes/acceleration/test/test_acceleration_scene.cpp index fce77212..e2990dbe 100644 --- a/test/scenes/test_acceleration_scene.cpp +++ b/src/scenes/acceleration/test/test_acceleration_scene.cpp @@ -1,3 +1,5 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include #include "robot_models/rbdl/RobotModelRBDL.hpp" #include "scenes/acceleration/AccelerationScene.hpp" @@ -15,7 +17,7 @@ BOOST_AUTO_TEST_CASE(simple_test){ // Configure Robot model shared_ptr robot_model = make_shared(); RobotModelConfig config; - config.file_or_string = "../../../models/kuka/urdf/kuka_iiwa.urdf"; + config.file_or_string = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; BOOST_CHECK_EQUAL(robot_model->configure(config), true); base::samples::Joints joint_state; diff --git a/src/scenes/acceleration_reduced_tsid/CMakeLists.txt b/src/scenes/acceleration_reduced_tsid/CMakeLists.txt index 4f3fd8dd..e21affaf 100644 --- a/src/scenes/acceleration_reduced_tsid/CMakeLists.txt +++ b/src/scenes/acceleration_reduced_tsid/CMakeLists.txt @@ -24,3 +24,5 @@ install(TARGETS ${TARGET_NAME} CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${HEADERS} DESTINATION include/wbc/scenes/acceleration_reduced_tsid) + +add_subdirectory(test) diff --git a/src/scenes/acceleration_reduced_tsid/test/CMakeLists.txt b/src/scenes/acceleration_reduced_tsid/test/CMakeLists.txt new file mode 100644 index 00000000..16b33a42 --- /dev/null +++ b/src/scenes/acceleration_reduced_tsid/test/CMakeLists.txt @@ -0,0 +1,7 @@ +find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) +add_executable(test_acceleration_scene_reduced_tsid test_acceleration_scene_reduced_tsid.cpp) +target_link_libraries(test_acceleration_scene_reduced_tsid + wbc-scenes-acceleration_reduced_tsid + wbc-robot_models-rbdl + wbc-solvers-qpoases + Boost::unit_test_framework) diff --git a/test/scenes/test_acceleration_scene_reduced_tsid.cpp b/src/scenes/acceleration_reduced_tsid/test/test_acceleration_scene_reduced_tsid.cpp similarity index 97% rename from test/scenes/test_acceleration_scene_reduced_tsid.cpp rename to src/scenes/acceleration_reduced_tsid/test/test_acceleration_scene_reduced_tsid.cpp index c5e7f153..e3cb9621 100644 --- a/test/scenes/test_acceleration_scene_reduced_tsid.cpp +++ b/src/scenes/acceleration_reduced_tsid/test/test_acceleration_scene_reduced_tsid.cpp @@ -1,3 +1,5 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include #include "robot_models/rbdl/RobotModelRBDL.hpp" #include "scenes/acceleration_reduced_tsid/AccelerationSceneReducedTSID.hpp" @@ -15,7 +17,7 @@ BOOST_AUTO_TEST_CASE(simple_test){ // Configure Robot model shared_ptr robot_model = make_shared(); RobotModelConfig config; - config.file_or_string = "../../../models/rh5/urdf/rh5_legs.urdf"; + config.file_or_string = "../../../../../models/rh5/urdf/rh5_legs.urdf"; config.floating_base = true; config.contact_points.names = {"FL_SupportCenter", "FR_SupportCenter"}; wbc::ActiveContact contact(1,0.6); diff --git a/src/scenes/acceleration_tsid/CMakeLists.txt b/src/scenes/acceleration_tsid/CMakeLists.txt index 25ad80d7..fd853325 100644 --- a/src/scenes/acceleration_tsid/CMakeLists.txt +++ b/src/scenes/acceleration_tsid/CMakeLists.txt @@ -24,3 +24,5 @@ install(TARGETS ${TARGET_NAME} CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${HEADERS} DESTINATION include/wbc/scenes/acceleration_tsid) + +add_subdirectory(test) diff --git a/src/scenes/acceleration_tsid/test/CMakeLists.txt b/src/scenes/acceleration_tsid/test/CMakeLists.txt new file mode 100644 index 00000000..541d5820 --- /dev/null +++ b/src/scenes/acceleration_tsid/test/CMakeLists.txt @@ -0,0 +1,7 @@ +find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) +add_executable(test_acceleration_scene_tsid test_acceleration_scene_tsid.cpp) +target_link_libraries(test_acceleration_scene_tsid + wbc-scenes-acceleration_tsid + wbc-robot_models-rbdl + wbc-solvers-qpoases + Boost::unit_test_framework) diff --git a/test/scenes/test_acceleration_scene_tsid.cpp b/src/scenes/acceleration_tsid/test/test_acceleration_scene_tsid.cpp similarity index 96% rename from test/scenes/test_acceleration_scene_tsid.cpp rename to src/scenes/acceleration_tsid/test/test_acceleration_scene_tsid.cpp index b6b57c31..40bda2d6 100644 --- a/test/scenes/test_acceleration_scene_tsid.cpp +++ b/src/scenes/acceleration_tsid/test/test_acceleration_scene_tsid.cpp @@ -1,3 +1,5 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include #include "robot_models/rbdl/RobotModelRBDL.hpp" #include "scenes/acceleration_tsid/AccelerationSceneTSID.hpp" @@ -15,7 +17,7 @@ BOOST_AUTO_TEST_CASE(simple_test){ // Configure Robot model shared_ptr robot_model = make_shared(); RobotModelConfig config; - config.file_or_string = "../../../models/rh5/urdf/rh5_legs.urdf"; + config.file_or_string = "../../../../../models/rh5/urdf/rh5_legs.urdf"; config.floating_base = true; config.contact_points.names = {"FL_SupportCenter", "FR_SupportCenter"}; wbc::ActiveContact contact(1,0.6); diff --git a/src/scenes/velocity/CMakeLists.txt b/src/scenes/velocity/CMakeLists.txt index 38e148d7..59adfedc 100644 --- a/src/scenes/velocity/CMakeLists.txt +++ b/src/scenes/velocity/CMakeLists.txt @@ -24,3 +24,5 @@ install(TARGETS ${TARGET_NAME} CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${HEADERS} DESTINATION include/wbc/scenes/velocity) + +add_subdirectory(test) diff --git a/src/scenes/velocity/test/CMakeLists.txt b/src/scenes/velocity/test/CMakeLists.txt new file mode 100644 index 00000000..d500eba2 --- /dev/null +++ b/src/scenes/velocity/test/CMakeLists.txt @@ -0,0 +1,8 @@ +find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) +add_executable(test_velocity_scene test_velocity_scene.cpp) +target_link_libraries(test_velocity_scene + wbc-scenes-velocity + wbc-robot_models-rbdl + wbc-solvers-hls + Boost::unit_test_framework) + diff --git a/test/scenes/test_velocity_scene.cpp b/src/scenes/velocity/test/test_velocity_scene.cpp similarity index 94% rename from test/scenes/test_velocity_scene.cpp rename to src/scenes/velocity/test/test_velocity_scene.cpp index 8cf2ba72..d015ab5f 100644 --- a/test/scenes/test_velocity_scene.cpp +++ b/src/scenes/velocity/test/test_velocity_scene.cpp @@ -1,3 +1,5 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include #include "robot_models/rbdl/RobotModelRBDL.hpp" #include "scenes/velocity/VelocityScene.hpp" @@ -16,7 +18,7 @@ BOOST_AUTO_TEST_CASE(configuration_test){ shared_ptr robot_model = make_shared(); RobotModelConfig config; - config.file_or_string = "../../../models/kuka/urdf/kuka_iiwa.urdf"; + config.file_or_string = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; BOOST_CHECK_EQUAL(robot_model->configure(config), true); QPSolverPtr solver = std::make_shared(); VelocityScene wbc_scene(robot_model, solver, 1e-3); @@ -47,7 +49,7 @@ BOOST_AUTO_TEST_CASE(simple_test){ // Configure Robot model shared_ptr robot_model = make_shared(); RobotModelConfig config; - config.file_or_string = "../../../models/kuka/urdf/kuka_iiwa.urdf"; + config.file_or_string = "../../../../../models/kuka/urdf/kuka_iiwa.urdf"; BOOST_CHECK(robot_model->configure(config)); base::samples::Joints joint_state; @@ -91,11 +93,3 @@ BOOST_AUTO_TEST_CASE(simple_test){ BOOST_CHECK(fabs(status[0].y_ref[i+3] - status[0].y_solution[i]) < 1e5); } } - - - - - - - - diff --git a/src/scenes/velocity_qp/CMakeLists.txt b/src/scenes/velocity_qp/CMakeLists.txt index a5307e99..953e4f67 100644 --- a/src/scenes/velocity_qp/CMakeLists.txt +++ b/src/scenes/velocity_qp/CMakeLists.txt @@ -25,3 +25,5 @@ install(TARGETS ${TARGET_NAME} CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${HEADERS} DESTINATION include/wbc/scenes/velocity_qp) + +add_subdirectory(test) diff --git a/src/scenes/velocity_qp/test/CMakeLists.txt b/src/scenes/velocity_qp/test/CMakeLists.txt new file mode 100644 index 00000000..f5a89921 --- /dev/null +++ b/src/scenes/velocity_qp/test/CMakeLists.txt @@ -0,0 +1,8 @@ +find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) +add_executable(test_velocity_scene_quadratic_cost test_velocity_scene_quadratic_cost.cpp) +target_link_libraries(test_velocity_scene_quadratic_cost + wbc-scenes-velocity_qp + wbc-robot_models-rbdl + wbc-solvers-qpoases + Boost::unit_test_framework) + diff --git a/test/scenes/test_velocity_scene_quadratic_cost.cpp b/src/scenes/velocity_qp/test/test_velocity_scene_quadratic_cost.cpp similarity index 96% rename from test/scenes/test_velocity_scene_quadratic_cost.cpp rename to src/scenes/velocity_qp/test/test_velocity_scene_quadratic_cost.cpp index 56749013..da3a23d7 100644 --- a/test/scenes/test_velocity_scene_quadratic_cost.cpp +++ b/src/scenes/velocity_qp/test/test_velocity_scene_quadratic_cost.cpp @@ -1,3 +1,5 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include #include "robot_models/rbdl/RobotModelRBDL.hpp" #include "scenes/velocity_qp/VelocitySceneQP.hpp" @@ -15,7 +17,7 @@ BOOST_AUTO_TEST_CASE(simple_test){ // Configure Robot model shared_ptr robot_model = make_shared(); RobotModelConfig config; - config.file_or_string = "../../../models/rh5/urdf/rh5_legs.urdf"; + config.file_or_string = "../../../../../models/rh5/urdf/rh5_legs.urdf"; config.floating_base = true; config.contact_points.names = {"FL_SupportCenter", "FR_SupportCenter"}; config.contact_points.elements = {ActiveContact(1,0.6),ActiveContact(1,0.6)}; diff --git a/src/solvers/CMakeLists.txt b/src/solvers/CMakeLists.txt index bfbec159..de02170d 100644 --- a/src/solvers/CMakeLists.txt +++ b/src/solvers/CMakeLists.txt @@ -1,12 +1,11 @@ -set(HEADERS qp_solver.hpp) add_subdirectory(qpoases) add_subdirectory(hls) -if(USE_EIQUADPROG) +if(SOLVER_EIQUADPROG) add_subdirectory(eiquadprog) endif() -if(USE_QPSWIFT) +if(SOLVER_QPSWIFT) add_subdirectory(qpswift) endif() -if(USE_PROXQP) +if(SOLVER_PROXQP) add_subdirectory(proxqp) endif() diff --git a/src/solvers/eiquadprog/CMakeLists.txt b/src/solvers/eiquadprog/CMakeLists.txt index 0bc07ef6..c58a7129 100644 --- a/src/solvers/eiquadprog/CMakeLists.txt +++ b/src/solvers/eiquadprog/CMakeLists.txt @@ -24,3 +24,5 @@ install(TARGETS ${TARGET_NAME} CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${HEADERS} DESTINATION include/${PROJECT_NAME}/solvers/eiquadprog) + +add_subdirectory(test) diff --git a/test/solvers/eiquadprog/CMakeLists.txt b/src/solvers/eiquadprog/test/CMakeLists.txt similarity index 68% rename from test/solvers/eiquadprog/CMakeLists.txt rename to src/solvers/eiquadprog/test/CMakeLists.txt index 8cdb9573..df6e5dae 100644 --- a/test/solvers/eiquadprog/CMakeLists.txt +++ b/src/solvers/eiquadprog/test/CMakeLists.txt @@ -1,4 +1,5 @@ -add_executable(test_eiquadprog_solver test_eiquadprog_solver.cpp ../../suite.cpp) +find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) +add_executable(test_eiquadprog_solver test_eiquadprog_solver.cpp) target_link_libraries(test_eiquadprog_solver wbc-solvers-eiquadprog Boost::unit_test_framework) diff --git a/test/solvers/eiquadprog/test_eiquadprog_solver.cpp b/src/solvers/eiquadprog/test/test_eiquadprog_solver.cpp similarity index 98% rename from test/solvers/eiquadprog/test_eiquadprog_solver.cpp rename to src/solvers/eiquadprog/test/test_eiquadprog_solver.cpp index d6c48b90..c47b35b6 100644 --- a/test/solvers/eiquadprog/test_eiquadprog_solver.cpp +++ b/src/solvers/eiquadprog/test/test_eiquadprog_solver.cpp @@ -1,8 +1,10 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include #include #include -#include "core/QuadraticProgram.hpp" -#include "solvers/eiquadprog/EiquadprogSolver.hpp" +#include +#include "../EiquadprogSolver.hpp" using namespace wbc; using namespace std; diff --git a/src/solvers/hls/CMakeLists.txt b/src/solvers/hls/CMakeLists.txt index 54279b15..d53f97bf 100644 --- a/src/solvers/hls/CMakeLists.txt +++ b/src/solvers/hls/CMakeLists.txt @@ -20,3 +20,5 @@ install(TARGETS ${TARGET_NAME} CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${HEADERS} DESTINATION include/${PROJECT_NAME}/solvers/hls) + +add_subdirectory(test) diff --git a/src/solvers/hls/test/CMakeLists.txt b/src/solvers/hls/test/CMakeLists.txt new file mode 100644 index 00000000..2abd7c80 --- /dev/null +++ b/src/solvers/hls/test/CMakeLists.txt @@ -0,0 +1,5 @@ +find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) +add_executable(test_hls_solver test_hls_solver.cpp) +target_link_libraries(test_hls_solver + wbc-solvers-hls + Boost::unit_test_framework) diff --git a/test/solvers/hls/test_hls_solver.cpp b/src/solvers/hls/test/test_hls_solver.cpp similarity index 97% rename from test/solvers/hls/test_hls_solver.cpp rename to src/solvers/hls/test/test_hls_solver.cpp index dc5d470e..ef1c1f89 100644 --- a/test/solvers/hls/test_hls_solver.cpp +++ b/src/solvers/hls/test/test_hls_solver.cpp @@ -1,3 +1,5 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include #include "solvers/hls/HierarchicalLSSolver.hpp" #include "core/QuadraticProgram.hpp" diff --git a/src/solvers/proxqp/CMakeLists.txt b/src/solvers/proxqp/CMakeLists.txt index c0cb88b4..f1884c1a 100644 --- a/src/solvers/proxqp/CMakeLists.txt +++ b/src/solvers/proxqp/CMakeLists.txt @@ -26,3 +26,5 @@ install(TARGETS ${TARGET_NAME} CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${HEADERS} DESTINATION include/${PROJECT_NAME}/solvers/proxqp) + +add_subdirectory(test) diff --git a/src/solvers/proxqp/test/CMakeLists.txt b/src/solvers/proxqp/test/CMakeLists.txt new file mode 100644 index 00000000..0237d8c8 --- /dev/null +++ b/src/solvers/proxqp/test/CMakeLists.txt @@ -0,0 +1,5 @@ +find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) +add_executable(test_proxqp_solver test_proxqp_solver.cpp) +target_link_libraries(test_proxqp_solver + wbc-solvers-proxqp + ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) diff --git a/test/solvers/proxqp/test_proxqp_solver.cpp b/src/solvers/proxqp/test/test_proxqp_solver.cpp similarity index 98% rename from test/solvers/proxqp/test_proxqp_solver.cpp rename to src/solvers/proxqp/test/test_proxqp_solver.cpp index f59a7e30..e17770dd 100644 --- a/test/solvers/proxqp/test_proxqp_solver.cpp +++ b/src/solvers/proxqp/test/test_proxqp_solver.cpp @@ -1,8 +1,10 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include #include #include -#include "core/QuadraticProgram.hpp" -#include "solvers/proxqp/ProxQPSolver.hpp" +#include +#include "../ProxQPSolver.hpp" using namespace wbc; using namespace std; @@ -172,7 +174,7 @@ BOOST_AUTO_TEST_CASE(solver_proxqp_with_inequality_constraints) long useconds = end.tv_usec - start.tv_usec; Eigen::VectorXd test = A*solver_output; - + for(uint j = 0; j < NO_JOINTS; ++j) BOOST_CHECK((qp.lower_y(j)-1e-9) <= test(j) && test(j) <= (qp.upper_y(j)+1e-9)); } diff --git a/src/solvers/qpoases/CMakeLists.txt b/src/solvers/qpoases/CMakeLists.txt index e75a195e..f6fb4c1a 100644 --- a/src/solvers/qpoases/CMakeLists.txt +++ b/src/solvers/qpoases/CMakeLists.txt @@ -24,3 +24,5 @@ install(TARGETS ${TARGET_NAME} CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${HEADERS} DESTINATION include/${PROJECT_NAME}/solvers/qpoases) + +add_subdirectory(test) diff --git a/src/solvers/qpoases/test/CMakeLists.txt b/src/solvers/qpoases/test/CMakeLists.txt new file mode 100644 index 00000000..97d8aa29 --- /dev/null +++ b/src/solvers/qpoases/test/CMakeLists.txt @@ -0,0 +1,5 @@ +find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) +add_executable(test_qpoases_solver test_qpoases_solver.cpp) +target_link_libraries(test_qpoases_solver + wbc-solvers-qpoases + Boost::unit_test_framework) diff --git a/test/solvers/qpoases/test_qpoases_solver.cpp b/src/solvers/qpoases/test/test_qpoases_solver.cpp similarity index 99% rename from test/solvers/qpoases/test_qpoases_solver.cpp rename to src/solvers/qpoases/test/test_qpoases_solver.cpp index 4ad0b52b..295fa892 100644 --- a/test/solvers/qpoases/test_qpoases_solver.cpp +++ b/src/solvers/qpoases/test/test_qpoases_solver.cpp @@ -1,3 +1,5 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include #include #include @@ -280,4 +282,4 @@ BOOST_AUTO_TEST_CASE(solver_qpoases_bounded) for(uint j = 0; j < NO_JOINTS; ++j) BOOST_CHECK((qp.lower_x(j)-1e-9) <= solver_output(j) && solver_output(j) <= (qp.upper_x(j)+1e-9)); -} \ No newline at end of file +} diff --git a/src/solvers/qpswift/CMakeLists.txt b/src/solvers/qpswift/CMakeLists.txt index 829457fc..e5cff08c 100644 --- a/src/solvers/qpswift/CMakeLists.txt +++ b/src/solvers/qpswift/CMakeLists.txt @@ -24,3 +24,5 @@ install(TARGETS ${TARGET_NAME} CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc DESTINATION lib/pkgconfig) INSTALL(FILES ${HEADERS} DESTINATION include/${PROJECT_NAME}/solvers/qpswift) + +add_subdirectory(test) diff --git a/src/solvers/qpswift/QPSwiftSolver.cpp b/src/solvers/qpswift/QPSwiftSolver.cpp index 042502d5..69b00ce3 100644 --- a/src/solvers/qpswift/QPSwiftSolver.cpp +++ b/src/solvers/qpswift/QPSwiftSolver.cpp @@ -1,5 +1,5 @@ #include "QPSwiftSolver.hpp" -#include +#include #include #include @@ -23,14 +23,14 @@ QPSwiftSolver::~QPSwiftSolver(){ } void QPSwiftSolver::toQpSwift(const wbc::QuadraticProgram &qp){ - - G.setZero(); + + G.setZero(); P = qp.H; c = qp.g; A = qp.A; b = qp.b; - + // create inequalities matrix (inequalities constraints + bounds) G.middleRows(0, qp.nin) = qp.C; G.middleRows(qp.nin, qp.nin) = -qp.C; @@ -71,11 +71,11 @@ void QPSwiftSolver::solve(const wbc::HierarchicalQP &hierarchical_qp, base::Vect const wbc::QuadraticProgram &qp = hierarchical_qp[0]; - if(!configured){ + if(!configured){ // Count equality / inequality constraints n_dec = qp.nq; n_eq = qp.neq; - n_ineq = 2 * (qp.nin + qp.upper_x.size()); + n_ineq = 2 * (qp.nin + qp.upper_x.size()); A.resize(n_eq, n_dec); b.resize(n_eq); diff --git a/src/solvers/qpswift/test/CMakeLists.txt b/src/solvers/qpswift/test/CMakeLists.txt new file mode 100644 index 00000000..1e09d643 --- /dev/null +++ b/src/solvers/qpswift/test/CMakeLists.txt @@ -0,0 +1,5 @@ +find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) +add_executable(test_qpswift_solver test_qpswift_solver.cpp) +target_link_libraries(test_qpswift_solver + wbc-solvers-qpswift + Boost::unit_test_framework) diff --git a/test/solvers/qpswift/test_qpswift_solver.cpp b/src/solvers/qpswift/test/test_qpswift_solver.cpp similarity index 97% rename from test/solvers/qpswift/test_qpswift_solver.cpp rename to src/solvers/qpswift/test/test_qpswift_solver.cpp index 4da48f04..bdfff7af 100644 --- a/test/solvers/qpswift/test_qpswift_solver.cpp +++ b/src/solvers/qpswift/test/test_qpswift_solver.cpp @@ -1,8 +1,10 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MAIN #include #include #include -#include "core/QuadraticProgram.hpp" -#include "solvers/qpswift/QPSwiftSolver.hpp" +#include +#include "../QPSwiftSolver.hpp" using namespace wbc; using namespace std; @@ -24,7 +26,7 @@ BOOST_AUTO_TEST_CASE(solver_qp_swift_without_constraints) wbc::QuadraticProgram qp; qp.resize(NO_JOINTS, NO_EQ_CONSTRAINTS, NO_IN_CONSTRAINTS, WITH_BOUNDS); - + // qp.lower_y.resize(0); // qp.upper_y.resize(0); @@ -43,7 +45,7 @@ BOOST_AUTO_TEST_CASE(solver_qp_swift_without_constraints) qp.H = A.transpose()*A; qp.g = -(A.transpose()*y).transpose(); - + qp.lower_x.setConstant(-1000); qp.upper_x.setConstant(1000); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 94f7e384..00000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -find_package(Boost COMPONENTS system filesystem unit_test_framework serialization REQUIRED) - -add_subdirectory(controllers) -add_subdirectory(core) -add_subdirectory(robot_models) -add_subdirectory(scenes) -add_subdirectory(solvers) diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt deleted file mode 100644 index 49cf5e09..00000000 --- a/test/core/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -add_executable(test_core test_core.cpp ../suite.cpp) -target_link_libraries(test_core - wbc-core - Boost::unit_test_framework) diff --git a/test/robot_models/CMakeLists.txt b/test/robot_models/CMakeLists.txt deleted file mode 100644 index 7f5045e1..00000000 --- a/test/robot_models/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -add_subdirectory(rbdl) -if(USE_PINOCCHIO) - add_subdirectory(pinocchio) -endif() -if(USE_HYRODYN) - add_subdirectory(hyrodyn) -endif() -if(USE_KDL) - add_subdirectory(kdl) -endif() - - -if(USE_HYRODYN AND USE_KDL AND USE_PINOCCHIO) - - add_executable(test_model_consistency test_model_consistency.cpp ../suite.cpp test_robot_model.cpp) - target_link_libraries(test_model_consistency - wbc-robot_models-hyrodyn - wbc-robot_models-kdl - wbc-robot_models-rbdl - wbc-robot_models-pinocchio - Boost::unit_test_framework) -endif() diff --git a/test/scenes/CMakeLists.txt b/test/scenes/CMakeLists.txt deleted file mode 100644 index 493d8413..00000000 --- a/test/scenes/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -add_executable(test_velocity_scene test_velocity_scene.cpp ../suite.cpp) -target_link_libraries(test_velocity_scene - wbc-scenes-velocity - wbc-robot_models-rbdl - wbc-solvers-hls - Boost::unit_test_framework) - -add_executable(test_velocity_scene_quadratic_cost test_velocity_scene_quadratic_cost.cpp ../suite.cpp) -target_link_libraries(test_velocity_scene_quadratic_cost - wbc-scenes-velocity_qp - wbc-robot_models-rbdl - wbc-solvers-qpoases - Boost::unit_test_framework) - -add_executable(test_acceleration_scene test_acceleration_scene.cpp ../suite.cpp) -target_link_libraries(test_acceleration_scene - wbc-scenes-acceleration - wbc-robot_models-rbdl - wbc-solvers-qpoases - Boost::unit_test_framework) - -add_executable(test_acceleration_scene_tsid test_acceleration_scene_tsid.cpp ../suite.cpp) -target_link_libraries(test_acceleration_scene_tsid - wbc-scenes-acceleration_tsid - wbc-robot_models-rbdl - wbc-solvers-qpoases - Boost::unit_test_framework) - -add_executable(test_acceleration_scene_reduced_tsid test_acceleration_scene_reduced_tsid.cpp ../suite.cpp) -target_link_libraries(test_acceleration_scene_reduced_tsid - wbc-scenes-acceleration_reduced_tsid - wbc-robot_models-rbdl - wbc-solvers-qpoases - Boost::unit_test_framework) - - diff --git a/test/solvers/CMakeLists.txt b/test/solvers/CMakeLists.txt deleted file mode 100644 index ed1e1b0a..00000000 --- a/test/solvers/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -add_subdirectory(hls) -add_subdirectory(qpoases) -if(USE_EIQUADPROG) - add_subdirectory(eiquadprog) -endif() -if(USE_QPSWIFT) - add_subdirectory(qpswift) -endif() -if(USE_PROXQP) - add_subdirectory(proxqp) -endif() diff --git a/test/solvers/hls/CMakeLists.txt b/test/solvers/hls/CMakeLists.txt deleted file mode 100644 index 895bef02..00000000 --- a/test/solvers/hls/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -add_executable(test_hls_solver test_hls_solver.cpp ../../suite.cpp) -target_link_libraries(test_hls_solver - wbc-solvers-hls - Boost::unit_test_framework) diff --git a/test/solvers/proxqp/CMakeLists.txt b/test/solvers/proxqp/CMakeLists.txt deleted file mode 100644 index bf7cda73..00000000 --- a/test/solvers/proxqp/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -add_executable(test_proxqp_solver test_proxqp_solver.cpp ../../suite.cpp) -target_link_libraries(test_proxqp_solver - wbc-solvers-proxqp - ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) diff --git a/test/solvers/qpoases/CMakeLists.txt b/test/solvers/qpoases/CMakeLists.txt deleted file mode 100644 index 915a172c..00000000 --- a/test/solvers/qpoases/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -add_executable(test_qpoases_solver test_qpoases_solver.cpp ../../suite.cpp) -target_link_libraries(test_qpoases_solver - wbc-solvers-qpoases - Boost::unit_test_framework) diff --git a/test/solvers/qpswift/CMakeLists.txt b/test/solvers/qpswift/CMakeLists.txt deleted file mode 100644 index a5038a54..00000000 --- a/test/solvers/qpswift/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -add_executable(test_qpswift_solver test_qpswift_solver.cpp ../../suite.cpp) -target_link_libraries(test_qpswift_solver - wbc-solvers-qpswift - Boost::unit_test_framework) diff --git a/test/suite.cpp b/test/suite.cpp deleted file mode 100644 index 0b47303b..00000000 --- a/test/suite.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#define BOOST_TEST_DYN_LINK -#define BOOST_TEST_MAIN -#include diff --git a/tutorials/rh5/CMakeLists.txt b/tutorials/rh5/CMakeLists.txt index 6880d4d7..0a8cc810 100644 --- a/tutorials/rh5/CMakeLists.txt +++ b/tutorials/rh5/CMakeLists.txt @@ -12,7 +12,7 @@ target_link_libraries(rh5_legs_floating_base wbc-controllers wbc-robot_models-rbdl) -if(USE_HYRODYN) +if(ROBOT_MODEL_HYRODYN) add_executable(rh5_single_leg_hybrid rh5_single_leg_hybrid.cpp) target_link_libraries(rh5_single_leg_hybrid wbc-solvers-qpoases diff --git a/tutorials/rh5v2/CMakeLists.txt b/tutorials/rh5v2/CMakeLists.txt index 167ef654..710d386a 100644 --- a/tutorials/rh5v2/CMakeLists.txt +++ b/tutorials/rh5v2/CMakeLists.txt @@ -5,7 +5,7 @@ target_link_libraries(rh5v2 wbc-controllers wbc-robot_models-rbdl) -if(USE_HYRODYN) +if(ROBOT_MODEL_HYRODYN) add_executable(rh5v2_hybrid rh5v2_hybrid.cpp) target_link_libraries(rh5v2_hybrid wbc-solvers-qpoases