diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e10f14a..8cb6902 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,35 +1,37 @@ #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 - OncillaHip.h - OncillaKnee.h - OncillaAnkle.h - OncillaFoot.h) + OncillaL01.h + OncillaL2.h + OncillaL3.h + OncillaL4.h + Oncilla.h) SET(ONCILLASOURCES OncillaTrunk.cpp - OncillaHip.cpp - OncillaKnee.cpp - OncillaAnkle.cpp - OncillaFoot.cpp) + OncillaL01.cpp + OncillaL2.cpp + OncillaL3.cpp + OncillaL4.cpp + Oncilla.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/OncillaHip.cpp b/src/OncillaL01.cpp similarity index 64% rename from src/OncillaHip.cpp rename to src/OncillaL01.cpp index 286ef96..55b24fb 100644 --- a/src/OncillaHip.cpp +++ b/src/OncillaL01.cpp @@ -1,99 +1,99 @@ -#include "OncillaHip.h" +#include "OncillaL01.h" using namespace std; namespace cca { namespace rci { namespace driver { -OncillaHipSagittal::OncillaHipSagittal(const std::string & name) : +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 OncillaHipSagittal::isConverged() const { +bool OncillaL1::isConverged() const { throw std::runtime_error("Not yet implemented."); return false; } -bool OncillaHipSagittal::setJointPosition(JointAnglesPtr position) { +bool OncillaL1::setJointPosition(JointAnglesPtr position) { // Successfull this->_lastCommandedPosition = position; return true; } -JointAnglesPtr OncillaHipSagittal::getJointPosition() const { +JointAnglesPtr OncillaL1::getJointPosition() const { return this->_latestJointPosition; } -bool OncillaHipSagittal::setJointVelocity(JointVelocitiesPtr vel) { +bool OncillaL1::setJointVelocity(JointVelocitiesPtr vel) { throw std::runtime_error("Not yet implemented."); } -bool OncillaHipSagittal::setJointTorque(JointTorquesPtr torque) { +bool OncillaL1::setJointTorque(JointTorquesPtr torque) { throw std::runtime_error("Not yet implemented."); } -bool OncillaHipSagittal::setJointImpedance(JointImpedancePtr imped) { +bool OncillaL1::setJointImpedance(JointImpedancePtr imped) { throw std::runtime_error("Not yet implemented."); } -JointAnglesPtr OncillaHipSagittal::getLastPositionCommand() const { +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; } -OncillaHipSagittal::~OncillaHipSagittal() { +OncillaL1::~OncillaL1() { } -std::string OncillaHipSagittal::print() const { +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 **/ -OncillaHipTransverse::OncillaHipTransverse(std::string name) : +OncillaL0::OncillaL0(std::string name) : ResourceNode(name), Controlled(), PositionControlled() { } -bool OncillaHipTransverse::isConverged() const { +bool OncillaL0::isConverged() const { return false; } -bool OncillaHipTransverse::setJointPosition(JointAnglesPtr position) { +bool OncillaL0::setJointPosition(JointAnglesPtr position) { // Successfull this->_lastCommandedPosition = position; return true; } -JointAnglesPtr OncillaHipTransverse::getLastPositionCommand() const { +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(); } -OncillaHipTransverse::~OncillaHipTransverse() { +OncillaL0::~OncillaL0() { } -std::string OncillaHipTransverse::print() const { +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/OncillaHip.h b/src/OncillaL01.h similarity index 87% rename from src/OncillaHip.h rename to src/OncillaL01.h index 90340ba..13dec62 100644 --- a/src/OncillaHip.h +++ b/src/OncillaL01.h @@ -1,146 +1,146 @@ #pragma once #include #include #include #include #include #include #include namespace cca { namespace rci { namespace driver { -class OncillaHipSagittal; -typedef boost::shared_ptr OncillaHipSagittalPtr; +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 OncillaHipSagittal: public rci::ResourceNode, +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 */ - OncillaHipSagittal(const std::string & name = "Oncilla Hip"); + OncillaL1(const std::string & name = "Oncilla Hip"); - virtual ~OncillaHipSagittal(); + 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); /** * 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 OncillaHipTransverse; -typedef boost::shared_ptr OncillaHipTwoPtr; +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 OncillaHipTransverse: public rci::ResourceNode, +class OncillaL0: public rci::ResourceNode, public rci::Controlled, public rci::PositionControlled { public: /** * Special constructor to also link to webots */ - OncillaHipTransverse(std::string name = "Oncilla Hip"); + OncillaL0(std::string name = "Oncilla Hip"); - virtual ~OncillaHipTransverse(); + 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/OncillaKnee.cpp b/src/OncillaL2.cpp similarity index 71% rename from src/OncillaKnee.cpp rename to src/OncillaL2.cpp index 2bf8969..93e0098 100644 --- a/src/OncillaKnee.cpp +++ b/src/OncillaL2.cpp @@ -1,68 +1,68 @@ -#include "OncillaKnee.h" +#include "OncillaL2.h" using namespace std; using namespace boost; namespace cca { namespace rci { namespace driver { -OncillaKnee::OncillaKnee(const std::string & name) : +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 OncillaKnee::isConverged() const { +bool OncillaL2::isConverged() const { return false; } -bool OncillaKnee::setJointPosition(JointAnglesPtr position) { +bool OncillaL2::setJointPosition(JointAnglesPtr position) { // Successfull // std::cerr << "[OncillaKnee] " << position << std::endl; this->_lastCommandedPosition = position; return true; } -JointAnglesPtr OncillaKnee::getJointPosition() const { +JointAnglesPtr OncillaL2::getJointPosition() const { return this->_latestJointPosition; } -OncillaKnee::~OncillaKnee() { +OncillaL2::~OncillaL2() { } -std::string OncillaKnee::print() const { +std::string OncillaL2::print() const { ostringstream outstream(ostringstream::out); outstream.precision(3); // Precision when printing double values outstream << "" << endl; return outstream.str(); } -bool OncillaKnee::setJointTorque(JointTorquesPtr torques) { +bool OncillaL2::setJointTorque(JointTorquesPtr torques) { throw std::runtime_error("Not yet implemented."); } -bool OncillaKnee::setJointImpedance(JointImpedancePtr imped) { +bool OncillaL2::setJointImpedance(JointImpedancePtr imped) { throw std::runtime_error("Not yet implemented."); } -bool OncillaKnee::setJointVelocity(JointVelocitiesPtr vel) { +bool OncillaL2::setJointVelocity(JointVelocitiesPtr vel) { throw std::runtime_error("Not yet implemented."); } -JointAnglesPtr OncillaKnee::getLastPositionCommand() const { +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/OncillaKnee.h b/src/OncillaL2.h similarity index 92% rename from src/OncillaKnee.h rename to src/OncillaL2.h index fb0055d..b60a819 100644 --- a/src/OncillaKnee.h +++ b/src/OncillaL2.h @@ -1,97 +1,97 @@ #pragma once #include #include #include #include #include #include #include namespace cca { namespace rci { namespace driver { -class OncillaKnee; -typedef boost::shared_ptr OncillaKneePtr; +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 OncillaKnee: public rci::ResourceNode, +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: - OncillaKnee(const std::string & name = "Oncilla Knee"); - virtual ~OncillaKnee(); + 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); /** * 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/OncillaAnkle.cpp b/src/OncillaL3.cpp similarity index 67% rename from src/OncillaAnkle.cpp rename to src/OncillaL3.cpp index f4c4aed..d2ecd86 100644 --- a/src/OncillaAnkle.cpp +++ b/src/OncillaL3.cpp @@ -1,30 +1,30 @@ -#include "OncillaAnkle.h" +#include "OncillaL3.h" using namespace std; namespace cca { namespace rci { namespace driver { -OncillaAnkle::OncillaAnkle(const std::string & name) : +OncillaL3::OncillaL3(const std::string & name) : rci::ResourceNode(name), rci::Sensing(), rci::PositionSensing() { this->_dimension = 1; } -JointAnglesPtr OncillaAnkle::getJointPosition() const { +JointAnglesPtr OncillaL3::getJointPosition() const { throw std::runtime_error("Not yet implemented."); } -OncillaAnkle::~OncillaAnkle() { +OncillaL3::~OncillaL3() { } -std::string OncillaAnkle::print() const { +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/OncillaAnkle.h b/src/OncillaL3.h similarity index 75% rename from src/OncillaAnkle.h rename to src/OncillaL3.h index ffe2553..2e35c85 100644 --- a/src/OncillaAnkle.h +++ b/src/OncillaL3.h @@ -1,47 +1,47 @@ #pragma once #include #include #include #include #include #include #include namespace cca { namespace rci { namespace driver { -class OncillaAnkle; -typedef boost::shared_ptr OncillaAnklePtr; +class OncillaL3; +typedef boost::shared_ptr OncillaL3Ptr; /** * Node class, representing the foot/ankle of the quadruped robot. Not actuated, * but force sensing. */ -class OncillaAnkle: public rci::ResourceNode, +class OncillaL3: public rci::ResourceNode, public rci::Sensing, public rci::PositionSensing { public: - OncillaAnkle(const std::string & name = "Oncilla Ankle"); + OncillaL3(const std::string & name = "Oncilla Ankle"); - virtual ~OncillaAnkle(); + virtual ~OncillaL3(); /** * Returns contact forces */ JointAnglesPtr getJointPosition() const; /** * Print */ std::string print() const; }; } } } diff --git a/src/OncillaFoot.cpp b/src/OncillaL4.cpp similarity index 69% rename from src/OncillaFoot.cpp rename to src/OncillaL4.cpp index d801d3f..a709959 100644 --- a/src/OncillaFoot.cpp +++ b/src/OncillaL4.cpp @@ -1,30 +1,30 @@ -#include "OncillaFoot.h" +#include "OncillaL4.h" using namespace std; namespace cca { namespace rci { namespace driver { -OncillaFoot::OncillaFoot(const std::string & name) : +OncillaL4::OncillaL4(const std::string & name) : rci::ResourceNode(name), rci::Sensing(), rci::ForceSensing() { this->_dimension = 1; } -ForcesPtr OncillaFoot::getForces() const { +ForcesPtr OncillaL4::getForces() const { throw std::runtime_error("Not yet implemented."); } -OncillaFoot::~OncillaFoot() { +OncillaL4::~OncillaL4() { } -std::string OncillaFoot::print() const { +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/OncillaFoot.h b/src/OncillaL4.h similarity index 75% rename from src/OncillaFoot.h rename to src/OncillaL4.h index a0bc8c5..c6f2e7a 100644 --- a/src/OncillaFoot.h +++ b/src/OncillaL4.h @@ -1,47 +1,47 @@ #pragma once #include #include #include #include #include #include #include namespace cca { namespace rci { namespace driver { -class OncillaFoot; -typedef boost::shared_ptr OncillaFootPtr; +class OncillaL4; +typedef boost::shared_ptr OncillaL4Ptr; /** * Node class, representing the foot of the quadruped robot. Not actuated, * but force sensing. */ -class OncillaFoot: public rci::ResourceNode, +class OncillaL4: public rci::ResourceNode, public rci::Sensing, public rci::ForceSensing { public: - OncillaFoot(const std::string & name = "Oncilla Foot"); + OncillaL4(const std::string & name = "Oncilla Foot"); - virtual ~OncillaFoot(); + virtual ~OncillaL4(); /** * Returns contact forces */ ForcesPtr getForces() const; /** * Print */ std::string print() const; }; } } }