Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat biclops without pthread #1255

Merged
merged 7 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -549,14 +549,14 @@ if(SOQT_FOUND) # SoQt < 1.6.0 that depends on Qt4 was found. We need an explicit
endif()
VP_OPTION(USE_SOXT SOXT "" "Include Coin/SoXt support" "" OFF IF USE_COIN3D AND NOT WINRT AND NOT IOS)
set(THREADS_PREFER_PTHREAD_FLAG ON)
VP_OPTION(USE_PTHREAD Threads "" "Include pthread support" "" ON IF NOT (WIN32 OR MINGW))
VP_OPTION(USE_THREADS Threads "" "Include std::thread support" "" ON IF NOT (WIN32 OR MINGW))

# We need threads with c++11
if((VISP_CXX_STANDARD GREATER VISP_CXX_STANDARD_98) AND NOT USE_PTHREAD)
if((VISP_CXX_STANDARD GREATER VISP_CXX_STANDARD_98) AND NOT USE_THREADS)
if(Threads_FOUND)
message(WARNING "We need threads. Turn USE_PTHREAD=ON.")
unset(USE_PTHREAD)
set(USE_PTHREAD ON CACHE BOOL "Include pthread support" FORCE)
message(WARNING "We need std::thread. We turn USE_THREADS=ON.")
unset(USE_THREADS)
set(USE_THREADS ON CACHE BOOL "Include std::thread support" FORCE)
endif()
endif()

