diff --git a/CMakeLists.txt b/CMakeLists.txt index 00890b3..5ae9310 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,179 +1,170 @@ 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 -#SET(PROJECT_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}/share/cmake/Modules") -#SET(SYSTEM_CMAKE_PATH "/usr/share/cmake/Modules") -#SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${LIBONCILLA_CMAKE_MODULE_PATH}" "${PROJECT_CMAKE_PATH}" "${SYSTEM_CMAKE_PATH}") 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) 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 "${PROJECT_NAME}Tests") SET(DTO_TEST_NAME "${DRIVER_TEST_NAME}DTO") 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(GTEST_DIR ${PROJECT_SOURCE_DIR}/3rdparty/gtest-1.5.0) SET(GTEST_INCLUDE_DIR ${GTEST_DIR}/include) SET(GMOCK_DIR ${PROJECT_SOURCE_DIR}/3rdparty/gmock-1.5.0) SET(GMOCK_INCLUDE_DIR ${GMOCK_DIR}/include) SET(GMOCK_LIBRARY_NAME "gmock") 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) ADD_SUBDIRECTORY(cmake) -IF(BUILD_HARDWARE_DRIVER) - INCLUDE_DIRECTORIES(SYSTEM ${LIBXML2_INCLUDE_DIR}) -ENDIF(BUILD_HARDWARE_DRIVER) - IF(BUILD_TESTS) ADD_SUBDIRECTORY(test) #ADD_SUBDIRECTORY(3rdparty) 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) # --- 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(${PROJECT_NAME}Config.cmake.in ${PROJECT_NAME}Config.cmake @ONLY) -INSTALL(FILES ${PROJECT_NAME}Config.cmake DESTINATION share/lib${LIBNAME}) +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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8cb6902..45ae094 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,37 +1,34 @@ -#INCLUDE_DIRECTORIES(BEFORE SYSTEM ${CMAKE_CURRENT_BINARY_DIR}) -#INCLUDE_DIRECTORIES(BEFORE SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}) -#INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/..) - # Configure config header CONFIGURE_FILE("config.h.in" "${PROJECT_NAME}Config.h") SET(ONCILLAHEADERS OncillaTrunk.h OncillaL01.h OncillaL2.h OncillaL3.h OncillaL4.h - Oncilla.h) + Oncilla.h + OncillaSynchronizer.h) SET(ONCILLASOURCES OncillaTrunk.cpp OncillaL01.cpp OncillaL2.cpp OncillaL3.cpp OncillaL4.cpp - Oncilla.cpp) + OncillaSynchronizer.cpp) ADD_LIBRARY(${LIBONCILLA_NAME} SHARED ${ONCILLASOURCES}) TARGET_LINK_LIBRARIES(${LIBONCILLA_NAME} ${RSC_LIBRARIES} ${RCI_LIBRARIES} ${LIBRARIES_LIBRARIES}) SET_TARGET_PROPERTIES(${LIBONCILLA_NAME} PROPERTIES VERSION ${LIBONCILLA_VERSION_STRING}) INSTALL(TARGETS ${LIBONCILLA_NAME} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) INSTALL_FILES_RECURSIVE(include/lib${LIBNAME} ONCILLAHEADERS) diff --git a/src/Oncilla.h b/src/Oncilla.h index 62f1d54..ee7b284 100644 --- a/src/Oncilla.h +++ b/src/Oncilla.h @@ -1,69 +1,66 @@ /* * Oncilla.h * - * Created on: 15 dŽc. 2011 + * Created on: 15 d�c. 2011 * Author: Alexandre Tuleu */ #ifndef LIBONCILLA_ONCILLA_H_ #define LIBONCILLA_ONCILLA_H_ - #include "OncillaL01.h" #include "OncillaL2.h" #include "OncillaL3.h" #include "OncillaL4.h" #include "OncillaTrunk.h" /* * */ /* * */ namespace cca { namespace rci { namespace driver { class Oncilla; typedef boost::shared_ptr OncillaPtr; class Oncilla { public: - enum Leg { - LEFT_FORE = 0, - RIGHT_FORE = 1, - LEFT_HIND = 2, - RIGHT_HIND = 3, - NUM_LEGS = 4 - }; - - Oncilla(); - virtual ~Oncilla(); + enum Leg { + LEFT_FORE = 0, + RIGHT_FORE = 1, + LEFT_HIND = 2, + RIGHT_HIND = 3, + NUM_LEGS = 4 + }; - OncillaL0Ptr getL0(Leg l); - OncillaL1Ptr getL1(Leg l); - OncillaL2Ptr getL2(Leg l); - OncillaL3Ptr getL3(Leg l); - OncillaL4Ptr getL4(Leg l); + Oncilla(); + virtual ~Oncilla(); - OncillaTrunkPtr getTrunk(); + OncillaL0Ptr getL0(Leg l); + OncillaL1Ptr getL1(Leg l); + OncillaL2Ptr getL2(Leg l); + OncillaL3Ptr getL3(Leg l); + OncillaL4Ptr getL4(Leg l); + OncillaTrunkPtr getTrunk(); -private : - void init(); +private: + void init(); - std::vector d_l0s; - std::vector d_l1s; - std::vector d_l2s; - std::vector d_l3s; - std::vector d_l4s; + std::vector d_l0s; + std::vector d_l1s; + std::vector d_l2s; + std::vector d_l3s; + std::vector d_l4s; - OncillaPtr d_trunk; + OncillaPtr d_trunk; }; - } } } #endif /* LIBONCILLA_ONCILLA_H_ */ diff --git a/src/OncillaL01.cpp b/src/OncillaL01.cpp index 55b24fb..0671797 100644 --- a/src/OncillaL01.cpp +++ b/src/OncillaL01.cpp @@ -1,99 +1,97 @@ #include "OncillaL01.h" using namespace std; -namespace cca { namespace rci { -namespace driver { +namespace oncilla { OncillaL1::OncillaL1(const std::string & name) : ResourceNode(name), Controlled(), Sensing(), PositionControlled(), PositionSensing(), TorqueControlled(), ImpedanceControlled() { this->_dimension = 2; // Two encoder values - should always be the same } 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) { throw std::runtime_error("Not yet implemented."); } bool OncillaL1::setJointTorque(JointTorquesPtr torque) { throw std::runtime_error("Not yet implemented."); } bool OncillaL1::setJointImpedance(JointImpedancePtr imped) { throw std::runtime_error("Not yet implemented."); } JointAnglesPtr OncillaL1::getLastPositionCommand() const { // TODO: The second part f this condition shouldn`t be necessary if (this->_lastCommandedPosition && this->_lastCommandedPosition.get()) { //std::cout << this->_lastCommandedPosition->print(); return this->_lastCommandedPosition; } // No command set yet. Returning current joint values instead return this->_latestJointPosition; } OncillaL1::~OncillaL1() { } std::string OncillaL1::print() const { ostringstream outstream(ostringstream::out); outstream.precision(3); // Precision when printing double values outstream << "" << endl; return outstream.str(); } /** Oncilla Hip Transverse **/ OncillaL0::OncillaL0(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 { // TODO: The second part f this condition shouldn`t be necessary if (this->_lastCommandedPosition && this->_lastCommandedPosition.get()) { //std::cout << this->_lastCommandedPosition->print(); return this->_lastCommandedPosition; } return JointAnglesPtr(); } OncillaL0::~OncillaL0() { } std::string OncillaL0::print() const { ostringstream outstream(ostringstream::out); outstream.precision(3); // Precision when printing double values outstream << "" << endl; return outstream.str(); } } } -} diff --git a/src/OncillaL01.h b/src/OncillaL01.h index 13dec62..c3f373d 100644 --- a/src/OncillaL01.h +++ b/src/OncillaL01.h @@ -1,146 +1,144 @@ #pragma once #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include -namespace cca { namespace rci { -namespace driver { +namespace oncilla { class OncillaL1; typedef boost::shared_ptr OncillaL1Ptr; /** * Node class, representing the hip node of the quadruped robot. * * @todo In case of simulation, this node can also sense the power consumption. */ class OncillaL1: public rci::ResourceNode, public rci::Controlled, public rci::Sensing, public rci::PositionControlled, public rci::PositionSensing, // Two encoder values public rci::VelocityControlled, public rci::TorqueControlled, public rci::ImpedanceControlled { public: /** * Special constructor to also link to webots */ OncillaL1(const std::string & name = "Oncilla Hip"); virtual ~OncillaL1(); /** * Returns, if controller is converged. * @return True, if controller is converged after last command. */ bool isConverged() const; /** * Commanding a joint position. * @param position Position command * @return Return, if successfull. (e.g. not exceeding joint limits) * @todo Check for correct control mode */ bool setJointPosition(JointAnglesPtr position); /** * Returns current joint position. * @return Current joint position */ virtual JointAnglesPtr getJointPosition() const; /** * Commanding a joint velocity. * @param position Position command * @return Return, if successfull. (e.g. not exceeding joint limits) * @todo Check for correct control mode */ - virtual bool setJointVelocity(cca::rci::JointVelocitiesPtr vel); + virtual bool setJointVelocity(rci::JointVelocitiesPtr vel); /** * Returns current joint torque. * @return Current joint torque */ virtual bool setJointTorque(JointTorquesPtr torque); /** * Returns current joint torque. * @return Current joint torque */ virtual bool setJointImpedance(JointImpedancePtr imped); /** * Returns latest position command. Note, that this is the latest valid * commanded position. If the position command exceeds limits and is * therefore rejected, it .. */ virtual JointAnglesPtr getLastPositionCommand() const; /** * Print */ std::string print() const; }; class OncillaL0; typedef boost::shared_ptr OncillaL0Ptr; /** * Node class, representing the hip node of the quadruped robot. * @todo In case of simulation, this node can also sense the power consumption. */ class OncillaL0: public rci::ResourceNode, public rci::Controlled, public rci::PositionControlled { public: /** * Special constructor to also link to webots */ OncillaL0(std::string name = "Oncilla Hip"); virtual ~OncillaL0(); /** * Returns, if controller is converged. * @return True, if controller is converged after last command. */ bool isConverged() const; /** * Commanding a joint position. * @param position Position command * @return Return, if successfull. (e.g. not exceeding joint limits) * @todo Check for correct control mode */ bool setJointPosition(JointAnglesPtr position); /** * Returns latest position command. Note, that this is the latest valid * commanded position. If the position command exceeds limits and is * therefore rejected, it .. */ virtual JointAnglesPtr getLastPositionCommand() const; /** * Print */ std::string print() const; }; } } -} diff --git a/src/OncillaL2.cpp b/src/OncillaL2.cpp index 93e0098..0537670 100644 --- a/src/OncillaL2.cpp +++ b/src/OncillaL2.cpp @@ -1,68 +1,66 @@ #include "OncillaL2.h" using namespace std; using namespace boost; -namespace cca { namespace rci { -namespace driver { +namespace oncilla { OncillaL2::OncillaL2(const std::string & name) : ResourceNode(name), Controlled(), Sensing(), PositionControlled(), PositionSensing(), VelocityControlled(), TorqueControlled(), ImpedanceControlled() { // 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) { throw std::runtime_error("Not yet implemented."); } bool OncillaL2::setJointImpedance(JointImpedancePtr imped) { throw std::runtime_error("Not yet implemented."); } bool OncillaL2::setJointVelocity(JointVelocitiesPtr vel) { 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/OncillaL2.h b/src/OncillaL2.h index b60a819..2c3869f 100644 --- a/src/OncillaL2.h +++ b/src/OncillaL2.h @@ -1,97 +1,95 @@ #pragma once #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include -namespace cca { namespace rci { -namespace driver { +namespace oncilla { class OncillaL2; typedef boost::shared_ptr OncillaL2Ptr; /** * Node class, representing the knee node of the quadruped robot. * @todo In case of simulation, this node can also sense the power consumption. */ class OncillaL2: public rci::ResourceNode, public rci::Controlled, public rci::Sensing, public rci::PositionControlled, public rci::PositionSensing, public rci::VelocityControlled, public rci::TorqueControlled, public rci::ImpedanceControlled { public: OncillaL2(const std::string & name = "Oncilla Knee"); virtual ~OncillaL2(); /** * Returns, if controller is converged. * @return True, if controller is converged after last command. */ bool isConverged() const; /** * Commanding a joint position. * @param position Position command * @return Return, if successfull. (e.g. not exceeding joint limits) * @todo Check for correct control mode */ bool setJointPosition(JointAnglesPtr position); /** * Returns current joint position. * @return Current joint position */ virtual JointAnglesPtr getJointPosition() const; /** * Commanding a joint velocity. * @param position Velocity command * @return Return, if successfull. (e.g. not exceeding joint limits) * @todo Check for correct control mode */ bool setJointVelocity(JointVelocitiesPtr vel); /** * Commanding a joint velocity. * @param position Velocity command * @return Return, if successfull. (e.g. not exceeding joint limits) * @todo Check for correct control mode */ bool setJointImpedance(JointImpedancePtr imped); /** * Commanding a joint torque. * @param position Torque command * @return Return, if successfull. (e.g. not exceeding joint limits) * @todo Check for correct control mode */ - virtual bool setJointTorque(cca::rci::JointTorquesPtr torques); + virtual bool setJointTorque(rci::JointTorquesPtr torques); /** * Returns latest position command. Note, that this is the latest valid * commanded position. If the position command exceeds limits and is * therefore rejected, it .. */ virtual JointAnglesPtr getLastPositionCommand() const; /** * Print */ std::string print() const; }; } } -} diff --git a/src/OncillaL3.cpp b/src/OncillaL3.cpp index d2ecd86..fd0adc2 100644 --- a/src/OncillaL3.cpp +++ b/src/OncillaL3.cpp @@ -1,30 +1,28 @@ #include "OncillaL3.h" using namespace std; -namespace cca { namespace rci { -namespace driver { +namespace oncilla { OncillaL3::OncillaL3(const std::string & name) : rci::ResourceNode(name), rci::Sensing(), rci::PositionSensing() { this->_dimension = 1; } JointAnglesPtr OncillaL3::getJointPosition() const { throw std::runtime_error("Not yet implemented."); } OncillaL3::~OncillaL3() { } std::string OncillaL3::print() const { ostringstream outstream(ostringstream::out); outstream.precision(3); // Precision when printing double values outstream << "" << endl; return outstream.str(); } } } -} diff --git a/src/OncillaL3.h b/src/OncillaL3.h index 2e35c85..caaf629 100644 --- a/src/OncillaL3.h +++ b/src/OncillaL3.h @@ -1,47 +1,45 @@ #pragma once #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include -namespace cca { namespace rci { -namespace driver { +namespace oncilla { class OncillaL3; typedef boost::shared_ptr OncillaL3Ptr; /** * Node class, representing the foot/ankle of the quadruped robot. Not actuated, * but force sensing. */ class OncillaL3: public rci::ResourceNode, public rci::Sensing, public rci::PositionSensing { public: OncillaL3(const std::string & name = "Oncilla Ankle"); virtual ~OncillaL3(); /** * Returns contact forces */ JointAnglesPtr getJointPosition() const; /** * Print */ std::string print() const; }; } } -} diff --git a/src/OncillaL4.cpp b/src/OncillaL4.cpp index a709959..6383dca 100644 --- a/src/OncillaL4.cpp +++ b/src/OncillaL4.cpp @@ -1,30 +1,28 @@ #include "OncillaL4.h" using namespace std; -namespace cca { namespace rci { -namespace driver { +namespace oncilla { OncillaL4::OncillaL4(const std::string & name) : rci::ResourceNode(name), rci::Sensing(), rci::ForceSensing() { this->_dimension = 1; } 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(); } } } -} diff --git a/src/OncillaL4.h b/src/OncillaL4.h index c6f2e7a..1b1ec24 100644 --- a/src/OncillaL4.h +++ b/src/OncillaL4.h @@ -1,47 +1,45 @@ #pragma once #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include -namespace cca { namespace rci { -namespace driver { +namespace oncilla { class OncillaL4; typedef boost::shared_ptr OncillaL4Ptr; /** * Node class, representing the foot of the quadruped robot. Not actuated, * but force sensing. */ class OncillaL4: public rci::ResourceNode, public rci::Sensing, public rci::ForceSensing { public: OncillaL4(const std::string & name = "Oncilla Foot"); virtual ~OncillaL4(); /** * Returns contact forces */ ForcesPtr getForces() const; /** * Print */ std::string print() const; }; } } -} diff --git a/src/OncillaSynchronizer.cpp b/src/OncillaSynchronizer.cpp new file mode 100644 index 0000000..09e7a87 --- /dev/null +++ b/src/OncillaSynchronizer.cpp @@ -0,0 +1,16 @@ +#include "OncillaSynchronizer.h" + +using namespace std; + +namespace rci { +namespace oncilla { + +OncillaSynchronizer::OncillaSynchronizer(const std::string &sname) : + Synchronizer(sname), _onlyReceive(true) { +} + +OncillaSynchronizer::~OncillaSynchronizer() { +} + +} +} diff --git a/src/OncillaSynchronizer.h b/src/OncillaSynchronizer.h new file mode 100644 index 0000000..1ef87b4 --- /dev/null +++ b/src/OncillaSynchronizer.h @@ -0,0 +1,85 @@ +#pragma once + +#include +#include +#include + +#include + +#include "OncillaTrunk.h" +#include "OncillaL01.h" +#include "OncillaL2.h" +#include "OncillaL3.h" +#include "OncillaL4.h" + +namespace rci { +namespace oncilla { + +class OncillaSynchronizer; +typedef boost::shared_ptr OncillaSynchronizerPtr; + +/** + * OncillaSynchronizer + * Different OncillaSynchronizers may be for example: + * * Update with a given frequency + * ** Send data every time + * ** Send only if new data + * * Update only if new data (event-based) + * * Triggered from robot side (e.g. FRI) + */ +class OncillaSynchronizer : public Synchronizer { +public: + OncillaSynchronizer(const std::string &name); + virtual ~OncillaSynchronizer(); + + /** + * Registers a trunk node. + */ + virtual void registerTrunkNode(unsigned int index, OncillaTrunkPtr node) = 0; + + /** + * Registers an L0 node. + */ + virtual void registerL0Node(unsigned int index, OncillaL0Ptr node) = 0; + + /** + * Registers an L1 node. + */ + virtual void registerL1Node(unsigned int index, OncillaL1Ptr node) = 0; + + /** + * Registers an L2 node. + */ + virtual void registerL2Node(unsigned int index, OncillaL2Ptr node) = 0; + + /** + * Registers an L3 node. + */ + virtual void registerL3Node(unsigned int index, OncillaL3Ptr node) = 0; + + /** + * Registers an L4 node. + */ + virtual void registerL4Node(unsigned int index, OncillaL4Ptr node) = 0; + + /** + * + */ + friend std::ostream + & operator<<(std::ostream& os, const OncillaSynchronizer& val); + +protected: + + /** + * Only true for the first time + */ + bool _onlyReceive; + + /** + * + */ + std::string name; +}; + +} +} diff --git a/src/OncillaTrunk.cpp b/src/OncillaTrunk.cpp index 5a3f98f..b8e46a5 100644 --- a/src/OncillaTrunk.cpp +++ b/src/OncillaTrunk.cpp @@ -1,38 +1,36 @@ #include "OncillaTrunk.h" using namespace std; -namespace cca { namespace rci { -namespace driver { +namespace oncilla { OncillaTrunk::OncillaTrunk(const std::string & name) : ResourceNode(name), Sensing(), PoseSensing() { this->_dimension = 1; } PosePtr OncillaTrunk::getAbsolutePose() const { throw std::runtime_error("Not yet implemented."); } PosePtr OncillaTrunk::getDisplacement() const { throw std::runtime_error("Not yet implemented."); } PosePtr OncillaTrunk::getAcceleration() const { throw std::runtime_error("Not yet implemented."); } OncillaTrunk::~OncillaTrunk() { } std::string OncillaTrunk::print() const { ostringstream outstream(ostringstream::out); outstream.precision(3); // Precision when printing double values outstream << "" << endl; return outstream.str(); } } } -} diff --git a/src/OncillaTrunk.h b/src/OncillaTrunk.h index bf372c2..74540cc 100644 --- a/src/OncillaTrunk.h +++ b/src/OncillaTrunk.h @@ -1,57 +1,55 @@ #pragma once #include #include -#include -#include -#include -#include +#include +#include +#include +#include -namespace cca { namespace rci { -namespace driver { +namespace oncilla { class OncillaTrunk; typedef boost::shared_ptr OncillaTrunkPtr; /** * Node class, representing the quadruped trunk, including pose sensing. */ class OncillaTrunk: public rci::ResourceNode, - public rci::Sensing, - public rci::PoseSensing { + public Sensing, + public PoseSensing { public: OncillaTrunk(const std::string & name = "Oncilla Trunk"); virtual ~OncillaTrunk(); /** * Returns current pose. * @return Current pose */ virtual PosePtr getAbsolutePose() const; /** * Returns current displacement. * @return Current pose */ virtual PosePtr getDisplacement() const; /** * Returns current translational and rotational acceleration. * @return Current pose */ virtual PosePtr getAcceleration() const; /** * Print */ std::string print() const; }; } } -} diff --git a/src/config.h.in b/src/config.h.in index ddf477d..8582120 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -1,6 +1,3 @@ #pragma once #define DF_DEBUG 0 -#define DF_VERBOSITY 0 - -#define PREFIX "${CMAKE_INSTALL_PREFIX}"