diff --git a/src/libraries/ctrlLib/CMakeLists.txt b/src/libraries/ctrlLib/CMakeLists.txt index 27b6c6f17f..4ee04938d5 100644 --- a/src/libraries/ctrlLib/CMakeLists.txt +++ b/src/libraries/ctrlLib/CMakeLists.txt @@ -35,12 +35,11 @@ include_directories(${PROJECT_SOURCE_DIR}/include ${GSL_INCLUDE_DIRS} ${YARP_INCLUDE_DIRS}) -add_library(${PROJECT_NAME} ${folder_source} ${folder_header}) - if(MSVC) - target_compile_definitions(${PROJECT_NAME} PUBLIC _USE_MATH_DEFINES) + add_definitions(-D_USE_MATH_DEFINES) endif() +add_library(${PROJECT_NAME} ${folder_source} ${folder_header}) target_link_libraries(${PROJECT_NAME} ${GSL_LIBRARIES} ${YARP_LIBRARIES}) icub_export_library(${PROJECT_NAME} INTERNAL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include diff --git a/src/libraries/ctrlLib/include/iCub/ctrl/math.h b/src/libraries/ctrlLib/include/iCub/ctrl/math.h index 894204afb1..0c5476b084 100644 --- a/src/libraries/ctrlLib/include/iCub/ctrl/math.h +++ b/src/libraries/ctrlLib/include/iCub/ctrl/math.h @@ -45,15 +45,10 @@ #ifndef __CTRLMATH_H__ #define __CTRLMATH_H__ -#include - #include #include #include -#define CTRL_RAD2DEG (180.0/M_PI) -#define CTRL_DEG2RAD (M_PI/180.0) - namespace iCub { @@ -61,6 +56,21 @@ namespace iCub namespace ctrl { +/** + * The PI constant. + */ +extern const double CTRL_PI; + +/** + * 180/PI. + */ +extern const double CTRL_RAD2DEG; + +/** + * PI/180. + */ +extern const double CTRL_DEG2RAD; + /** * \ingroup Maths * diff --git a/src/libraries/ctrlLib/src/math.cpp b/src/libraries/ctrlLib/src/math.cpp index 687f328396..b2763f7edd 100644 --- a/src/libraries/ctrlLib/src/math.cpp +++ b/src/libraries/ctrlLib/src/math.cpp @@ -29,6 +29,16 @@ using namespace yarp::sig; using namespace yarp::math; +/************************************************************************/ +namespace iCub { + namespace ctrl { + const double CTRL_PI=M_PI; + const double CTRL_RAD2DEG=180.0/M_PI; + const double CTRL_DEG2RAD=M_PI/180.0; + } +} + + /************************************************************************/ double iCub::ctrl::dot(const Matrix &A, int colA, const Matrix &B, int colB) { diff --git a/src/libraries/iDyn/CMakeLists.txt b/src/libraries/iDyn/CMakeLists.txt index 5e8202cc9e..08f4ad01ee 100644 --- a/src/libraries/iDyn/CMakeLists.txt +++ b/src/libraries/iDyn/CMakeLists.txt @@ -2,41 +2,42 @@ # Authors: Matteo Fumagalli, Serena Ivaldi # CopyPolicy: Released under the terms of the GNU GPL v2.0. -SET(PROJECTNAME iDyn) +project(iDyn) -PROJECT(${PROJECTNAME}) - -SET(folder_source src/iDyn.cpp +set(folder_source src/iDyn.cpp src/iDynInv.cpp src/iDynBody.cpp src/iDynTransform.cpp src/iDynContact.cpp) -SET(folder_header include/iCub/iDyn/iDyn.h +set(folder_header include/iCub/iDyn/iDyn.h include/iCub/iDyn/iDynInv.h include/iCub/iDyn/iDynBody.h include/iCub/iDyn/iDynTransform.h include/iCub/iDyn/iDynContact.h) -SOURCE_GROUP("Source Files" FILES ${folder_source}) -SOURCE_GROUP("Header Files" FILES ${folder_header}) +source_group("Source Files" FILES ${folder_source}) +source_group("Header Files" FILES ${folder_header}) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include +include_directories(${PROJECT_SOURCE_DIR}/include ${iKin_INCLUDE_DIRS} ${skinDynLib_INCLUDE_DIRS} ${GSL_INCLUDE_DIRS} ${YARP_INCLUDE_DIRS}) -ADD_LIBRARY(${PROJECTNAME} ${folder_source} ${folder_header}) +if(MSVC) + add_definitions(-D_USE_MATH_DEFINES) +endif() -TARGET_LINK_LIBRARIES(${PROJECTNAME} iKin - skinDynLib - ${GSL_LIBRARIES} - ${YARP_LIBRARIES}) +add_library(${PROJECT_NAME} ${folder_source} ${folder_header}) +target_link_libraries(${PROJECT_NAME} iKin + skinDynLib + ${GSL_LIBRARIES} + ${YARP_LIBRARIES}) -icub_export_library(${PROJECTNAME} INTERNAL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include - DEPENDS iKin skinDynLib - DESTINATION include/iCub/iDyn - FILES ${folder_header}) +icub_export_library(${PROJECT_NAME} INTERNAL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include + DEPENDS iKin skinDynLib + DESTINATION include/iCub/iDyn + FILES ${folder_header}) diff --git a/src/libraries/iDyn/include/iCub/iDyn/iDyn.h b/src/libraries/iDyn/include/iCub/iDyn/iDyn.h index acdfcdc814..08a4fa0f85 100644 --- a/src/libraries/iDyn/include/iCub/iDyn/iDyn.h +++ b/src/libraries/iDyn/include/iCub/iDyn/iDyn.h @@ -456,7 +456,7 @@ class iDynLink : public iKin::iKinLink * @param _Min is the joint angle lower bound in [-pi,pi] (-pi by default) * @param _Max is the joint angle higher bound in [-pi,pi] (pi by default) */ - iDynLink(double _A, double _D, double _Alpha, double _Offset, double _Min=-M_PI, double _Max=M_PI); + iDynLink(double _A, double _D, double _Alpha, double _Offset, double _Min=-iCub::ctrl::CTRL_PI, double _Max=iCub::ctrl::CTRL_PI); /** * Constructor, with initialization of kinematic and dynamic data @@ -470,7 +470,7 @@ class iDynLink : public iKin::iKinLink * @param _Min is the joint angle lower bound in [-pi,pi] (-pi by default) * @param _Max is the joint angle higher bound in [-pi,pi] (pi by default) */ - iDynLink(const double _m, const yarp::sig::Matrix &_HC, const yarp::sig::Matrix &_I, double _A, double _D, double _Alpha, double _Offset, double _Min=-M_PI, double _Max=M_PI); + iDynLink(const double _m, const yarp::sig::Matrix &_HC, const yarp::sig::Matrix &_I, double _A, double _D, double _Alpha, double _Offset, double _Min=-iCub::ctrl::CTRL_PI, double _Max=iCub::ctrl::CTRL_PI); /** * Constructor, with initialization of kinematic and dynamic data @@ -484,7 +484,7 @@ class iDynLink : public iKin::iKinLink * @param _Min is the joint angle lower bound in [-pi,pi] (-pi by default) * @param _Max is the joint angle higher bound in [-pi,pi] (pi by default) */ - iDynLink(const double _m, const yarp::sig::Vector &_C, const yarp::sig::Matrix &_I, double _A, double _D, double _Alpha, double _Offset, double _Min=-M_PI, double _Max=M_PI); + iDynLink(const double _m, const yarp::sig::Vector &_C, const yarp::sig::Matrix &_I, double _A, double _D, double _Alpha, double _Offset, double _Min=-iCub::ctrl::CTRL_PI, double _Max=iCub::ctrl::CTRL_PI); /** * Constructor, with initialization of kinematic and dynamic data @@ -505,7 +505,7 @@ class iDynLink : public iKin::iKinLink * @param _Min is the joint angle lower bound in [-pi,pi] (-pi by default) * @param _Max is the joint angle higher bound in [-pi,pi] (pi by default) */ - iDynLink(const double _m, const double _rCx, const double _rCy, const double _rCz, const double Ixx, const double Ixy, const double Ixz, const double Iyy, const double Iyz, const double Izz, double _A, double _D, double _Alpha, double _Offset, double _Min=-M_PI, double _Max=M_PI); + iDynLink(const double _m, const double _rCx, const double _rCy, const double _rCz, const double Ixx, const double Ixy, const double Ixz, const double Iyy, const double Iyz, const double Izz, double _A, double _D, double _Alpha, double _Offset, double _Min=-iCub::ctrl::CTRL_PI, double _Max=iCub::ctrl::CTRL_PI); /** * Copy constructor diff --git a/src/libraries/iDyn/src/iDyn.cpp b/src/libraries/iDyn/src/iDyn.cpp index f2963c8be9..7c581225ab 100644 --- a/src/libraries/iDyn/src/iDyn.cpp +++ b/src/libraries/iDyn/src/iDyn.cpp @@ -16,13 +16,16 @@ * Public License for more details */ -#include -#include -#include +#include +#include #include -#include #include +#include +#include +#include + + using namespace std; using namespace yarp::os; using namespace yarp::dev; diff --git a/src/libraries/iKin/CMakeLists.txt b/src/libraries/iKin/CMakeLists.txt index f5344e0845..c07e26dc21 100644 --- a/src/libraries/iKin/CMakeLists.txt +++ b/src/libraries/iKin/CMakeLists.txt @@ -35,6 +35,10 @@ if(ICUB_USE_IPOPT) add_definitions(${IPOPT_DEFINITIONS}) endif() +if(MSVC) + add_definitions(-D_USE_MATH_DEFINES) +endif() + add_library(${PROJECT_NAME} ${folder_source} ${folder_header}) target_link_libraries(${PROJECT_NAME} ctrlLib ${YARP_LIBRARIES}) diff --git a/src/libraries/iKin/include/iCub/iKin/iKinFwd.h b/src/libraries/iKin/include/iCub/iKin/iKinFwd.h index 44b9092215..8e6eafada1 100644 --- a/src/libraries/iKin/include/iCub/iKin/iKinFwd.h +++ b/src/libraries/iKin/include/iCub/iKin/iKinFwd.h @@ -140,7 +140,7 @@ class iKinLink * default). */ iKinLink(double _A, double _D, double _Alpha, double _Offset, - double _Min=-M_PI, double _Max=M_PI); + double _Min=-iCub::ctrl::CTRL_PI, double _Max=iCub::ctrl::CTRL_PI); /** * Creates a new Link from an already existing Link object. diff --git a/src/libraries/optimization/CMakeLists.txt b/src/libraries/optimization/CMakeLists.txt index 898094298d..ce9efa4379 100644 --- a/src/libraries/optimization/CMakeLists.txt +++ b/src/libraries/optimization/CMakeLists.txt @@ -24,6 +24,10 @@ include_directories(${PROJECT_SOURCE_DIR}/include ${YARP_INCLUDE_DIRS}) add_definitions(${IPOPT_DEFINITIONS}) +if(MSVC) + add_definitions(-D_USE_MATH_DEFINES) +endif() + add_library(${PROJECTNAME} ${folder_source} ${folder_header}) set_property(TARGET ${PROJECTNAME} APPEND_STRING PROPERTY LINK_FLAGS " ${IPOPT_LINK_FLAGS}") diff --git a/src/libraries/optimization/src/calibReference.cpp b/src/libraries/optimization/src/calibReference.cpp index c7a9a3e28b..d95a153a74 100644 --- a/src/libraries/optimization/src/calibReference.cpp +++ b/src/libraries/optimization/src/calibReference.cpp @@ -15,6 +15,7 @@ * Public License for more details */ +#include #include #include diff --git a/src/modules/iKinGazeCtrl/CMakeLists.txt b/src/modules/iKinGazeCtrl/CMakeLists.txt index 1a46e2483d..526458765d 100644 --- a/src/modules/iKinGazeCtrl/CMakeLists.txt +++ b/src/modules/iKinGazeCtrl/CMakeLists.txt @@ -28,6 +28,10 @@ include_directories(${PROJECT_SOURCE_DIR}/include ${IPOPT_INCLUDE_DIRS} ${YARP_INCLUDE_DIRS}) +if(MSVC) + add_definitions(-D_USE_MATH_DEFINES) +endif() + add_executable(${PROJECTNAME} ${folder_header} ${folder_source}) target_link_libraries(${PROJECTNAME} ctrlLib iKin ${YARP_LIBRARIES}) install(TARGETS ${PROJECTNAME} DESTINATION bin) diff --git a/src/modules/wholeBodyDynamics/CMakeLists.txt b/src/modules/wholeBodyDynamics/CMakeLists.txt index 51ff639e8d..e8255bec85 100644 --- a/src/modules/wholeBodyDynamics/CMakeLists.txt +++ b/src/modules/wholeBodyDynamics/CMakeLists.txt @@ -3,25 +3,25 @@ # Author: Matteo Fumagalli, Marco Randazzo # CopyPolicy: Released under the terms of the GNU GPL v2.0. - -SET(PROJECTNAME wholeBodyDynamics) +project(wholeBodyDynamics) -PROJECT(${PROJECTNAME}) +file(GLOB folder_source main.cpp observerThread.cpp) +file(GLOB folder_header observerThread.h) -FILE(GLOB folder_source main.cpp observerThread.cpp) -FILE(GLOB folder_header observerThread.h) +source_group("Source Files" FILES ${folder_source}) +source_group("Header Files" FILES ${folder_header}) -SOURCE_GROUP("Source Files" FILES ${folder_source}) -SOURCE_GROUP("Header Files" FILES ${folder_header}) - -INCLUDE_DIRECTORIES(${iDyn_INCLUDE_DIRS} +include_directories(${iDyn_INCLUDE_DIRS} ${YARP_INCLUDE_DIRS} ${skinDynLib_INCLUDE_DIRS}) -ADD_EXECUTABLE(${PROJECTNAME} ${folder_source} ${folder_header}) +if(MSVC) + add_definitions(-D_USE_MATH_DEFINES) +endif() -TARGET_LINK_LIBRARIES(${PROJECTNAME} iDyn - ${YARP_LIBRARIES} - skinDynLib) +add_executable(${PROJECT_NAME} ${folder_source} ${folder_header}) +target_link_libraries(${PROJECT_NAME} iDyn + ${YARP_LIBRARIES} + skinDynLib) +install(TARGETS ${PROJECT_NAME} DESTINATION bin) -INSTALL(TARGETS ${PROJECTNAME} DESTINATION bin) diff --git a/src/modules/wholeBodyDynamics/observerThread.cpp b/src/modules/wholeBodyDynamics/observerThread.cpp index e541b5aa95..8821991811 100644 --- a/src/modules/wholeBodyDynamics/observerThread.cpp +++ b/src/modules/wholeBodyDynamics/observerThread.cpp @@ -16,6 +16,11 @@ * Public License for more details */ +#include +#include +#include +#include + #include #include #include @@ -25,9 +30,6 @@ #include #include -#include -#include -#include #include "observerThread.h" using namespace yarp::os; diff --git a/src/tools/depth2kin/CMakeLists.txt b/src/tools/depth2kin/CMakeLists.txt index 5e39cd8fdc..422ac88911 100644 --- a/src/tools/depth2kin/CMakeLists.txt +++ b/src/tools/depth2kin/CMakeLists.txt @@ -35,6 +35,10 @@ include_directories(${PROJECT_SOURCE_DIR}/include ${learningMachine_INCLUDE_DIRS}) add_definitions(${IPOPT_DEFINITIONS}) +if(MSVC) + add_definitions(-D_USE_MATH_DEFINES) +endif() + add_executable(${PROJECTNAME} ${header_files} ${source_files} ${idl_files} ${doc_files}) set_property(TARGET ${PROJECTNAME} APPEND_STRING PROPERTY LINK_FLAGS " ${IPOPT_LINK_FLAGS}") target_link_libraries(${PROJECTNAME} ${YARP_LIBRARIES} diff --git a/src/tools/depth2kin/src/nlp.cpp b/src/tools/depth2kin/src/nlp.cpp index c4befc6a03..dd228e2c1b 100644 --- a/src/tools/depth2kin/src/nlp.cpp +++ b/src/tools/depth2kin/src/nlp.cpp @@ -15,6 +15,7 @@ * Public License for more details */ +#include #include #include #include diff --git a/src/tools/stereoCalib/src/stereoCalibThread.cpp b/src/tools/stereoCalib/src/stereoCalibThread.cpp index 8aef4416ee..cce6eb3115 100644 --- a/src/tools/stereoCalib/src/stereoCalibThread.cpp +++ b/src/tools/stereoCalib/src/stereoCalibThread.cpp @@ -101,7 +101,7 @@ bool stereoCalibThread::threadInit() for(size_t i=0; i