Expand Down Expand Up @@ -658,9 +658,9 @@ endif()
# ----------------------------------------------------------------------------
# Build-in 3rd parties. Should be after c++ standard potential modification
# ----------------------------------------------------------------------------
VP_OPTION(WITH_PTHREAD "" "" "Build pthread as built-in library" "" ON IF (NOT USE_PTHREAD) AND (WIN32 OR MINGW) AND (NOT WINRT_8_1) AND (NOT WINRT_8_0))
VP_OPTION(WITH_PTHREAD "" "" "Build pthread as built-in library" "" ON IF (NOT USE_THREADS) AND (WIN32 OR MINGW) AND (NOT WINRT_8_1) AND (NOT WINRT_8_0))
# Since C99 is not supported by MSVC 2010 or prior, we disable apriltag if MSVC < 2012
VP_OPTION(WITH_APRILTAG "" "" "Build AprilTag as built-in library" "" ON IF (USE_PTHREAD OR WITH_PTHREAD) AND (NOT WINRT_8_1) AND (NOT WINRT_8_0) AND (NOT MSVC_VERSION LESS 1700))
VP_OPTION(WITH_APRILTAG "" "" "Build AprilTag as built-in library" "" ON IF (USE_THREADS OR WITH_PTHREAD) AND (NOT WINRT_8_1) AND (NOT WINRT_8_0) AND (NOT MSVC_VERSION LESS 1700))
VP_OPTION(WITH_APRILTAG_BIG_FAMILY "" "" "Build AprilTag big family (41h12, 48h12, 49h12, 52h13)" "" OFF IF WITH_APRILTAG)
VP_OPTION(WITH_ATIDAQ "" "" "Build atidaq-c as built-in library" "" ON IF USE_COMEDI AND NOT WINRT)
VP_OPTION(WITH_CLIPPER "" "" "Build clipper as built-in library" "" ON IF USE_OPENCV)
Expand Down Expand Up @@ -890,7 +890,8 @@ VP_SET(VISP_HAVE_LAPACK_GSL TRUE IF (BUILD_MODULE_visp_core AND USE_GSL))
VP_SET(VISP_HAVE_LAPACK_MKL TRUE IF (BUILD_MODULE_visp_core AND USE_MKL))
VP_SET(VISP_HAVE_LAPACK_NETLIB TRUE IF (BUILD_MODULE_visp_core AND USE_NETLIB))
VP_SET(VISP_HAVE_LAPACK_OPENBLAS TRUE IF (BUILD_MODULE_visp_core AND USE_OPENBLAS))
VP_SET(VISP_HAVE_PTHREAD TRUE IF (BUILD_MODULE_visp_core AND USE_PTHREAD))
VP_SET(VISP_HAVE_PTHREAD TRUE IF (BUILD_MODULE_visp_core AND USE_THREADS)) # Keep for the momment for compat
VP_SET(VISP_HAVE_THREADS TRUE IF (BUILD_MODULE_visp_core AND USE_THREADS))
VP_SET(VISP_HAVE_XML2 TRUE IF (BUILD_MODULE_visp_core AND USE_XML2))
VP_SET(VISP_HAVE_PCL TRUE IF (BUILD_MODULE_visp_core AND USE_PCL))
VP_SET(VISP_HAVE_TENSORRT TRUE IF (BUILD_MODULE_visp_core AND USE_TENSORRT))
Expand All @@ -915,22 +916,22 @@ VP_SET(VISP_HAVE_UR_RTDE TRUE IF (BUILD_MODULE_visp_robot AND USE_UR_RTDE))
VP_SET(VISP_HAVE_FRANKA TRUE IF (BUILD_MODULE_visp_robot AND USE_FRANKA))
VP_SET(VISP_HAVE_JACOSDK TRUE IF (BUILD_MODULE_visp_robot AND USE_JACOSDK))
VP_SET(VISP_HAVE_MAVSDK TRUE IF (BUILD_MODULE_visp_robot AND USE_MAVSDK))
VP_SET(VISP_HAVE_BICLOPS TRUE IF (BUILD_MODULE_visp_robot AND USE_BICLOPS))
VP_SET(VISP_HAVE_BICLOPS TRUE IF (BUILD_MODULE_visp_robot AND USE_BICLOPS AND USE_THREADS))
VP_SET(VISP_HAVE_PTU46 TRUE IF (BUILD_MODULE_visp_robot AND USE_PTU46))
VP_SET(VISP_HAVE_FLIR_PTU_SDK TRUE IF (BUILD_MODULE_visp_robot AND USE_FLIRPTUSDK))
VP_SET(VISP_HAVE_ARSDK TRUE IF (BUILD_MODULE_visp_robot AND USE_ARSDK))
VP_SET(VISP_HAVE_FFMPEG TRUE IF (BUILD_MODULE_visp_robot AND USE_FFMPEG))
#VP_SET(VISP_HAVE_PIONEER TRUE IF (BUILD_MODULE_visp_robot AND USE_ARIA))
if(BUILD_MODULE_visp_robot AND USE_ARIA)
if(UNIX AND USE_PTHREAD AND RT_FOUND AND DL_FOUND)
if(UNIX AND USE_THREADS AND RT_FOUND AND DL_FOUND)
set(VISP_HAVE_PIONEER TRUE)
elseif(NOT UNIX)
set(VISP_HAVE_PIONEER TRUE)
endif()
endif()
#VP_SET(VISP_HAVE_VIRTUOSE TRUE IF (BUILD_MODULE_visp_robot AND USE_VIRTUOSE))
if(BUILD_MODULE_visp_robot AND USE_VIRTUOSE)
if(UNIX AND USE_PTHREAD AND RT_FOUND AND DL_FOUND)
if(UNIX AND USE_THREADS AND RT_FOUND AND DL_FOUND)
set(VISP_HAVE_VIRTUOSE TRUE)
elseif(NOT UNIX)
set(VISP_HAVE_VIRTUOSE TRUE)
Expand Down Expand Up @@ -970,9 +971,9 @@ VP_SET(VISP_HAVE_D3D9 TRUE IF USE_DIRECT3D) # for header vpConfig.h
VP_SET(VISP_HAVE_GTK TRUE IF USE_GTK2) # for header vpConfig.h
VP_SET(VISP_HAVE_XRANDR TRUE IF XRANDR) # for header vpConfig.h

# Check if libfreenect dependencies (ie libusb-1.0 and libpthread) are available
if(USE_LIBFREENECT AND USE_LIBUSB_1 AND USE_PTHREAD)
if(LIBFREENECT_FOUND AND LIBUSB_1_FOUND AND PTHREAD_FOUND)
# Check if libfreenect dependencies (ie libusb-1.0 and threads) are available
if(USE_LIBFREENECT AND USE_LIBUSB_1 AND USE_THREADS)
if(LIBFREENECT_FOUND AND LIBUSB_1_FOUND)
set(VISP_HAVE_LIBFREENECT_AND_DEPENDENCIES TRUE)

# The material is found. Check if libfreenect is an old version
Expand Down Expand Up @@ -1092,7 +1093,7 @@ endif()

