Skip to content

Commit

Permalink
Merge pull request #1258 from fspindle/feat_biclops_private
Browse files Browse the repository at this point in the history
Make Biclops 3rdparty usage private
  • Loading branch information
fspindle authored Oct 20, 2023
2 parents c75b063 + 0536594 commit acc88f0
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 107 deletions.
80 changes: 40 additions & 40 deletions cmake/FindBICLOPS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,85 +39,85 @@
#############################################################################


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
$ENV{BICLOPS_PMD_HOME}/lib
/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 <PMDUtils.h>
int main(){
Expand All @@ -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
Expand All @@ -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)
2 changes: 1 addition & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,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)
Expand Down
2 changes: 1 addition & 1 deletion example/servo-biclops/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions modules/robot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -101,8 +102,9 @@ 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})
list(APPEND opt_libs_private ${BICLOPS_LIBRARIES})
endif()

if(USE_PTU46)
Expand Down Expand Up @@ -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})
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)
Expand Down Expand Up @@ -222,6 +226,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)
Expand Down
6 changes: 3 additions & 3 deletions modules/robot/include/visp3/robot/vpRobotBiclops.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
#include <visp3/core/vpVelocityTwistMatrix.h>
#include <visp3/robot/vpBiclops.h>
#include <visp3/robot/vpRobot.h>
#include <visp3/robot/vpRobotBiclopsController.h>

/* ------------------------------------------------------------------------ */
/* --- CLASS -------------------------------------------------------------- */
Expand Down Expand Up @@ -411,14 +410,15 @@ 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;

std::string m_configfile; // Biclops config file

vpRobotBiclopsController m_controller;
class vpRobotBiclopsController;
vpRobotBiclopsController *m_controller;

double m_positioningVelocity;
vpColVector m_q_previous;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@

/* Headers */
#include <visp3/robot/vpRobotBiclops.h>
#include <visp3/robot/vpRobotBiclopsController.h>
#include <visp3/robot/vpRobotException.h>

#include "vpRobotBiclopsController_impl.h"

//#define VP_DEBUG // Activate the debug mode
//#define VP_DEBUG_MODE 20 // Activate debug level 1 and 2

#include <visp3/core/vpDebug.h>

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)
{
Expand All @@ -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;
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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);
Expand All @@ -282,7 +283,7 @@ vpColVector vpRobotBiclopsController::getPosition()
return q;
}

vpColVector vpRobotBiclopsController::getActualPosition()
vpColVector vpRobotBiclops::vpRobotBiclopsController::getActualPosition()
{
vpColVector q(vpBiclops::ndof);
PMDint32 panpos, tiltpos;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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]);
Expand All @@ -335,7 +336,7 @@ void vpRobotBiclopsController::writeShm(shmType &shm)
}
}

vpRobotBiclopsController::shmType vpRobotBiclopsController::readShm()
vpRobotBiclops::vpRobotBiclopsController::shmType vpRobotBiclops::vpRobotBiclopsController::readShm()
{
shmType tmp_shm;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
/*!
Expand Down
Loading

0 comments on commit acc88f0

Please sign in to comment.