diff --git a/CMakeLists.txt b/CMakeLists.txt index 43d33bf..322af91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,171 +1,172 @@ PROJECT(liboncilla C CXX) CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET(LIBNAME "oncilla") SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE) SET(LIBONCILLA_CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # CMake module path and modules FIND_PACKAGE(RSC REQUIRED) SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${RSC_CMAKE_MODULE_PATH}") MESSAGE(STATUS "RSC version: ${RSC_VERSION}") INCLUDE(CheckIncludeFileCXX) INCLUDE(InstallFilesRecursive) INCLUDE(EnableCoverageReport) INCLUDE(EnableSlocCount) INCLUDE(GenerateDoxygen) INCLUDE(GenerateCppcheck) INCLUDE(PedanticCompilerWarnings) FIND_PACKAGE(PkgConfig REQUIRED) SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # --- user options --- OPTION(BUILD_TESTS "Decide whether unit-tests are built" ON) OPTION(BUILD_EXAMPLES "Decide whether the examples are built" ON) OPTION(BUILD_DOCS "Decide whether the docygen documentation is built" OFF) # Dependencies FIND_PACKAGE(Threads REQUIRED) MESSAGE(STATUS "Threading library: ${CMAKE_THREAD_LIBS_INIT}") set(OLD_CXX_FLAGS ${CMAKE_CXX_FLAGS}) FIND_PACKAGE(NemoMath REQUIRED) MESSAGE(STATUS "NemoMath version: ${NemoMath_VERSION}") set(CMAKE_CXX_FLAGS ${OLD_CXX_FLAGS}) FIND_PACKAGE(RCI REQUIRED) MESSAGE(STATUS "RCI version: ${RCI_VERSION}") # --- global definitions --- SET(LIBONCILLA_NAME "${LIBNAME}") SET(DRIVER_TEST_NAME "OncillaTest") SET(NODE_TEST_NAME "${DRIVER_TEST_NAME}Nodes") SET(LIBONCILLA_VERSION_MAJOR 0) SET(LIBONCILLA_VERSION_MINOR 2) SET(LIBONCILLA_VERSION_PATCH 0) SET(LIBONCILLA_VERSION_STRING "${LIBONCILLA_VERSION_MAJOR}.${LIBONCILLA_VERSION_MINOR}.${LIBONCILLA_VERSION_PATCH}") SET(LIBONCILLA_CMAKE_MODULE_PATH "share/cmake/Modules") SET(OUTPUT_PATH ${PROJECT_BINARY_DIR}/build) SET(ARCHIVE_OUTPUT_PATH ${OUTPUT_PATH}) SET(LIBRARY_OUTPUT_PATH ${OUTPUT_PATH}) SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_PATH}) # --- dependency handling --- IF(BUILD_DOCS) FIND_PACKAGE(Doxygen) ENDIF() # Includes INCLUDE_DIRECTORIES(BEFORE src ${PROJECT_BINARY_DIR}/src) message(STATUS ${RSC_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(SYSTEM ${RCI_INCLUDE_DIRS} ${RSC_INCLUDE_DIRS} ${NemoMath_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${LIBRARIES_INCLUDE_DIRS}) #INCLUDE_DIRECTORIES(BEFORE SYSTEM ${PROTOBUF_INCLUDE_DIR} ${RST_INCLUDE_DIRS}) LINK_DIRECTORIES(${RCI_LIBRARY_DIR} ${LIBRARIES_LIBRARY_DIRS}) ADD_DEFINITIONS(${NEMOMATH_DEFINITIONS}) ADD_SUBDIRECTORY(src) IF(BUILD_TESTS) ENABLE_TESTING() INCLUDE(ProvideGoogleMock) MESSAGE(STATUS "Building tests - deactivate by adapting BUILD_TESTS") IF(GMOCK_AVAILABLE) ADD_SUBDIRECTORY(test) ELSE() MESSAGE(WARNING "Could not build unit tests even though desired because Google Mock could not be installed.") ENDIF() ENDIF() #IF(BUILD_EXAMPLES) # ADD_SUBDIRECTORY(examples) #ENDIF() # --- cmake config file --- SET(LIB_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) IF(CMAKE_LINK_LIBRARY_SUFFIX) SET(LIB_SUFFIX ${CMAKE_LINK_LIBRARY_SUFFIX}) ENDIF() # --- pkgconfig file --- -CONFIGURE_FILE(lib${LIBONCILLA_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/lib${LIBONCILLA_NAME}.pc @ONLY) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${LIBONCILLA_NAME}.pc DESTINATION lib/pkgconfig) +set(PKG_CONFIG_FILE lib${LIBONCILLA_NAME}-${LIBONCILLA_VERSION_MAJOR}.pc) +CONFIGURE_FILE(lib${LIBONCILLA_NAME}.pc.in ${PKG_CONFIG_FILE} @ONLY) +INSTALL(FILES ${PKG_CONFIG_FILE} DESTINATION lib/pkgconfig) # --- cmake config file --- SET(LIB_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) IF(CMAKE_LINK_LIBRARY_SUFFIX) SET(LIB_SUFFIX ${CMAKE_LINK_LIBRARY_SUFFIX}) ENDIF() CONFIGURE_FILE(${CMAKE_PROJECT_NAME}Config.cmake.in ${CMAKE_PROJECT_NAME}Config.cmake @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake DESTINATION share/lib${LIBNAME}) # --- documentation generation --- IF(BUILD_DOCS) IF(DOXYGEN_FOUND) SET(API_DIR "${CMAKE_BINARY_DIR}/doc") SET(SOURCE_DIR "${CMAKE_SOURCE_DIR}/src") SET(DOXYFILE "${CMAKE_BINARY_DIR}/Doxyfile") SET(WARNFILE "${CMAKE_BINARY_DIR}/doxygen-warn.log") CONFIGURE_FILE(Doxyfile.in ${DOXYFILE}) ADD_CUSTOM_COMMAND(OUTPUT ${API_DIR} DEPENDS ${DOXYFILE} COMMAND ${DOXYGEN_EXECUTABLE} ARGS ${DOXYFILE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) ADD_CUSTOM_TARGET(doc DEPENDS ${API_DIR}) INSTALL(CODE "execute_process(COMMAND ${CMAKE_BUILD_TOOL} doc)") INSTALL(DIRECTORY ${API_DIR} DESTINATION share/lib${LIBNAME}) ENDIF() ENDIF(BUILD_DOCS) # --- coverage --- IF(BUILD_TESTS) ENABLE_COVERAGE_REPORT(TARGETS ${LIBONCILLA_NAME} TESTS ${DTO_TEST_NAME} ${INTEGRATED_TEST_NAME} FILTER "*3rdparty*" "*test/*") ENDIF(BUILD_TESTS) # --- sloccount --- ENABLE_SLOCCOUNT(FOLDERS src test examples) # --- cppcheck --- GENERATE_CPPCHECK(SOURCES src test examples "${CMAKE_CURRENT_BINARY_DIR}/src" "${CMAKE_CURRENT_BINARY_DIR}/test" "${CMAKE_CURRENT_BINARY_DIR}/examples" ENABLE_IDS style) # --- package --- INCLUDE(CheckLSBTypes) -SET(CPACK_PACKAGE_VERSION_MAJOR ${LIBONCILLA_VERSION_MAJOR}) -SET(CPACK_PACKAGE_VERSION_MINOR ${LIBONCILLA_VERSION_MINOR}) -SET(CPACK_PACKAGE_VERSION_PATCH ${LIBONCILLA_VERSION_PATCH}) -SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") -SET(CPACK_PACKAGE_FILE_NAME ${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}_${LSB_CODENAME}_${LSB_PROCESSOR_ARCH}) - -SET(CPACK_GENERATOR "TGZ") -SET(CPACK_PACKAGE_VENDOR "CoR-Lab Bielefeld University") - -IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") - SET(CPACK_GENERATOR "${CPACK_GENERATOR};DEB") - SET(CPACK_DEBIAN_PACKAGE_NAME "amarsi-liboncilla") - SET(CPACK_DEBIAN_PACKAGE_VERSION ${LIBONCILLA_VERSION_MAJOR}.${LIBONCILLA_VERSION_MINOR}.${LIBONCILLA_VERSION_PATCH}) - SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Arne Nordmann (anordman@cor-lab.uni-bielefeld.de)") - SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "AMARSi RCI representations of the AMARSi quadruped robot 'Oncilla'.") - SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") - SET(CPACK_DEBIAN_PACKAGE_SECTION "devel") - SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "amarsi-rci-all") - SET(CPACK_DEBIAN_PACKAGE_SUGGESTS "cmake, cmake-data, doxygen, lcov, cppcheck, sloccount") -ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") - -INCLUDE(CPack) +# SET(CPACK_PACKAGE_VERSION_MAJOR ${LIBONCILLA_VERSION_MAJOR}) +# SET(CPACK_PACKAGE_VERSION_MINOR ${LIBONCILLA_VERSION_MINOR}) +# SET(CPACK_PACKAGE_VERSION_PATCH ${LIBONCILLA_VERSION_PATCH}) +# SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") +# SET(CPACK_PACKAGE_FILE_NAME ${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}_${LSB_CODENAME}_${LSB_PROCESSOR_ARCH}) + +# SET(CPACK_GENERATOR "TGZ") +# SET(CPACK_PACKAGE_VENDOR "CoR-Lab Bielefeld University") + +# IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # SET(CPACK_GENERATOR "${CPACK_GENERATOR};DEB") + # SET(CPACK_DEBIAN_PACKAGE_NAME "amarsi-liboncilla") + # SET(CPACK_DEBIAN_PACKAGE_VERSION ${LIBONCILLA_VERSION_MAJOR}.${LIBONCILLA_VERSION_MINOR}.${LIBONCILLA_VERSION_PATCH}) + # SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Arne Nordmann (anordman@cor-lab.uni-bielefeld.de)") + # SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "AMARSi RCI representations of the AMARSi quadruped robot 'Oncilla'.") + # SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") + # SET(CPACK_DEBIAN_PACKAGE_SECTION "devel") + # SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) + # SET(CPACK_DEBIAN_PACKAGE_DEPENDS "amarsi-rci-all") + # SET(CPACK_DEBIAN_PACKAGE_SUGGESTS "cmake, cmake-data, doxygen, lcov, cppcheck, sloccount") +# ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + +# INCLUDE(CPack) diff --git a/src/OncillaL01.cpp b/src/OncillaL01.cpp index 50c934f..74c0b23 100644 --- a/src/OncillaL01.cpp +++ b/src/OncillaL01.cpp @@ -1,102 +1,102 @@ #include "OncillaL01.h" using namespace std; namespace rci { namespace oncilla { OncillaL0::OncillaL0(const std::string &name) : ResourceNode(name), Controlled(), PositionControlled() { } bool OncillaL0::isConverged() const { return false; } bool OncillaL0::setJointPosition(JointAnglesPtr position) { // Successfull this->_lastCommandedPosition = position; return true; } JointAnglesPtr OncillaL0::getLastPositionCommand() const { if (this->_lastCommandedPosition) { return this->_lastCommandedPosition; } throw runtime_error("No position command received yet."); } OncillaL0::~OncillaL0() { } std::string OncillaL0::print() const { ostringstream outstream(ostringstream::out); outstream.precision(3); // Precision when printing double values outstream << "" << endl; return outstream.str(); } OncillaL1::OncillaL1(OncillaSynchronizer &s, const std::string &name) : ResourceNode(name), Controlled(), Sensing(), PositionControlled(), PositionSensing(), TorqueControlled(), ImpedanceControlled(), synchronizer( s) { } bool OncillaL1::isConverged() const { throw std::runtime_error("Not yet implemented."); return false; } bool OncillaL1::setJointPosition(JointAnglesPtr position) { // Successfull this->_lastCommandedPosition = position; return true; } JointAnglesPtr OncillaL1::getJointPosition() const { return this->_latestJointPosition; } -bool OncillaL1::setJointVelocity(JointVelocitiesPtr vel) { +bool OncillaL1::setJointVelocity(JointVelocitiesPtr ) { throw std::runtime_error("Not yet implemented."); } -bool OncillaL1::setJointTorque(JointTorquesPtr torque) { +bool OncillaL1::setJointTorque(JointTorquesPtr ) { throw std::runtime_error("Not yet implemented."); } -bool OncillaL1::setJointImpedance(JointImpedancePtr imped) { +bool OncillaL1::setJointImpedance(JointImpedancePtr ) { if (this->synchronizer.tooBusy()) { throw std::runtime_error( "Synchronizer has to be switched off to change JointImpedance."); } else { throw std::runtime_error("Not yet implemented."); } } JointAnglesPtr OncillaL1::getLastPositionCommand() const { if (this->_lastCommandedPosition) { return this->_lastCommandedPosition; } // If we don`t have a command yet, we return the latest sensor value if (this->_latestJointPosition) { // TODO: Log return this->_latestJointPosition; } throw runtime_error("No position command received yet."); } OncillaL1::~OncillaL1() { } std::string OncillaL1::print() const { ostringstream outstream(ostringstream::out); outstream.precision(3); // Precision when printing double values outstream << "" << endl; return outstream.str(); } } } diff --git a/src/OncillaL2.cpp b/src/OncillaL2.cpp index fb35997..40cafde 100644 --- a/src/OncillaL2.cpp +++ b/src/OncillaL2.cpp @@ -1,77 +1,77 @@ #include "OncillaL2.h" using namespace std; using namespace boost; namespace rci { namespace oncilla { OncillaL2::OncillaL2(OncillaSynchronizer &s, const std::string &name) : ResourceNode(name) , Controlled() , Sensing() , PositionControlled() - , PositionSensing() + , PositionSensing() , VelocityControlled() , TorqueControlled() , ImpedanceControlled() , synchronizer(s) { // Two encoder values - difference is due to passive compliance this->dimension = 2; } bool OncillaL2::isConverged() const { return false; } bool OncillaL2::setJointPosition(JointAnglesPtr position) { // Successfull // std::cerr << "[OncillaKnee] " << position << std::endl; this->_lastCommandedPosition = position; return true; } JointAnglesPtr OncillaL2::getJointPosition() const { return this->_latestJointPosition; } OncillaL2::~OncillaL2() { } std::string OncillaL2::print() const { ostringstream outstream(ostringstream::out); outstream.precision(3); // Precision when printing double values outstream << "" << endl; return outstream.str(); } -bool OncillaL2::setJointTorque(JointTorquesPtr torques) { +bool OncillaL2::setJointTorque(JointTorquesPtr ) { throw std::runtime_error("Not yet implemented."); } -bool OncillaL2::setJointImpedance(JointImpedancePtr imped) { +bool OncillaL2::setJointImpedance(JointImpedancePtr ) { if (this->synchronizer.tooBusy()) { throw std::runtime_error( "Synchronizer has to be switched off to change JointImpedance."); } else { throw std::runtime_error("Not yet implemented."); } } -bool OncillaL2::setJointVelocity(JointVelocitiesPtr vel) { +bool OncillaL2::setJointVelocity(JointVelocitiesPtr ) { throw std::runtime_error("Not yet implemented."); } JointAnglesPtr OncillaL2::getLastPositionCommand() const { // TODO: The second part f this condition shouldn`t be necessary if (!this->_lastCommandedPosition || !this->_lastCommandedPosition.get()) { // No command set yet. Returning current joint values instead // FIXME: Instead of return current position set command to current position return this->_latestJointPosition; } return this->_lastCommandedPosition; } } } diff --git a/src/OncillaL4.cpp b/src/OncillaL4.cpp index c02f0e5..1a32e50 100644 --- a/src/OncillaL4.cpp +++ b/src/OncillaL4.cpp @@ -1,28 +1,29 @@ #include "OncillaL4.h" using namespace std; namespace rci { namespace oncilla { OncillaL4::OncillaL4(const std::string & name) : rci::ResourceNode(name) , rci::Sensing() , rci::ForceSensing() { } ForcesPtr OncillaL4::getForces() const { + throw std::runtime_error("Not yet implemented."); } OncillaL4::~OncillaL4() { } std::string OncillaL4::print() const { ostringstream outstream(ostringstream::out); outstream.precision(3); // Precision when printing double values outstream << "" << endl; return outstream.str(); } } }