# libraries for Pioneer mobile robots
if(USE_ARIA AND UNIX)
if(ARIA_FOUND AND USE_PTHREAD AND RT_FOUND AND DL_FOUND)
if(ARIA_FOUND AND USE_THREADS AND RT_FOUND AND DL_FOUND)
set(VISP_HAVE_PIONEER TRUE) # for header vpConfig.h
endif()
elseif(USE_ARIA AND NOT UNIX)
Expand Down Expand Up @@ -1571,10 +1572,10 @@ status(" RGB-D sensors: ")
status(" Use Realsense:" USE_REALSENSE THEN "yes (ver ${REALSENSE_VERSION})" ELSE "no")
status(" Use Realsense2:" USE_REALSENSE2 THEN "yes (ver ${REALSENSE2_VERSION})" ELSE "no")
status(" Use Occipital Structure:" USE_OCCIPITAL_STRUCTURE THEN "yes" ELSE "no")
status(" Use Kinect:" USE_LIBFREENECT AND USE_LIBUSB_1 AND USE_PTHREAD THEN "yes" ELSE "no")
status(" Use Kinect:" USE_LIBFREENECT AND USE_LIBUSB_1 AND USE_THREADS THEN "yes" ELSE "no")
status(" \\- Use libfreenect:" USE_LIBFREENECT THEN "yes (ver ${LIBFREENECT_VERSION})" ELSE "no")
status(" \\- Use libusb-1:" USE_LIBUSB_1 THEN "yes (ver ${LIBUSB_1_VERSION})" ELSE "no")
status(" \\- Use pthread:" USE_PTHREAD THEN "yes" ELSE "no")
status(" \\- Use std::thread:" USE_THREADS THEN "yes" ELSE "no")
status(" Use PCL:" USE_PCL THEN "yes (ver ${PCL_VERSION})" ELSE "no")
status(" \\- Use VTK:" VTK_FOUND THEN "yes (ver ${VTK_VERSION})" ELSE "no")
status("")
Expand All @@ -1601,7 +1602,7 @@ status(" Use json (nlohmann):" USE_NLOHMANN_JSON THEN "yes (ver ${nlohman
status("")
status(" Optimization: ")
status(" Use OpenMP:" USE_OPENMP THEN "yes" ELSE "no")
status(" Use pthread:" USE_PTHREAD THEN "yes" ELSE "no")
status(" Use st::thread:" USE_THREADS THEN "yes" ELSE "no")
status(" Use pthread (built-in):" WITH_PTHREAD THEN "yes (ver ${PTHREADS_VERSION})" ELSE "no")
status(" Use Simd (built-in):" "yes (ver ${SIMD_VERSION})")
status("")
Expand Down
4 changes: 2 additions & 2 deletions CTestConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ if(VISP_HAVE_XML2)
set(BUILDNAME "${BUILDNAME}-xml")
endif()
# PThread
if(VISP_HAVE_PTHREAD)
set(BUILDNAME "${BUILDNAME}-pthread")
if(VISP_HAVE_THREADS)
set(BUILDNAME "${BUILDNAME}-threads")
endif()
# OpenMP
if(VISP_HAVE_OPENMP)
Expand Down
2 changes: 1 addition & 1 deletion ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ ViSP 2.6.1 (released October 20th, 2011)
vpRobotSimulator, vpFFMPEG, vpBSpline
- It is now possible to grab images from an usb webcam with the
vpV4l2Grabber class that is based on the video 4 linux 2 driver.
- When it was possible without braking the backward compatibilty
- When it was possible without braking the backward compatibility
std::list was introduced instead of vpList. Some of the functions that
use vpList are now deprecated.
- Better detection of image or video file types when used in vpImageIo,
Expand Down
2 changes: 1 addition & 1 deletion cmake/AddExtraCompilationFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ if(USE_OPENMP)
add_extra_compiler_option("${OpenMP_CXX_FLAGS}")
endif()

if(USE_PTHREAD)
if(USE_THREADS)
if(THREADS_HAVE_PTHREAD_ARG)
add_extra_compiler_option("-pthread")
endif()
Expand Down
1 change: 1 addition & 0 deletions cmake/templates/VISPConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ set(VISP_HAVE_SOWIN "@VISP_HAVE_SOWIN@")
set(VISP_HAVE_SOXT "@VISP_HAVE_SOXT@")
set(VISP_HAVE_TAKKTILE2 "@VISP_HAVE_TAKKTILE2@")
set(VISP_HAVE_TENSORRT "@VISP_HAVE_TENSORRT@")
set(VISP_HAVE_THREADS "@VISP_HAVE_THREADS@")
set(VISP_HAVE_UEYE "@VISP_HAVE_UEYE@")
set(VISP_HAVE_UR_RTDE "@VISP_HAVE_UR_RTDE@")
set(VISP_HAVE_V4L2 "@VISP_HAVE_V4L2@")
Expand Down
3 changes: 3 additions & 0 deletions cmake/templates/vpConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@
// Defined if pthread library available.
#cmakedefine VISP_HAVE_PTHREAD

// Defined if std::thread available.
#cmakedefine VISP_HAVE_THREADS

// Defined if YARP available.
#cmakedefine VISP_HAVE_YARP

Expand Down
1 change: 1 addition & 0 deletions doc/config-doxygen.in
Original file line number Diff line number Diff line change
Expand Up @@ -2220,6 +2220,7 @@ PREDEFINED = @DOXYGEN_SHOULD_SKIP_THIS@ \
VISP_HAVE_SOXT \
VISP_HAVE_TAKKTILE2 \
VISP_HAVE_TENSORRT \
VISP_HAVE_THREADS \
VISP_HAVE_UEYE \
VISP_HAVE_UR_RTDE \
VISP_HAVE_V4L2 \
Expand Down
50 changes: 25 additions & 25 deletions example/servo-biclops/moveBiclops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
* See http://www.traclabs.com/tracbiclops.htm for more details.
*/

#include <stdlib.h>
#include <visp3/core/vpColVector.h>
#include <visp3/core/vpDebug.h>
#include <visp3/core/vpTime.h>
#include <visp3/io/vpParseArgv.h>
#include <iostream>

#include <visp3/core/vpConfig.h>

#ifdef VISP_HAVE_BICLOPS

#include <visp3/robot/vpRobotBiclops.h>
#include <visp3/io/vpParseArgv.h>

// List of allowed command line options
#define GETOPTARGS "c:h"
Expand Down Expand Up @@ -145,49 +145,49 @@ int main(int argc, const char **argv)
q = 0;
q[0] = vpMath::rad(-10);
q[1] = vpMath::rad(-20);
std::cout << "Set position in the articular frame: "
std::cout << "Set Joint position "
<< " pan: " << vpMath::deg(q[0]) << " deg"
<< " tilt: " << vpMath::deg(q[1]) << " deg" << std::endl;
robot.setPositioningVelocity(30.);
robot.setPosition(vpRobot::JOINT_STATE, q);

robot.getPosition(vpRobot::JOINT_STATE, qm);
std::cout << "Position in the articular frame: "
std::cout << " Joint position "
<< " pan: " << vpMath::deg(qm[0]) << " tilt: " << vpMath::deg(qm[1]) << std::endl;
robot.getVelocity(vpRobot::JOINT_STATE, qm);
std::cout << "Velocity in the articular frame: "
std::cout << " Joint velocity "
<< " pan: " << vpMath::deg(qm[0]) << " tilt: " << vpMath::deg(qm[1]) << std::endl;

q[0] = vpMath::rad(10);
q[1] = vpMath::rad(20);
std::cout << "Set position in the articular frame: "
std::cout << "Set Joint position "
<< " pan: " << vpMath::deg(q[0]) << " deg"
<< " tilt: " << vpMath::deg(q[1]) << " deg" << std::endl;
robot.setPositioningVelocity(10);
robot.setPosition(vpRobot::JOINT_STATE, q);

robot.getPosition(vpRobot::JOINT_STATE, qm);
std::cout << "Position in the articular frame: "
std::cout << " Joint position: "
<< " pan: " << vpMath::deg(qm[0]) << " tilt: " << vpMath::deg(qm[1]) << std::endl;
robot.getVelocity(vpRobot::JOINT_STATE, qm);
std::cout << "Velocity in the articular frame: "
std::cout << " Joint velocity: "
<< " pan: " << vpMath::deg(qm[0]) << " tilt: " << vpMath::deg(qm[1]) << std::endl;

std::cout << "Set STATE_VELOCITY_CONTROL" << std::endl;
robot.setRobotState(vpRobot::STATE_VELOCITY_CONTROL);

robot.getPosition(vpRobot::JOINT_STATE, qm);
std::cout << "Position in the articular frame: "
std::cout << " Joint position: "
<< " pan: " << vpMath::deg(qm[0]) << " deg"
<< " tilt: " << vpMath::deg(qm[1]) << " deg" << std::endl;
robot.getVelocity(vpRobot::JOINT_STATE, qm);
std::cout << "Velocity in the articular frame: "
std::cout << " Joint velocity "
<< " pan: " << vpMath::deg(qm[0]) << " tilt: " << vpMath::deg(qm[1]) << std::endl;

qdot = 0;
// qdot[0] = vpMath::rad(0.1) ;
qdot[1] = vpMath::rad(25);
std::cout << "Set articular frame velocity for 5 sec"
std::cout << "Set joint velocity for 5 sec"
<< " pan: " << vpMath::deg(qdot[0]) << " deg/s"
<< " tilt: " << vpMath::deg(qdot[1]) << " deg/s" << std::endl;
robot.setVelocity(vpRobot::JOINT_STATE, qdot);
Expand All @@ -196,17 +196,17 @@ int main(int argc, const char **argv)
vpTime::wait(5000.0);

robot.getPosition(vpRobot::JOINT_STATE, qm);
std::cout << "Position in the articular frame: "
std::cout << " Joint position "
<< " pan: " << vpMath::deg(qm[0]) << " deg"
<< " tilt: " << vpMath::deg(qm[1]) << " deg" << std::endl;
robot.getVelocity(vpRobot::JOINT_STATE, qm);
std::cout << "Velocity in the articular frame: "
std::cout << " Joint velocity "
<< " pan: " << vpMath::deg(qm[0]) << " tilt: " << vpMath::deg(qm[1]) << std::endl;

qdot = 0;
// qdot[0] = vpMath::rad(0.1) ;
qdot[1] = -vpMath::rad(25);
std::cout << "Set articular frame velocity for 3 sec"
std::cout << "Set joint velocity for 3 sec"
<< " pan: " << vpMath::deg(qdot[0]) << " deg/s"
<< " tilt: " << vpMath::deg(qdot[1]) << " deg/s" << std::endl;
robot.setVelocity(vpRobot::JOINT_STATE, qdot);
Expand All @@ -215,17 +215,17 @@ int main(int argc, const char **argv)
vpTime::wait(3000.0);

robot.getPosition(vpRobot::JOINT_STATE, qm);
std::cout << "Position in the articular frame: "
std::cout << " Joint position "
<< " pan: " << vpMath::deg(qm[0]) << " deg"
<< " tilt: " << vpMath::deg(qm[1]) << " deg" << std::endl;
robot.getVelocity(vpRobot::JOINT_STATE, qm);
std::cout << "Velocity in the articular frame: "
std::cout << " Joint velocity "
<< " pan: " << vpMath::deg(qm[0]) << " tilt: " << vpMath::deg(qm[1]) << std::endl;

qdot = 0;
// qdot[0] = vpMath::rad(0.1) ;
qdot[1] = vpMath::rad(10);
std::cout << "Set articular frame velocity for 2 sec"
std::cout << "Set joint velocity for 2 sec"
<< " pan: " << vpMath::deg(qdot[0]) << " deg/s"
<< " tilt: " << vpMath::deg(qdot[1]) << " deg/s" << std::endl;
robot.setVelocity(vpRobot::JOINT_STATE, qdot);
Expand All @@ -234,18 +234,18 @@ int main(int argc, const char **argv)
vpTime::wait(2000.0);

robot.getPosition(vpRobot::JOINT_STATE, qm);
std::cout << "Position in the articular frame: "
std::cout << " Joint position "
<< " pan: " << vpMath::deg(qm[0]) << " deg"
<< " tilt: " << vpMath::deg(qm[1]) << " deg" << std::endl;
robot.getVelocity(vpRobot::JOINT_STATE, qm);
std::cout << "Velocity in the articular frame: "
std::cout << " Joint velocity "
<< " pan: " << vpMath::deg(qm[0]) << " tilt: " << vpMath::deg(qm[1]) << std::endl;

qdot = 0;
qdot[0] = vpMath::rad(-5);
// qdot[1] = vpMath::rad(-5);

std::cout << "Set articular frame velocity for 2 sec"
std::cout << "Set joint velocity for 2 sec"
<< " pan: " << vpMath::deg(qdot[0]) << " deg/s"
<< " tilt: " << vpMath::deg(qdot[1]) << " deg/s" << std::endl;
robot.setVelocity(vpRobot::JOINT_STATE, qdot);
Expand All @@ -254,11 +254,11 @@ int main(int argc, const char **argv)
vpTime::wait(2000.0);

robot.getPosition(vpRobot::JOINT_STATE, qm);
std::cout << "Position in the articular frame: "
std::cout << " Joint position "
<< " pan: " << vpMath::deg(qm[0]) << " deg"
<< " tilt: " << vpMath::deg(qm[1]) << " deg" << std::endl;
robot.getVelocity(vpRobot::JOINT_STATE, qm);
std::cout << "Velocity in the articular frame: "
std::cout << " Joint velocity "
<< " pan: " << vpMath::deg(qm[0]) << " tilt: " << vpMath::deg(qm[1]) << std::endl;
return EXIT_SUCCESS;
}
Expand Down
Loading
Loading