From 25d54a293af8dead9ff7a6360fd0dea33e963519 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Wed, 18 Oct 2023 16:27:59 +0200 Subject: [PATCH 1/5] Make Biclops 3rdparty usage private - BICLOPS_INCLUDE_DIRS and BICLOPS_LIBRARIES are no more exported - vpRobotBiclopsController class is now private --- cmake/FindBICLOPS.cmake | 80 +++++++++---------- example/CMakeLists.txt | 2 +- example/servo-biclops/CMakeLists.txt | 2 +- modules/robot/CMakeLists.txt | 11 ++- .../include/visp3/robot/vpRobotBiclops.h | 4 +- .../vpRobotBiclopsController_impl.cpp} | 25 +++--- .../private/vpRobotBiclopsController_impl.h} | 2 +- .../src/real-robot/biclops/vpRobotBiclops.cpp | 70 ++++++++-------- 8 files changed, 101 insertions(+), 95 deletions(-) rename modules/robot/src/real-robot/biclops/{vpRobotBiclopsController.cpp => private/vpRobotBiclopsController_impl.cpp} (92%) rename modules/robot/{include/visp3/robot/vpRobotBiclopsController.h => src/real-robot/biclops/private/vpRobotBiclopsController_impl.h} (99%) diff --git a/cmake/FindBICLOPS.cmake b/cmake/FindBICLOPS.cmake index 31e0f5da60..537f7a3d49 100644 --- a/cmake/FindBICLOPS.cmake +++ b/cmake/FindBICLOPS.cmake @@ -39,35 +39,35 @@ ############################################################################# -IF(NOT UNIX AND NOT WIN32) - # MESSAGE("FindBICLOPS.cmake: macro only for Unix and Windows for the moment.") - SET(BICLOPS_FOUND FALSE) -ELSE(NOT UNIX AND NOT WIN32) +if(NOT UNIX AND NOT WIN32) + # message("FindBICLOPS.cmake: macro only for Unix and Windows for the moment.") + set(BICLOPS_FOUND FALSE) +else(NOT UNIX AND NOT WIN32) - FIND_PATH(BICLOPS_INCLUDE_DIR Biclops.h + find_path(BICLOPS_INCLUDE_DIR Biclops.h $ENV{BICLOPS_HOME}/include /usr/include ) - #MESSAGE("DBG BICLOPS_INCLUDE_DIR=${BICLOPS_INCLUDE_DIR}") + #message("DBG BICLOPS_INCLUDE_DIR=${BICLOPS_INCLUDE_DIR}") - FIND_PATH(PMD_INCLUDE_DIR PMD.h + find_path(PMD_INCLUDE_DIR PMD.h $ENV{BICLOPS_HOME}/include $ENV{BICLOPS_PMD_HOME}/include /usr/include ) - FIND_PATH(UTILS_INCLUDE_DIR utility.h + find_path(UTILS_INCLUDE_DIR utility.h $ENV{BICLOPS_HOME}/include $ENV{BICLOPS_UTILS_HOME}/include /usr/include ) - FIND_LIBRARY(BICLOPS_LIBRARY + find_library(BICLOPS_LIBRARY NAMES Biclops libBiclops libBiclopsD PATHS $ENV{BICLOPS_HOME}/lib /usr/lib ) - FIND_LIBRARY(PMD_LIBRARY + find_library(PMD_LIBRARY NAMES PMD libPMD libPMDD PATHS $ENV{BICLOPS_HOME}/lib @@ -75,49 +75,49 @@ ELSE(NOT UNIX AND NOT WIN32) /usr/lib ) - FIND_LIBRARY(UTILS_LIBRARY + find_library(UTILS_LIBRARY NAMES Utils libUtils libUtilsD PATHS $ENV{BICLOPS_HOME}/lib $ENV{BICLOPS_UTILS_HOME}/lib /usr/lib ) - #MESSAGE("DBG BICLOPS_LIBRARY=${BICLOPS_LIBRARY}") + #message("DBG BICLOPS_LIBRARY=${BICLOPS_LIBRARY}") ## -------------------------------- - IF(BICLOPS_LIBRARY AND PMD_LIBRARY AND UTILS_LIBRARY) - SET(BICLOPS_LIBRARIES ${BICLOPS_LIBRARY} ${PMD_LIBRARY} ${UTILS_LIBRARY}) - ELSE(BICLOPS_LIBRARY AND PMD_LIBRARY AND UTILS_LIBRARY) -# MESSAGE(SEND_ERROR "Biclops library not found. Set USE_BICLOPS option OFF") - ENDIF(BICLOPS_LIBRARY AND PMD_LIBRARY AND UTILS_LIBRARY) + if(BICLOPS_LIBRARY AND PMD_LIBRARY AND UTILS_LIBRARY) + set(BICLOPS_LIBRARIES ${BICLOPS_LIBRARY} ${PMD_LIBRARY} ${UTILS_LIBRARY}) + else(BICLOPS_LIBRARY AND PMD_LIBRARY AND UTILS_LIBRARY) +# message(SEND_ERROR "Biclops library not found. Set USE_BICLOPS option OFF") + endif(BICLOPS_LIBRARY AND PMD_LIBRARY AND UTILS_LIBRARY) - IF(NOT BICLOPS_INCLUDE_DIR) -# MESSAGE(SEND_ERROR "Biclops include dir not found. Set USE_BICLOPS option OFF") - ENDIF(NOT BICLOPS_INCLUDE_DIR) + if(NOT BICLOPS_INCLUDE_DIR) +# message(SEND_ERROR "Biclops include dir not found. Set USE_BICLOPS option OFF") + endif(NOT BICLOPS_INCLUDE_DIR) - IF(NOT PMD_INCLUDE_DIR) -# MESSAGE(SEND_ERROR "PMD include dir not found. Set USE_BICLOPS option OFF") - ENDIF(NOT PMD_INCLUDE_DIR) + if(NOT PMD_INCLUDE_DIR) +# message(SEND_ERROR "PMD include dir not found. Set USE_BICLOPS option OFF") + endif(NOT PMD_INCLUDE_DIR) - IF(NOT UTILS_INCLUDE_DIR) -# MESSAGE(SEND_ERROR "Utils include dir not found. Set USE_BICLOPS option OFF ") - ENDIF(NOT UTILS_INCLUDE_DIR) + if(NOT UTILS_INCLUDE_DIR) +# message(SEND_ERROR "Utils include dir not found. Set USE_BICLOPS option OFF ") + endif(NOT UTILS_INCLUDE_DIR) - IF(BICLOPS_INCLUDE_DIR AND PMD_INCLUDE_DIR AND UTILS_INCLUDE_DIR) - SET(BICLOPS_INCLUDE_DIRS ${BICLOPS_INCLUDE_DIR} ${PMD_INCLUDE_DIR} ${UTILS_INCLUDE_DIR}) - ENDIF(BICLOPS_INCLUDE_DIR AND PMD_INCLUDE_DIR AND UTILS_INCLUDE_DIR) + if(BICLOPS_INCLUDE_DIR AND PMD_INCLUDE_DIR AND UTILS_INCLUDE_DIR) + set(BICLOPS_INCLUDE_DIRS ${BICLOPS_INCLUDE_DIR} ${PMD_INCLUDE_DIR} ${UTILS_INCLUDE_DIR}) + endif(BICLOPS_INCLUDE_DIR AND PMD_INCLUDE_DIR AND UTILS_INCLUDE_DIR) - IF(BICLOPS_LIBRARIES AND BICLOPS_INCLUDE_DIR AND PMD_INCLUDE_DIR AND UTILS_INCLUDE_DIR) + if(BICLOPS_LIBRARIES AND BICLOPS_INCLUDE_DIR AND PMD_INCLUDE_DIR AND UTILS_INCLUDE_DIR) #message("BICLOPS_LIBRARIES: ${BICLOPS_LIBRARIES}") #message("BICLOPS_INCLUDE_DIRS: ${BICLOPS_INCLUDE_DIRS}") # Try to compile a sample code using Biclops library to see if GetHomedState() is available - #SET(BICLOPS_HAVE_GET_HOMED_STATE_FUNCTION FALSE) + #set(BICLOPS_HAVE_GET_HOMED_STATE_FUNCTION FALSE) include(CheckCXXSourceCompiles) - SET(CMAKE_REQUIRED_LIBRARIES ${BICLOPS_LIBRARIES}) - SET(CMAKE_REQUIRED_INCLUDES ${BICLOPS_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES ${BICLOPS_LIBRARIES}) + set(CMAKE_REQUIRED_INCLUDES ${BICLOPS_INCLUDE_DIRS}) CHECK_CXX_SOURCE_COMPILES(" #include int main(){ @@ -127,14 +127,14 @@ ELSE(NOT UNIX AND NOT WIN32) } " BICLOPS_HAVE_GET_HOMED_STATE_FUNCTION) - #MESSAGE("DBG1 BICLOPS_HAVE_GET_HOMED_STATE_FUNCTION ${BICLOPS_HAVE_GET_HOMED_STATE_FUNCTION}") + #message("DBG1 BICLOPS_HAVE_GET_HOMED_STATE_FUNCTION ${BICLOPS_HAVE_GET_HOMED_STATE_FUNCTION}") - SET(BICLOPS_FOUND TRUE) - ELSE(BICLOPS_LIBRARIES AND BICLOPS_INCLUDE_DIR AND PMD_INCLUDE_DIR AND UTILS_INCLUDE_DIR) - SET(BICLOPS_FOUND FALSE) - ENDIF(BICLOPS_LIBRARIES AND BICLOPS_INCLUDE_DIR AND PMD_INCLUDE_DIR AND UTILS_INCLUDE_DIR) + set(BICLOPS_FOUND TRUE) + else(BICLOPS_LIBRARIES AND BICLOPS_INCLUDE_DIR AND PMD_INCLUDE_DIR AND UTILS_INCLUDE_DIR) + set(BICLOPS_FOUND FALSE) + endif(BICLOPS_LIBRARIES AND BICLOPS_INCLUDE_DIR AND PMD_INCLUDE_DIR AND UTILS_INCLUDE_DIR) - MARK_AS_ADVANCED( + mark_as_advanced( BICLOPS_INCLUDE_DIR BICLOPS_LIBRARIES BICLOPS_LIBRARY @@ -143,4 +143,4 @@ ELSE(NOT UNIX AND NOT WIN32) PMD_LIBRARY UTILS_LIBRARY ) -ENDIF(NOT UNIX AND NOT WIN32) +endif(NOT UNIX AND NOT WIN32) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 55cf447f77..a81238aeb1 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -85,7 +85,7 @@ visp_add_subdirectory(robot-simulator/camera REQUIRED_DEPS visp_core visp_vs v visp_add_subdirectory(robot-simulator/viper850 REQUIRED_DEPS visp_core visp_vs visp_robot visp_io visp_gui) visp_add_subdirectory(servo-afma4 REQUIRED_DEPS visp_core visp_blob visp_vs visp_robot visp_sensor visp_gui) visp_add_subdirectory(servo-afma6 REQUIRED_DEPS visp_core visp_blob visp_vs visp_robot visp_sensor visp_vision visp_gui) -visp_add_subdirectory(servo-biclops REQUIRED_DEPS visp_core visp_blob visp_vs visp_robot visp_sensor visp_gui) +visp_add_subdirectory(servo-biclops REQUIRED_DEPS visp_core visp_detection visp_vs visp_robot visp_sensor visp_gui) visp_add_subdirectory(servo-bebop2 REQUIRED_DEPS visp_core visp_vs visp_robot visp_gui visp_detection) visp_add_subdirectory(servo-flir-ptu REQUIRED_DEPS visp_core visp_robot visp_vision visp_gui visp_vs visp_visual_features visp_detection visp_sensor) visp_add_subdirectory(servo-franka REQUIRED_DEPS visp_core visp_robot visp_vision visp_io visp_gui visp_vs visp_visual_features visp_detection) diff --git a/example/servo-biclops/CMakeLists.txt b/example/servo-biclops/CMakeLists.txt index 5aeff5de0b..e3a22ceb6a 100644 --- a/example/servo-biclops/CMakeLists.txt +++ b/example/servo-biclops/CMakeLists.txt @@ -37,7 +37,7 @@ cmake_minimum_required(VERSION 3.5) project(example-servo-biclops) -find_package(VISP REQUIRED visp_core visp_blob visp_vs visp_robot visp_sensor visp_gui) +find_package(VISP REQUIRED visp_core visp_detection visp_vs visp_robot visp_sensor visp_gui) set(example_cpp moveBiclops.cpp diff --git a/modules/robot/CMakeLists.txt b/modules/robot/CMakeLists.txt index d402d398bd..1704f070fc 100644 --- a/modules/robot/CMakeLists.txt +++ b/modules/robot/CMakeLists.txt @@ -101,8 +101,8 @@ if(USE_MAVSDK) endif() if(USE_BICLOPS) - list(APPEND opt_incs ${BICLOPS_INCLUDE_DIRS}) - list(APPEND opt_libs ${BICLOPS_LIBRARIES}) + # No need to export, there is an implementation that allows to use Biclops as private + include_directories(${BICLOPS_INCLUDE_DIRS}) endif() if(USE_PTU46) @@ -181,7 +181,7 @@ if(WITH_TAKKTILE2) include_directories(${TAKKTILE2_INCLUDE_DIRS}) endif() -vp_add_module(robot visp_core OPTIONAL visp_io visp_gui visp_sensor PRIVATE_OPTIONAL ${QBDEVICE_LIBRARIES} ${TAKKTILE2_LIBRARIES}) +vp_add_module(robot visp_core OPTIONAL visp_io visp_gui visp_sensor PRIVATE_OPTIONAL ${QBDEVICE_LIBRARIES} ${TAKKTILE2_LIBRARIES} ${BICLOPS_LIBRARIES}) vp_glob_module_sources() vp_set_source_file_compile_flag(src/wireframe-simulator/vpKeyword.cpp -Wno-sign-conversion) @@ -222,6 +222,11 @@ if(USE_MAVSDK) vp_set_source_file_compile_flag(src/real-robot/mavsdk/vpRobotMavsdk.cp -Wno-unused-but-set-variable) endif() +if(USE_BICLOPS) + vp_set_source_file_compile_flag(src/real-robot/biclops/vpRobotBiclops.cpp -Wno-unused-parameter) + vp_set_source_file_compile_flag(src/real-robot/biclops/private/vpRobotBiclopsController_impl.cpp -Wno-unused-parameter) +endif() + vp_set_source_file_compile_flag(src/light/vpRingLight.cpp -Wno-strict-overflow) vp_set_source_file_compile_flag(src/wireframe-simulator/vpClipping.cpp -Wno-strict-overflow) vp_set_source_file_compile_flag(src/wireframe-simulator/vpBoundio.cpp -Wno-strict-overflow) diff --git a/modules/robot/include/visp3/robot/vpRobotBiclops.h b/modules/robot/include/visp3/robot/vpRobotBiclops.h index 900e7e4f5d..44aba86a72 100644 --- a/modules/robot/include/visp3/robot/vpRobotBiclops.h +++ b/modules/robot/include/visp3/robot/vpRobotBiclops.h @@ -52,7 +52,6 @@ #include #include #include -#include /* ------------------------------------------------------------------------ */ /* --- CLASS -------------------------------------------------------------- */ @@ -418,7 +417,8 @@ class VISP_EXPORT vpRobotBiclops : public vpBiclops, public vpRobot std::string m_configfile; // Biclops config file - vpRobotBiclopsController m_controller; + class vpRobotBiclopsController; + vpRobotBiclopsController *m_controller; double m_positioningVelocity; vpColVector m_q_previous; diff --git a/modules/robot/src/real-robot/biclops/vpRobotBiclopsController.cpp b/modules/robot/src/real-robot/biclops/private/vpRobotBiclopsController_impl.cpp similarity index 92% rename from modules/robot/src/real-robot/biclops/vpRobotBiclopsController.cpp rename to modules/robot/src/real-robot/biclops/private/vpRobotBiclopsController_impl.cpp index 845ddeb8e5..957f688d08 100644 --- a/modules/robot/src/real-robot/biclops/vpRobotBiclopsController.cpp +++ b/modules/robot/src/real-robot/biclops/private/vpRobotBiclopsController_impl.cpp @@ -43,15 +43,16 @@ /* Headers */ #include -#include #include +#include "vpRobotBiclopsController_impl.h" + //#define VP_DEBUG // Activate the debug mode //#define VP_DEBUG_MODE 20 // Activate debug level 1 and 2 #include -vpRobotBiclopsController::vpRobotBiclopsController() +vpRobotBiclops::vpRobotBiclopsController::vpRobotBiclopsController() : m_biclops(), m_axisMask(0), m_panAxis(NULL), m_tiltAxis(NULL), m_vergeAxis(NULL), m_panProfile(), m_tiltProfile(), m_vergeProfile(), m_shm(), m_stopControllerThread(false) { @@ -72,9 +73,9 @@ vpRobotBiclopsController::vpRobotBiclopsController() } } -vpRobotBiclopsController::~vpRobotBiclopsController() { } +vpRobotBiclops::vpRobotBiclopsController::~vpRobotBiclopsController() { } -void vpRobotBiclopsController::init(const std::string &configfile) +void vpRobotBiclops::vpRobotBiclopsController::init(const std::string &configfile) { vpDEBUG_TRACE(12, "Initialize Biclops."); bool binit = false; @@ -143,7 +144,7 @@ void vpRobotBiclopsController::init(const std::string &configfile) m_vergeAxis->GetProfile(m_vergeProfile); } -void vpRobotBiclopsController::setPosition(const vpColVector &q, double percentVelocity) +void vpRobotBiclops::vpRobotBiclopsController::setPosition(const vpColVector &q, double percentVelocity) { if (q.getRows() != vpBiclops::ndof) { vpERROR_TRACE("Bad dimension for positioning vector."); @@ -213,7 +214,7 @@ void vpRobotBiclopsController::setPosition(const vpColVector &q, double percentV m_biclops.Move(Biclops::PanMask + Biclops::TiltMask /*, 0*/); // } -void vpRobotBiclopsController::setVelocity(const vpColVector &q_dot) +void vpRobotBiclops::vpRobotBiclopsController::setVelocity(const vpColVector &q_dot) { if (q_dot.getRows() != vpBiclops::ndof) { vpERROR_TRACE("Bad dimension for velocity vector."); @@ -264,7 +265,7 @@ void vpRobotBiclopsController::setVelocity(const vpColVector &q_dot) m_biclops.Move(Biclops::PanMask + Biclops::TiltMask, 0); // } -vpColVector vpRobotBiclopsController::getPosition() +vpColVector vpRobotBiclops::vpRobotBiclopsController::getPosition() { vpDEBUG_TRACE(12, "Start vpRobotBiclopsController::getPosition() "); vpColVector q(vpBiclops::ndof); @@ -282,7 +283,7 @@ vpColVector vpRobotBiclopsController::getPosition() return q; } -vpColVector vpRobotBiclopsController::getActualPosition() +vpColVector vpRobotBiclops::vpRobotBiclopsController::getActualPosition() { vpColVector q(vpBiclops::ndof); PMDint32 panpos, tiltpos; @@ -296,7 +297,7 @@ vpColVector vpRobotBiclopsController::getActualPosition() return q; } -vpColVector vpRobotBiclopsController::getVelocity() +vpColVector vpRobotBiclops::vpRobotBiclopsController::getVelocity() { vpColVector q_dot(vpBiclops::ndof); PMDint32 pan_vel, tilt_vel; @@ -310,7 +311,7 @@ vpColVector vpRobotBiclopsController::getVelocity() return q_dot; } -vpColVector vpRobotBiclopsController::getActualVelocity() +vpColVector vpRobotBiclops::vpRobotBiclopsController::getActualVelocity() { vpColVector q_dot(vpBiclops::ndof); PMDint32 pan_vel, tilt_vel; @@ -324,7 +325,7 @@ vpColVector vpRobotBiclopsController::getActualVelocity() return q_dot; } -void vpRobotBiclopsController::writeShm(shmType &shm) +void vpRobotBiclops::vpRobotBiclopsController::writeShm(shmType &shm) { for (unsigned int i = 0; i < vpBiclops::ndof; i++) { vpDEBUG_TRACE(13, "q_dot[%d]=%f", i, m_shm.q_dot[i]); @@ -335,7 +336,7 @@ void vpRobotBiclopsController::writeShm(shmType &shm) } } -vpRobotBiclopsController::shmType vpRobotBiclopsController::readShm() +vpRobotBiclops::vpRobotBiclopsController::shmType vpRobotBiclops::vpRobotBiclopsController::readShm() { shmType tmp_shm; diff --git a/modules/robot/include/visp3/robot/vpRobotBiclopsController.h b/modules/robot/src/real-robot/biclops/private/vpRobotBiclopsController_impl.h similarity index 99% rename from modules/robot/include/visp3/robot/vpRobotBiclopsController.h rename to modules/robot/src/real-robot/biclops/private/vpRobotBiclopsController_impl.h index c2f9627fe3..e44bf2296e 100644 --- a/modules/robot/include/visp3/robot/vpRobotBiclopsController.h +++ b/modules/robot/src/real-robot/biclops/private/vpRobotBiclopsController_impl.h @@ -66,7 +66,7 @@ class VISP_EXPORT Biclops; // needed for dll creation * This class uses libraries libBiclops.so, libUtils.so and libPMD.so and * includes Biclops.h and PMDUtils.h provided by Traclabs. */ -class VISP_EXPORT vpRobotBiclopsController +class VISP_EXPORT vpRobotBiclops::vpRobotBiclopsController { public: /*! diff --git a/modules/robot/src/real-robot/biclops/vpRobotBiclops.cpp b/modules/robot/src/real-robot/biclops/vpRobotBiclops.cpp index 8edb4956da..68b6aa2ff2 100644 --- a/modules/robot/src/real-robot/biclops/vpRobotBiclops.cpp +++ b/modules/robot/src/real-robot/biclops/vpRobotBiclops.cpp @@ -49,6 +49,8 @@ #include #include +#include "private/vpRobotBiclopsController_impl.h" + //#define VP_DEBUG // Activate the debug mode //#define VP_DEBUG_MODE 10 // Activate debug level 1 and 2 #include @@ -68,30 +70,29 @@ static std::mutex m_mutex_measure; /* ---------------------------------------------------------------------- */ vpRobotBiclops::vpRobotBiclops() - : vpBiclops(), vpRobot(), m_control_thread(), m_controller(), m_positioningVelocity(defaultPositioningVelocity), + : vpBiclops(), vpRobot(), m_control_thread(), m_positioningVelocity(defaultPositioningVelocity), m_q_previous() { vpDEBUG_TRACE(12, "Begin default constructor."); + m_controller = new vpRobotBiclopsController; setConfigFile("/usr/share/BiclopsDefault.cfg"); } vpRobotBiclops::vpRobotBiclops(const std::string &filename) - : vpBiclops(), vpRobot(), m_control_thread(), m_controller(), m_positioningVelocity(defaultPositioningVelocity), + : vpBiclops(), vpRobot(), m_control_thread(), m_positioningVelocity(defaultPositioningVelocity), m_q_previous() { vpDEBUG_TRACE(12, "Begin default constructor."); + m_controller = new vpRobotBiclopsController; setConfigFile(filename); init(); - - return; } vpRobotBiclops::~vpRobotBiclops() { - vpDEBUG_TRACE(12, "Start vpRobotBiclops::~vpRobotBiclops()"); setRobotState(vpRobot::STATE_STOP); @@ -105,8 +106,8 @@ vpRobotBiclops::~vpRobotBiclops() m_control_thread.join(); } + delete m_controller; vpDEBUG_TRACE(12, "Stop vpRobotBiclops::~vpRobotBiclops()"); - return; } void vpRobotBiclops::setConfigFile(const std::string &filename) { m_configfile = filename; } @@ -122,7 +123,7 @@ void vpRobotBiclops::init() fclose(fd); // Initialize the controller - m_controller.init(m_configfile); + m_controller->init(m_configfile); try { setRobotState(vpRobot::STATE_STOP); @@ -141,11 +142,11 @@ void vpRobotBiclops::init() void *vpRobotBiclops::vpRobotBiclopsSpeedControlLoop(void *arg) { - vpRobotBiclopsController *m_controller = static_cast(arg); + vpRobotBiclopsController *controller = static_cast(arg); int iter = 0; - // PMDAxisControl *m_panAxis = m_controller->getPanAxis(); - // PMDAxisControl *m_tiltAxis = m_controller->getTiltAxis(); + // PMDAxisControl *m_panAxis = controller->getPanAxis(); + // PMDAxisControl *m_tiltAxis = controller->getTiltAxis(); vpRobotBiclopsController::shmType shm; vpDEBUG_TRACE(10, "Start control loop"); @@ -169,7 +170,7 @@ void *vpRobotBiclops::vpRobotBiclopsSpeedControlLoop(void *arg) vpDEBUG_TRACE(11, "Lock mutex vpShm_mutex"); m_mutex_shm.lock(); - shm = m_controller->readShm(); + shm = controller->readShm(); vpDEBUG_TRACE(11, "unlock mutex vpShm_mutex"); m_mutex_shm.unlock(); @@ -183,20 +184,20 @@ void *vpRobotBiclops::vpRobotBiclopsSpeedControlLoop(void *arg) } // Initialize actual position and velocity - mes_q = m_controller->getActualPosition(); - mes_q_dot = m_controller->getActualVelocity(); + mes_q = controller->getActualPosition(); + mes_q_dot = controller->getActualVelocity(); vpDEBUG_TRACE(11, "Lock mutex vpShm_mutex"); m_mutex_shm.lock(); - shm = m_controller->readShm(); + shm = controller->readShm(); // Updates the shm for (unsigned int i = 0; i < vpBiclops::ndof; i++) { shm.actual_q[i] = mes_q[i]; shm.actual_q_dot[i] = mes_q_dot[i]; } // Update current positions - m_controller->writeShm(shm); + controller->writeShm(shm); vpDEBUG_TRACE(11, "unlock mutex vpShm_mutex"); m_mutex_shm.unlock(); @@ -204,16 +205,16 @@ void *vpRobotBiclops::vpRobotBiclopsSpeedControlLoop(void *arg) vpDEBUG_TRACE(11, "unlock mutex vpMeasure_mutex"); m_mutex_measure.unlock(); // A position is available - while (!m_controller->isStopRequested()) { + while (!controller->isStopRequested()) { // Get actual position and velocity - mes_q = m_controller->getActualPosition(); - mes_q_dot = m_controller->getActualVelocity(); + mes_q = controller->getActualPosition(); + mes_q_dot = controller->getActualVelocity(); vpDEBUG_TRACE(11, "Lock mutex vpShm_mutex"); m_mutex_shm.lock(); - shm = m_controller->readShm(); + shm = controller->readShm(); // Updates the shm for (unsigned int i = 0; i < vpBiclops::ndof; i++) { @@ -317,7 +318,7 @@ void *vpRobotBiclops::vpRobotBiclopsSpeedControlLoop(void *arg) else { // Axis not in joint limit - // Update the desired speed + // Update the desired speed q_dot[i] = shm.q_dot[i]; shm.status[i] = vpRobotBiclopsController::SPEED; enable_limit[i] = true; // Joint limit detection must be active @@ -346,7 +347,7 @@ void *vpRobotBiclops::vpRobotBiclopsSpeedControlLoop(void *arg) } } // Update the actual positions - m_controller->writeShm(shm); + controller->writeShm(shm); vpDEBUG_TRACE(11, "unlock mutex vpShm_mutex"); m_mutex_shm.unlock(); @@ -355,7 +356,7 @@ void *vpRobotBiclops::vpRobotBiclopsSpeedControlLoop(void *arg) vpDEBUG_TRACE(12, "apply q_dot : %f %f", vpMath::deg(q_dot[0]), vpMath::deg(q_dot[1])); // Apply the velocity - m_controller->setVelocity(q_dot); + controller->setVelocity(q_dot); } // Update the previous speed for next iteration @@ -369,11 +370,11 @@ void *vpRobotBiclops::vpRobotBiclopsSpeedControlLoop(void *arg) iter++; } - m_controller->stopRequest(false); + controller->stopRequest(false); // Stop the robot vpDEBUG_TRACE(10, "End of the control thread: stop the robot"); q_dot = 0; - m_controller->setVelocity(q_dot); + controller->setVelocity(q_dot); delete[] new_q_dot; delete[] change_dir; @@ -427,10 +428,9 @@ void vpRobotBiclops::stopMotion(void) { vpColVector q_dot(vpBiclops::ndof); q_dot = 0; - m_controller.setVelocity(q_dot); - // std::cout << "Request to stop the velocity controller thread...."<< - // std::endl; - m_controller.stopRequest(true); + m_controller->setVelocity(q_dot); + // std::cout << "Request to stop the velocity controller thread...." << std::endl; + m_controller->stopRequest(true); } void vpRobotBiclops::get_cVe(vpVelocityTwistMatrix &cVe) const @@ -503,7 +503,7 @@ void vpRobotBiclops::setPosition(const vpRobot::vpControlFrameType frame, const vpDEBUG_TRACE(12, "Lock mutex vpEndThread_mutex"); m_mutex_end_thread.lock(); - m_controller.setPosition(q, m_positioningVelocity); + m_controller->setPosition(q, m_positioningVelocity); vpDEBUG_TRACE(12, "Unlock mutex vpEndThread_mutex"); m_mutex_end_thread.unlock(); return; @@ -563,7 +563,7 @@ void vpRobotBiclops::getPosition(const vpRobot::vpControlFrameType frame, vpColV switch (state) { case STATE_STOP: case STATE_POSITION_CONTROL: - q = m_controller.getPosition(); + q = m_controller->getPosition(); break; case STATE_VELOCITY_CONTROL: @@ -579,7 +579,7 @@ void vpRobotBiclops::getPosition(const vpRobot::vpControlFrameType frame, vpColV vpDEBUG_TRACE(12, "Lock mutex vpShm_mutex"); m_mutex_shm.lock(); - shm = m_controller.readShm(); + shm = m_controller->readShm(); vpDEBUG_TRACE(12, "unlock mutex vpShm_mutex"); m_mutex_shm.unlock(); @@ -673,12 +673,12 @@ void vpRobotBiclops::setVelocity(const vpRobot::vpControlFrameType frame, const vpDEBUG_TRACE(12, "Lock mutex vpShm_mutex"); m_mutex_shm.lock(); - shm = m_controller.readShm(); + shm = m_controller->readShm(); for (unsigned int i = 0; i < vpBiclops::ndof; i++) shm.q_dot[i] = q_dot[i]; - m_controller.writeShm(shm); + m_controller->writeShm(shm); vpDEBUG_TRACE(12, "unlock mutex vpShm_mutex"); m_mutex_shm.unlock(); @@ -715,7 +715,7 @@ void vpRobotBiclops::getVelocity(const vpRobot::vpControlFrameType frame, vpColV switch (state) { case STATE_STOP: case STATE_POSITION_CONTROL: - q_dot = m_controller.getVelocity(); + q_dot = m_controller->getVelocity(); break; case STATE_VELOCITY_CONTROL: @@ -731,7 +731,7 @@ void vpRobotBiclops::getVelocity(const vpRobot::vpControlFrameType frame, vpColV vpDEBUG_TRACE(12, "Lock mutex vpShm_mutex"); m_mutex_shm.lock(); - shm = m_controller.readShm(); + shm = m_controller->readShm(); vpDEBUG_TRACE(12, "unlock mutex vpShm_mutex"); m_mutex_shm.unlock(); From 8abdbfe486e138fac6b2844ce213d198bfd2d7dd Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Wed, 18 Oct 2023 20:21:44 +0200 Subject: [PATCH 2/5] Make gtk-2, X11, libjpeg and libpng private - allow to not export include dirs and librairies --- doc/tutorial/unix/tutorial-install-fedora.dox | 9 + .../unix/tutorial-install-osx-homebrew.dox | 15 ++ doc/tutorial/unix/tutorial-install-ubuntu.dox | 12 +- modules/gui/CMakeLists.txt | 19 +- modules/gui/include/visp3/gui/vpDisplayGTK.h | 172 +++++++++--------- modules/gui/include/visp3/gui/vpDisplayX.h | 164 +++++++++-------- modules/io/CMakeLists.txt | 13 +- 7 files changed, 214 insertions(+), 190 deletions(-) diff --git a/doc/tutorial/unix/tutorial-install-fedora.dox b/doc/tutorial/unix/tutorial-install-fedora.dox index 8cef5ec3ac..c82b87d370 100644 --- a/doc/tutorial/unix/tutorial-install-fedora.dox +++ b/doc/tutorial/unix/tutorial-install-fedora.dox @@ -110,6 +110,15 @@ $ sudo dnf install libdmtx-devel \verbatim $ sudo dnf install gsl-devel \endverbatim +- Gtk-2 for gui capabilities instead of X11 +\verbatim +$ sudo dnf install gtk2-devel glib2-devel pango-devel atk-devel cairo-devel +\endverbatim +After installing the gtk packages, you need to explicitly enable gtk usage during ViSP cmake configuration step by: +\verbatim +$ cd $VISP_WS/visp-build +$ cmake ../visp -DUSE_GTK=ON +\endverbatim \subsection install_fedora_get_source Get ViSP source code diff --git a/doc/tutorial/unix/tutorial-install-osx-homebrew.dox b/doc/tutorial/unix/tutorial-install-osx-homebrew.dox index 12f829da55..c6bb49a62e 100644 --- a/doc/tutorial/unix/tutorial-install-osx-homebrew.dox +++ b/doc/tutorial/unix/tutorial-install-osx-homebrew.dox @@ -250,6 +250,21 @@ dyld[33644]: Library not loaded: /System/Library/Frameworks/Python.framework/Ver To overcome this error, download and install the latest Python 2 for macOS from [offical site](https://www.python.org/downloads/macos/). +\subsubsection install_brew_3rdparty_other Other optional 3rd parties + +We give also the way to install other 3rd party libraries to enable specific capabilities. + +- Gtk-2 for gui capabilities instead of X11 +\verbatim +$ brew install gtk +\endverbatim +After installing the gtk packages, you need to explicitly enable gtk usage during ViSP cmake configuration step by: +\verbatim +$ cd $VISP_WS/visp-build +$ cmake ../visp -DUSE_GTK=ON +\endverbatim + + \subsection install_brew_get_source Get ViSP source code There are different ways to get ViSP source code: diff --git a/doc/tutorial/unix/tutorial-install-ubuntu.dox b/doc/tutorial/unix/tutorial-install-ubuntu.dox index 7235cdbe60..5a83412844 100644 --- a/doc/tutorial/unix/tutorial-install-ubuntu.dox +++ b/doc/tutorial/unix/tutorial-install-ubuntu.dox @@ -31,7 +31,8 @@ $ mkdir -p $VISP_WS \section install_ubuntu_quick Quick ViSP installation -In this section, we give minimal instructions to build ViSP from source just to try ViSP without entering in \ref install_ubuntu_advanced. +In this section, we give minimal instructions to build ViSP from source just to try ViSP without entering in +\ref install_ubuntu_advanced. - Install a small number of recommended 3rd parties @@ -448,6 +449,15 @@ $ sudo apt-get install libgsl-dev \verbatim $ sudo apt-get install nlohmann-json3-dev \endverbatim +- Gtk-2 for gui capabilities instead of X11 +\verbatim +$ sudo apt-get install libgtk2.0-dev libglib2.0-dev libpango1.0-dev libatk1.0-dev libcairo2-dev +\endverbatim +After installing the gtk packages, you need to explicitly enable gtk usage during ViSP cmake configuration step by: +\verbatim +$ cd $VISP_WS/visp-build +$ cmake ../visp -DUSE_GTK=ON +\endverbatim \subsection install_ubuntu_visp_get_source Get ViSP source code diff --git a/modules/gui/CMakeLists.txt b/modules/gui/CMakeLists.txt index 85483a04b5..729f6ec155 100644 --- a/modules/gui/CMakeLists.txt +++ b/modules/gui/CMakeLists.txt @@ -39,28 +39,27 @@ set(opt_libs "") # Display X11, GTK, GDI, D3D9. OpenCV already handled by core module if(USE_X11) - list(APPEND opt_incs ${X11_INCLUDE_DIR}) - list(APPEND opt_libs ${X11_LIBRARIES}) + # X11 is private + include_directories(${X11_INCLUDE_DIR}) mark_as_advanced(X11_xcb_icccm_INCLUDE_PATH) mark_as_advanced(X11_xcb_icccm_LIB) mark_as_advanced(X11_xcb_xkb_INCLUDE_PATH) endif() + if(USE_GTK2) - list(APPEND opt_incs ${GTK2_INCLUDE_DIRS}) - list(APPEND opt_libs ${GTK2_LIBRARIES}) - # FS next lines removed until they proved to be useful -# if(UNIX) -# ## ignore gtk pedantic warnings by gcc specific -isystem : -# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${GTK2_gtk_INCLUDE_PATH}") -# endif() + # gtk2 is private + include_directories(${GTK2_INCLUDE_DIRS}) endif() + if(USE_GDI) list(APPEND opt_libs ${GDI_LIBRARIES}) endif() + if(USE_DIRECT3D) list(APPEND opt_incs ${DIRECT3D_INCLUDE_DIRS}) list(APPEND opt_libs ${DIRECT3D_LIBRARIES}) endif() + if(USE_PCL) list(APPEND opt_incs ${PCL_INCLUDE_DIRS}) @@ -83,7 +82,7 @@ if(USE_PCL) list(APPEND opt_libs ${PCL_DEPS_LIBRARIES}) endif() -vp_add_module(gui visp_core) +vp_add_module(gui visp_core PRIVATE_OPTIONAL ${X11_LIBRARIES} ${GTK2_LIBRARIES}) vp_glob_module_sources() vp_module_include_directories(${opt_incs}) vp_create_module(${opt_libs}) diff --git a/modules/gui/include/visp3/gui/vpDisplayGTK.h b/modules/gui/include/visp3/gui/vpDisplayGTK.h index b0ef9f9e27..b0fcda5406 100644 --- a/modules/gui/include/visp3/gui/vpDisplayGTK.h +++ b/modules/gui/include/visp3/gui/vpDisplayGTK.h @@ -1,5 +1,4 @@ -/**************************************************************************** - * +/* * ViSP, open source Visual Servoing Platform software. * Copyright (C) 2005 - 2023 by Inria. All rights reserved. * @@ -30,11 +29,7 @@ * * Description: * Image display. - * - * Authors: - * Christophe Collewet - * -*****************************************************************************/ + */ #ifndef vpDisplayGTK_h #define vpDisplayGTK_h @@ -46,90 +41,89 @@ #include /*! - \file vpDisplayGTK.h - \brief Define the GTK console to display images. -*/ + * \file vpDisplayGTK.h + * \brief Define the GTK console to display images. + */ /*! - - \class vpDisplayGTK - - \ingroup group_gui_display - - \brief The vpDisplayGTK allows to display image using the GTK 3rd party - library. Thus to enable this class GTK should be installed. Installation - instructions are provided here https://visp.inria.fr/3rd_gtk. - - The example below shows how to display an image with this video device. - \code -#include -#include -#include - -int main() -{ -#if defined(VISP_HAVE_GTK) - vpImage I; // Grey level image - - // Read an image in PGM P5 format -#ifdef _WIN32 - vpImageIo::read(I, "C:/Temp/visp-images/Klimt/Klimt.pgm"); -#else - vpImageIo::read(I, "/local/soft/ViSP/ViSP-images/Klimt/Klimt.pgm"); -#endif - - vpDisplayGTK d; - - // Initialize the display with the image I. Display and image are - // now link together. - d.init(I); - - // Specify the window location - vpDisplay::setWindowPosition(I, 400, 100); - - // Set the display window title - vpDisplay::setTitle(I, "My GTK display"); - - // Set the display background with image I content - vpDisplay::display(I); - - // Draw a red rectangle in the display overlay (foreground) - vpDisplay::displayRectangle(I, 10, 10, 100, 20, vpColor::red, true); - - // Draw a red rectangle in the display overlay (foreground) - vpImagePoint topLeftCorner; - topLeftCorner.set_i(50); - topLeftCorner.set_j(10); - vpDisplay::displayRectangle(I, topLeftCorner, 100, 20, vpColor::green, true); - - // Flush the foreground and background display - vpDisplay::flush(I); - - // Get non blocking keyboard events - std::cout << "Check keyboard events..." << std::endl; - char key[10]; - bool ret; - for (int i=0; i< 200; i++) { - bool ret = vpDisplay::getKeyboardEvent(I, key, false); - if (ret) - std::cout << "keyboard event: key: " << "\"" << key << "\"" << std::endl; - vpTime::wait(40); - } - - // Get a blocking keyboard event - std::cout << "Wait for a keyboard event..." << std::endl; - ret = vpDisplay::getKeyboardEvent(I, key, true); - std::cout << "keyboard event: " << ret << std::endl; - if (ret) - std::cout << "key: " << "\"" << key << "\"" << std::endl; - - // Wait for a click in the display window - std::cout << "Wait for a button click..." << std::endl; - vpDisplay::getClick(I); -#endif -} - \endcode -*/ + * \class vpDisplayGTK + * + * \ingroup group_gui_display + * + * \brief The vpDisplayGTK allows to display image using the GTK 3rd party + * library. Thus to enable this class GTK should be installed. Installation + * instructions are provided here https://visp.inria.fr/3rd_gtk. + * + * The example below shows how to display an image with this video device. + * \code + * #include + * #include + * #include + * + * int main() + * { + * #if defined(VISP_HAVE_GTK) + * vpImage I; // Grey level image + * + * // Read an image in PGM P5 format + * #ifdef _WIN32 + * vpImageIo::read(I, "C:/Temp/visp-images/Klimt/Klimt.pgm"); + * #else + * vpImageIo::read(I, "/local/soft/ViSP/ViSP-images/Klimt/Klimt.pgm"); + * #endif + * + * vpDisplayGTK d; + * + * // Initialize the display with the image I. Display and image are + * // now link together. + * d.init(I); + * + * // Specify the window location + * vpDisplay::setWindowPosition(I, 400, 100); + * + * // Set the display window title + * vpDisplay::setTitle(I, "My GTK display"); + * + * // Set the display background with image I content + * vpDisplay::display(I); + * + * // Draw a red rectangle in the display overlay (foreground) + * vpDisplay::displayRectangle(I, 10, 10, 100, 20, vpColor::red, true); + * + * // Draw a red rectangle in the display overlay (foreground) + * vpImagePoint topLeftCorner; + * topLeftCorner.set_i(50); + * topLeftCorner.set_j(10); + * vpDisplay::displayRectangle(I, topLeftCorner, 100, 20, vpColor::green, true); + * + * // Flush the foreground and background display + * vpDisplay::flush(I); + * + * // Get non blocking keyboard events + * std::cout << "Check keyboard events..." << std::endl; + * char key[10]; + * bool ret; + * for (int i=0; i< 200; i++) { + * bool ret = vpDisplay::getKeyboardEvent(I, key, false); + * if (ret) + * std::cout << "keyboard event: key: " << "\"" << key << "\"" << std::endl; + * vpTime::wait(40); + * } + * + * // Get a blocking keyboard event + * std::cout << "Wait for a keyboard event..." << std::endl; + * ret = vpDisplay::getKeyboardEvent(I, key, true); + * std::cout << "keyboard event: " << ret << std::endl; + * if (ret) + * std::cout << "key: " << "\"" << key << "\"" << std::endl; + * + * // Wait for a click in the display window + * std::cout << "Wait for a button click..." << std::endl; + * vpDisplay::getClick(I); + * #endif + * } + * \endcode + */ class VISP_EXPORT vpDisplayGTK : public vpDisplay { private: diff --git a/modules/gui/include/visp3/gui/vpDisplayX.h b/modules/gui/include/visp3/gui/vpDisplayX.h index 9f8734359a..554a93a550 100644 --- a/modules/gui/include/visp3/gui/vpDisplayX.h +++ b/modules/gui/include/visp3/gui/vpDisplayX.h @@ -43,91 +43,89 @@ #include /*! - \file vpDisplayX.h - \brief Define the X11 console to display images. -*/ + * \file vpDisplayX.h + * \brief Define the X11 console to display images. + */ /*! - \class vpDisplayX - - \ingroup group_gui_display - - \brief Use the X11 console to display images on unix-like OS. - Thus to enable this class X11 should be installed. Installation - instructions are provided here https://visp.inria.fr/3rd_x11. - - This class define the X11 console to display images - It also define method to display some geometric feature (point, line, -circle) in the image. - - The example below shows how to display an image with this video device. - \code -#include -#include -#include - -int main() -{ - vpImage I; // Grey level image - - // Read an image in PGM P5 format - vpImageIo::read(I, "/local/soft/ViSP/ViSP-images/Klimt/Klimt.pgm"); - -#if defined(VISP_HAVE_X11) - vpDisplayX d; - - // Initialize the display with the image I. Display and image are - // now link together. - d.init(I); -#endif - - // Specify the window location - vpDisplay::setWindowPosition(I, 400, 100); - - // Set the display window title - vpDisplay::setTitle(I, "My X11 display"); - - // Set the display background with image I content - vpDisplay::display(I); - - // Draw a red rectangle in the display overlay (foreground) - vpDisplay::displayRectangle(I, 10, 10, 100, 20, vpColor::red, true); - - // Draw a red rectangle in the display overlay (foreground) - vpImagePoint topLeftCorner; - topLeftCorner.set_i(50); - topLeftCorner.set_j(10); - vpDisplay::displayRectangle(I, topLeftCorner, 100, 20, vpColor::green, true); - - // Flush the foreground and background display - vpDisplay::flush(I); - - // Get non blocking keyboard events - std::cout << "Check keyboard events..." << std::endl; - char key[10]; - bool ret; - for (int i=0; i< 200; i++) { - bool ret = vpDisplay::getKeyboardEvent(I, key, false); - if (ret) - std::cout << "keyboard event: key: " << "\"" << key << "\"" << std::endl; - vpTime::wait(40); - } - - // Get a blocking keyboard event - std::cout << "Wait for a keyboard event..." << std::endl; - ret = vpDisplay::getKeyboardEvent(I, key, true); - std::cout << "keyboard event: " << ret << std::endl; - if (ret) - std::cout << "key: " << "\"" << key << "\"" << std::endl; - - // Wait for a click in the display window - std::cout << "Wait for a button click..." << std::endl; - vpDisplay::getClick(I); -} - \endcode - -*/ - + * \class vpDisplayX + * + * \ingroup group_gui_display + * + * \brief Use the X11 console to display images on unix-like OS. + * Thus to enable this class X11 should be installed. Installation + * instructions are provided here https://visp.inria.fr/3rd_x11. + * + * This class define the X11 console to display images + * It also define method to display some geometric feature (point, line, + * circle) in the image. + * + * The example below shows how to display an image with this video device. + * \code + * #include + * #include + * #include + * + * int main() + * { + * vpImage I; // Grey level image + * + * // Read an image in PGM P5 format + * vpImageIo::read(I, "/local/soft/ViSP/ViSP-images/Klimt/Klimt.pgm"); + * + * #if defined(VISP_HAVE_X11) + * vpDisplayX d; + * + * // Initialize the display with the image I. Display and image are + * // now link together. + * d.init(I); + * #endif + * + * // Specify the window location + * vpDisplay::setWindowPosition(I, 400, 100); + * + * // Set the display window title + * vpDisplay::setTitle(I, "My X11 display"); + * + * // Set the display background with image I content + * vpDisplay::display(I); + * + * // Draw a red rectangle in the display overlay (foreground) + * vpDisplay::displayRectangle(I, 10, 10, 100, 20, vpColor::red, true); + * + * // Draw a red rectangle in the display overlay (foreground) + * vpImagePoint topLeftCorner; + * topLeftCorner.set_i(50); + * topLeftCorner.set_j(10); + * vpDisplay::displayRectangle(I, topLeftCorner, 100, 20, vpColor::green, true); + * + * // Flush the foreground and background display + * vpDisplay::flush(I); + * + * // Get non blocking keyboard events + * std::cout << "Check keyboard events..." << std::endl; + * char key[10]; + * bool ret; + * for (int i=0; i< 200; i++) { + * bool ret = vpDisplay::getKeyboardEvent(I, key, false); + * if (ret) + * std::cout << "keyboard event: key: " << "\"" << key << "\"" << std::endl; + * vpTime::wait(40); + * } + * + * // Get a blocking keyboard event + * std::cout << "Wait for a keyboard event..." << std::endl; + * ret = vpDisplay::getKeyboardEvent(I, key, true); + * std::cout << "keyboard event: " << ret << std::endl; + * if (ret) + * std::cout << "key: " << "\"" << key << "\"" << std::endl; + * + * // Wait for a click in the display window + * std::cout << "Wait for a button click..." << std::endl; + * vpDisplay::getClick(I); + * } + * \endcode + */ class VISP_EXPORT vpDisplayX : public vpDisplay { // private: diff --git a/modules/io/CMakeLists.txt b/modules/io/CMakeLists.txt index 70a2659b5f..785e0bd19d 100644 --- a/modules/io/CMakeLists.txt +++ b/modules/io/CMakeLists.txt @@ -39,8 +39,8 @@ set(opt_libs "") # Image i/o: jpeg, png, OpenCV (already included by core) if(USE_JPEG) - list(APPEND opt_incs ${JPEG_INCLUDE_DIR}) - list(APPEND opt_libs ${JPEG_LIBRARIES}) + # libpng usage is private + include_directories(${JPEG_INCLUDE_DIR}) # If Qt3 and libjpeg are used, we add here QT_CLEAN_NAMESPACE define to # handle a compilation error "conflicting declaration 'typedef long int INT32' if(VISP_HAVE_QT3_FOUND) @@ -49,8 +49,8 @@ if(USE_JPEG) endif() if(USE_PNG) - list(APPEND opt_incs ${PNG_INCLUDE_DIR}) - list(APPEND opt_libs ${PNG_LIBRARIES}) + # libpng usage is private + include_directories(${PNG_INCLUDE_DIR}) add_definitions(${PNG_DEFINITIONS}) endif() @@ -67,7 +67,6 @@ if(USE_NLOHMANN_JSON) list(APPEND opt_incs ${_inc_dirs}) endif() - # simdlib is always enabled since it contains fallback code to plain C++ code # Simd lib is private include_directories(${SIMDLIB_INCLUDE_DIRS}) @@ -183,9 +182,9 @@ if(USE_OPENCV) endif(USE_OPENCV) if(ANDROID) - vp_add_module(io visp_core PRIVATE_OPTIONAL ${SIMDLIB_LIBRARIES}) + vp_add_module(io visp_core PRIVATE_OPTIONAL ${SIMDLIB_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES}) else() - vp_add_module(io visp_core PRIVATE_OPTIONAL ${SIMDLIB_LIBRARIES} WRAP java) + vp_add_module(io visp_core PRIVATE_OPTIONAL ${SIMDLIB_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} WRAP java) endif() vp_glob_module_sources() From 72594bd3693338e6d593cd771426f49f4bb1f4c9 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Thu, 19 Oct 2023 15:57:48 +0200 Subject: [PATCH 3/5] Introduce opt_libs_private var for private libraries --- modules/robot/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/robot/CMakeLists.txt b/modules/robot/CMakeLists.txt index 1704f070fc..c205a763b2 100644 --- a/modules/robot/CMakeLists.txt +++ b/modules/robot/CMakeLists.txt @@ -36,6 +36,7 @@ # Add optional 3rd parties set(opt_incs "") set(opt_libs "") +set(opt_libs_private "") # Warning: when composing the link line, CMake sometimes end up placing multiple # copies of a given library. This can produce the following link error @@ -103,6 +104,7 @@ endif() if(USE_BICLOPS) # No need to export, there is an implementation that allows to use Biclops as private include_directories(${BICLOPS_INCLUDE_DIRS}) + list(APPEND opt_libs_private ${BICLOPS_LIBRARIES}) endif() if(USE_PTU46) @@ -174,14 +176,16 @@ endif() if(WITH_QBDEVICE) # qbdevice is private include_directories(${QBDEVICE_INCLUDE_DIRS}) + list(APPEND opt_libs_private ${QBDEVICE_LIBRARIES}) endif() if(WITH_TAKKTILE2) # reflex-takktile2 is private include_directories(${TAKKTILE2_INCLUDE_DIRS}) + list(APPEND opt_libs_private ${TAKKTILE2_LIBRARIES}) endif() -vp_add_module(robot visp_core OPTIONAL visp_io visp_gui visp_sensor PRIVATE_OPTIONAL ${QBDEVICE_LIBRARIES} ${TAKKTILE2_LIBRARIES} ${BICLOPS_LIBRARIES}) +vp_add_module(robot visp_core OPTIONAL visp_io visp_gui visp_sensor PRIVATE_OPTIONAL ${opt_libs_private}) vp_glob_module_sources() vp_set_source_file_compile_flag(src/wireframe-simulator/vpKeyword.cpp -Wno-sign-conversion) From 0536594c6562f8c313dbbd2daaba62d7fb01eae2 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Thu, 19 Oct 2023 15:59:11 +0200 Subject: [PATCH 4/5] Fix and update biclops control thread --- .../robot/include/visp3/robot/vpRobotBiclops.h | 2 +- .../src/real-robot/biclops/vpRobotBiclops.cpp | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/modules/robot/include/visp3/robot/vpRobotBiclops.h b/modules/robot/include/visp3/robot/vpRobotBiclops.h index 44aba86a72..356e3c4c94 100644 --- a/modules/robot/include/visp3/robot/vpRobotBiclops.h +++ b/modules/robot/include/visp3/robot/vpRobotBiclops.h @@ -410,7 +410,7 @@ class VISP_EXPORT vpRobotBiclops : public vpBiclops, public vpRobot * speed/power can damage the unit, damage due to velocity mode commanding is * under user responsibility. */ - static void *vpRobotBiclopsSpeedControlLoop(void *arg); + static void vpRobotBiclopsSpeedControlLoop(void *arg); private: std::thread m_control_thread; diff --git a/modules/robot/src/real-robot/biclops/vpRobotBiclops.cpp b/modules/robot/src/real-robot/biclops/vpRobotBiclops.cpp index 68b6aa2ff2..288e6ec518 100644 --- a/modules/robot/src/real-robot/biclops/vpRobotBiclops.cpp +++ b/modules/robot/src/real-robot/biclops/vpRobotBiclops.cpp @@ -51,8 +51,8 @@ #include "private/vpRobotBiclopsController_impl.h" -//#define VP_DEBUG // Activate the debug mode -//#define VP_DEBUG_MODE 10 // Activate debug level 1 and 2 +//#define VP_DEBUG // Activate the debug mode +//#define VP_DEBUG_MODE 12 // Activate debug level up to 12 #include /* ---------------------------------------------------------------------- */ @@ -140,11 +140,10 @@ void vpRobotBiclops::init() return; } -void *vpRobotBiclops::vpRobotBiclopsSpeedControlLoop(void *arg) +void vpRobotBiclops::vpRobotBiclopsSpeedControlLoop(void *arg) { vpRobotBiclopsController *controller = static_cast(arg); - int iter = 0; // PMDAxisControl *m_panAxis = controller->getPanAxis(); // PMDAxisControl *m_tiltAxis = controller->getTiltAxis(); vpRobotBiclopsController::shmType shm; @@ -363,12 +362,8 @@ void *vpRobotBiclops::vpRobotBiclopsSpeedControlLoop(void *arg) for (unsigned int i = 0; i < vpBiclops::ndof; i++) prev_q_dot[i] = shm.q_dot[i]; - vpDEBUG_TRACE(12, "iter: %d", iter); - // wait 5 ms vpTime::wait(5.0); - - iter++; } controller->stopRequest(false); // Stop the robot @@ -382,8 +377,6 @@ void *vpRobotBiclops::vpRobotBiclopsSpeedControlLoop(void *arg) delete[] enable_limit; vpDEBUG_TRACE(11, "unlock vpEndThread_mutex"); m_mutex_end_thread.unlock(); - - return NULL; } vpRobot::vpRobotStateType vpRobotBiclops::setRobotState(vpRobot::vpRobotStateType newState) @@ -410,7 +403,7 @@ vpRobot::vpRobotStateType vpRobotBiclops::setRobotState(vpRobot::vpRobotStateTyp m_mutex_end_thread.lock(); vpDEBUG_TRACE(12, "Create speed control thread"); - m_control_thread = std::thread(&vpRobotBiclops::vpRobotBiclopsSpeedControlLoop, &m_controller); + m_control_thread = std::thread(&vpRobotBiclops::vpRobotBiclopsSpeedControlLoop, m_controller); vpTime::wait(100.0); vpDEBUG_TRACE(12, "Speed control thread created"); From d42d0b792735417266a2775a7e6230d0ccc50a51 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Thu, 19 Oct 2023 16:09:13 +0200 Subject: [PATCH 5/5] Introduce opt_libs_private to handle private libs --- modules/gui/CMakeLists.txt | 5 ++++- modules/io/CMakeLists.txt | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/gui/CMakeLists.txt b/modules/gui/CMakeLists.txt index 729f6ec155..8972c4037b 100644 --- a/modules/gui/CMakeLists.txt +++ b/modules/gui/CMakeLists.txt @@ -36,11 +36,13 @@ # Add optional 3rd parties set(opt_incs "") set(opt_libs "") +set(opt_libs_private "") # Display X11, GTK, GDI, D3D9. OpenCV already handled by core module if(USE_X11) # X11 is private include_directories(${X11_INCLUDE_DIR}) + list(APPEND opt_libs_private ${X11_LIBRARIES}) mark_as_advanced(X11_xcb_icccm_INCLUDE_PATH) mark_as_advanced(X11_xcb_icccm_LIB) mark_as_advanced(X11_xcb_xkb_INCLUDE_PATH) @@ -49,6 +51,7 @@ endif() if(USE_GTK2) # gtk2 is private include_directories(${GTK2_INCLUDE_DIRS}) + list(APPEND opt_libs_private ${GTK2_LIBRARIES}) endif() if(USE_GDI) @@ -82,7 +85,7 @@ if(USE_PCL) list(APPEND opt_libs ${PCL_DEPS_LIBRARIES}) endif() -vp_add_module(gui visp_core PRIVATE_OPTIONAL ${X11_LIBRARIES} ${GTK2_LIBRARIES}) +vp_add_module(gui visp_core PRIVATE_OPTIONAL ${opt_libs_private}) vp_glob_module_sources() vp_module_include_directories(${opt_incs}) vp_create_module(${opt_libs}) diff --git a/modules/io/CMakeLists.txt b/modules/io/CMakeLists.txt index 785e0bd19d..0c0e900226 100644 --- a/modules/io/CMakeLists.txt +++ b/modules/io/CMakeLists.txt @@ -36,11 +36,13 @@ # Add optional 3rd parties set(opt_incs "") set(opt_libs "") +set(opt_libs_private "") # Image i/o: jpeg, png, OpenCV (already included by core) if(USE_JPEG) - # libpng usage is private + # libjpeg usage is private include_directories(${JPEG_INCLUDE_DIR}) + list(APPEND opt_libs_private ${JPEG_LIBRARIES}) # If Qt3 and libjpeg are used, we add here QT_CLEAN_NAMESPACE define to # handle a compilation error "conflicting declaration 'typedef long int INT32' if(VISP_HAVE_QT3_FOUND) @@ -51,6 +53,7 @@ endif() if(USE_PNG) # libpng usage is private include_directories(${PNG_INCLUDE_DIR}) + list(APPEND opt_libs_private ${PNG_LIBRARIES}) add_definitions(${PNG_DEFINITIONS}) endif() @@ -70,6 +73,7 @@ endif() # simdlib is always enabled since it contains fallback code to plain C++ code # Simd lib is private include_directories(${SIMDLIB_INCLUDE_DIRS}) +list(APPEND opt_libs_private ${SIMDLIB_LIBRARIES}) # TinyEXR lib is private include_directories(${TINYEXR_INCLUDE_DIRS}) @@ -182,9 +186,9 @@ if(USE_OPENCV) endif(USE_OPENCV) if(ANDROID) - vp_add_module(io visp_core PRIVATE_OPTIONAL ${SIMDLIB_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES}) + vp_add_module(io visp_core PRIVATE_OPTIONAL ${opt_libs_private}) else() - vp_add_module(io visp_core PRIVATE_OPTIONAL ${SIMDLIB_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} WRAP java) + vp_add_module(io visp_core PRIVATE_OPTIONAL ${opt_libs_private} WRAP java) endif() vp_glob_module_sources()