diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 41ed98b..ea7c88f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,37 +1,35 @@ # Configure config header CONFIGURE_FILE("config.h.in" "${PROJECT_NAME}Config.h") SET(ONCILLAHEADERS OncillaTrunk.h OncillaL0.h - OncillaL1.h - OncillaL2.h + OncillaL1L2.h OncillaL3.h OncillaL4.h Oncilla.h OncillaSynchronizer.h) SET(ONCILLASOURCES OncillaTrunk.cpp OncillaL0.cpp - OncillaL1.cpp - OncillaL2.cpp + OncillaL1L2.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.cpp b/src/Oncilla.cpp index 2c5d027..eab42b8 100644 --- a/src/Oncilla.cpp +++ b/src/Oncilla.cpp @@ -1,116 +1,115 @@ /* * Oncilla.cpp * * Created on: 15 dec. 2011 * Author: Alexandre Tuleu, Arne Nordmann */ #include "Oncilla.h" #include "OncillaTrunk.h" #include "OncillaL0.h" -#include "OncillaL1.h" -#include "OncillaL2.h" +#include "OncillaL1L2.h" #include "OncillaL3.h" #include "OncillaL4.h" namespace rci { namespace oncilla { Oncilla::LegNames Oncilla::s_legNames; const std::string & Oncilla::nameOfLeg(Leg l){ if(s_legNames.empty()){ s_legNames.push_back("Left Fore"); s_legNames.push_back("Right Fore"); s_legNames.push_back("Left Hind"); s_legNames.push_back("Right Hind"); s_legNames.push_back("Undefined"); } if(l >= NUM_LEGS){ return s_legNames.back(); } return s_legNames[l]; } Oncilla::Oncilla(OncillaSynchronizerPtr synchronizer) :d_synchronizer(synchronizer){ init(); } Oncilla::~Oncilla() { } #define CREATE_NODES(LegName)do{\ d_L0s.push_back(OncillaL0Ptr(new OncillaL0(LegName " Oncilla L0" )));\ - d_L1s.push_back(OncillaL1Ptr(new OncillaL1(*d_synchronizer,\ - LegName " Oncilla L1")));\ - d_L2s.push_back(OncillaL2Ptr(new OncillaL2(*d_synchronizer,\ - LegName " Oncilla L2")));\ + d_L1s.push_back(OncillaL1Ptr(new OncillaL1L2(*d_synchronizer,\ + LegName " Oncilla L1")));\ + d_L2s.push_back(OncillaL2Ptr(new OncillaL1L2(*d_synchronizer,\ + LegName " Oncilla L2")));\ d_L3s.push_back(OncillaL3Ptr(new OncillaL3(LegName " Oncilla L3")));\ d_L4s.push_back(OncillaL4Ptr(new OncillaL4(LegName " Oncilla L4")));\ }while(0) #define REGISTER_NODES(Type)do{\ for(std::vector < Oncilla ## Type ## Ptr >::const_iterator n = d_ ## Type ## s.begin();\ n != d_ ## Type ## s.end();\ ++n){\ Oncilla::Leg l = static_cast(n - d_ ## Type ## s.begin());\ d_synchronizer->register ## Type ## Node(l,*n);\ }\ }while(0) void Oncilla::init() { d_L0s.reserve(4); d_L1s.reserve(4); d_L2s.reserve(4); d_L3s.reserve(4); d_L4s.reserve(4); CREATE_NODES("Left Fore"); CREATE_NODES("Right Fore"); CREATE_NODES("Left Hind"); CREATE_NODES("Right Hind"); d_trunk = OncillaTrunkPtr(new OncillaTrunk("Oncilla Trunk")); REGISTER_NODES(L0); REGISTER_NODES(L1); REGISTER_NODES(L2); REGISTER_NODES(L3); REGISTER_NODES(L4); d_synchronizer->registerTrunkNode(d_trunk); } OncillaL0Ptr Oncilla::getL0(Leg l) const { return this->d_L0s[l]; } OncillaL1Ptr Oncilla::getL1(Leg l) const { return this->d_L1s[l]; } OncillaL2Ptr Oncilla::getL2(Leg l) const { return this->d_L2s[l]; } OncillaL3Ptr Oncilla::getL3(Leg l) const { return this->d_L3s[l]; } OncillaL4Ptr Oncilla::getL4(Leg l) const { return this->d_L4s[l]; } OncillaTrunkPtr Oncilla::getTrunk() const { return this->d_trunk; } } } diff --git a/src/Oncilla.h b/src/Oncilla.h index f5d5e23..a616327 100644 --- a/src/Oncilla.h +++ b/src/Oncilla.h @@ -1,84 +1,83 @@ /* * Oncilla.h * * Created on: 15 dec. 2011 * Author: Alexandre Tuleu, Arne Nordmann */ #pragma once #include #include #include /* * */ /* * */ namespace rci { namespace oncilla { class Oncilla; typedef std::tr1::shared_ptr OncillaPtr; class OncillaSynchronizer; typedef std::tr1::shared_ptr OncillaSynchronizerPtr; class OncillaTrunk; typedef std::tr1::shared_ptr OncillaTrunkPtr; class OncillaL0; typedef std::tr1::shared_ptr OncillaL0Ptr; -class OncillaL1; -typedef std::tr1::shared_ptr OncillaL1Ptr; -class OncillaL2; -typedef std::tr1::shared_ptr OncillaL2Ptr; +class OncillaL1L2; +typedef std::tr1::shared_ptr OncillaL1Ptr; +typedef std::tr1::shared_ptr OncillaL2Ptr; class OncillaL3; typedef std::tr1::shared_ptr OncillaL3Ptr; class OncillaL4; typedef std::tr1::shared_ptr OncillaL4Ptr; class Oncilla { public: enum Leg { LEFT_FORE = 0, RIGHT_FORE = 1, LEFT_HIND = 2, RIGHT_HIND = 3, NUM_LEGS = 4 }; static const std::string & nameOfLeg(Leg l); Oncilla(OncillaSynchronizerPtr synchronizer); virtual ~Oncilla(); OncillaL0Ptr getL0(Leg l) const; OncillaL1Ptr getL1(Leg l) const; OncillaL2Ptr getL2(Leg l) const; OncillaL3Ptr getL3(Leg l) const; OncillaL4Ptr getL4(Leg l) const; OncillaTrunkPtr getTrunk() const; private: typedef std::vector LegNames; static LegNames s_legNames; void init(); OncillaSynchronizerPtr d_synchronizer; std::vector d_L0s; std::vector d_L1s; std::vector d_L2s; std::vector d_L3s; std::vector d_L4s; OncillaTrunkPtr d_trunk; }; } } diff --git a/src/OncillaL1.cpp b/src/OncillaL1L2.cpp similarity index 66% rename from src/OncillaL1.cpp rename to src/OncillaL1L2.cpp index a26844a..a0be954 100644 --- a/src/OncillaL1.cpp +++ b/src/OncillaL1L2.cpp @@ -1,108 +1,108 @@ -#include "OncillaL1.h" +#include "OncillaL1L2.h" #include using namespace std; namespace rci{ namespace oncilla{ -OncillaL1::OncillaL1(OncillaSynchronizer &s, const std::string &name) +OncillaL1L2::OncillaL1L2(OncillaSynchronizer &s, const std::string &name) : ResourceNode(name) , Controlled() , Sensing() , PositionControlled() , PositionSensing() , TorqueControlled() , ImpedanceControlled() , synchronizer(s) { /// \todo add default value as setting this->dimension = 2; this->_lastCommandedPosition = JointAngles::create(1,0.0); this->_latestJointPosition = JointAngles::create(2,0.0); } -bool OncillaL1::isConverged() const { +bool OncillaL1L2::isConverged() const { throw std::runtime_error("Not yet implemented."); return false; } -bool OncillaL1::setJointPosition(JointAnglesPtr position) { +bool OncillaL1L2::setJointPosition(JointAnglesPtr position) { // Successfull this->_lastCommandedPosition = position; return true; } -JointAnglesPtr OncillaL1::getJointPosition() const { +JointAnglesPtr OncillaL1L2::getJointPosition() const { return this->_latestJointPosition; } -bool OncillaL1::setJointVelocity(JointVelocitiesPtr ) { +bool OncillaL1L2::setJointVelocity(JointVelocitiesPtr ) { throw std::runtime_error("Not yet implemented."); } -bool OncillaL1::setJointTorque(JointTorquesPtr ) { +bool OncillaL1L2::setJointTorque(JointTorquesPtr ) { throw std::runtime_error("Not yet implemented."); } -bool OncillaL1::setJointImpedance(JointImpedancePtr ) { +bool OncillaL1L2::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 { +JointAnglesPtr OncillaL1L2::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() { +OncillaL1L2::~OncillaL1L2() { } -std::string OncillaL1::print() const { +std::string OncillaL1L2::print() const { ostringstream outstream(ostringstream::out); outstream.precision(3); // Precision when printing double values outstream << "" << endl; return outstream.str(); } -void OncillaL1::setRawLocalCommand(double value){ +void OncillaL1L2::setRawLocalCommand(double value){ this->_lastCommandedPosition->setValue(0,value); } -double OncillaL1::getRawLocalCommand() const{ +double OncillaL1L2::getRawLocalCommand() const{ return this->_lastCommandedPosition->asDouble(0); } -double OncillaL1::getRawLocalMotorAxisPosition() const{ +double OncillaL1L2::getRawLocalMotorAxisPosition() const{ return this->_latestJointPosition->asDouble(MotorAxisIndex); } -double OncillaL1::getRawLocalMagneticEncoderPosition() const{ +double OncillaL1L2::getRawLocalMagneticEncoderPosition() const{ return this->_latestJointPosition->asDouble(MagneticEncoderIndex); } -void OncillaL1::updateRawLocalMotorAxisPosition(double value){ +void OncillaL1L2::updateRawLocalMotorAxisPosition(double value){ this->_latestJointPosition->setValue(MotorAxisIndex,value); } -void OncillaL1::updateRawLocalMagneticEncoderPosition(double value){ +void OncillaL1L2::updateRawLocalMagneticEncoderPosition(double value){ this->_latestJointPosition->setValue(MagneticEncoderIndex,value); } } } diff --git a/src/OncillaL1.h b/src/OncillaL1L2.h similarity index 92% rename from src/OncillaL1.h rename to src/OncillaL1L2.h index 6e71760..2b7d5e2 100644 --- a/src/OncillaL1.h +++ b/src/OncillaL1L2.h @@ -1,124 +1,124 @@ #pragma once #include #include #include #include #include #include "OncillaSynchronizer.h" namespace rci{ namespace oncilla{ -class OncillaL1; -typedef std::tr1::shared_ptr OncillaL1Ptr; +class OncillaL1L2; +typedef std::tr1::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, +class OncillaL1L2: 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: const static unsigned int MotorAxisIndex = 0; const static unsigned int MagneticEncoderIndex = 1; /** * Special constructor to also link to webots */ - OncillaL1(OncillaSynchronizer &s, const std::string &name = "Oncilla Hip"); + OncillaL1L2(OncillaSynchronizer &s, const std::string &name = "Oncilla Hip"); - virtual ~OncillaL1(); + virtual ~OncillaL1L2(); /** * 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); void setRawLocalCommand(double value); double getRawLocalCommand() const ; /** * Returns current joint position. * @return Current joint position */ virtual JointAnglesPtr getJointPosition() const; double getRawLocalMotorAxisPosition() const; double getRawLocalMagneticEncoderPosition() const; void updateRawLocalMotorAxisPosition(double value); void updateRawLocalMagneticEncoderPosition(double value); /** * 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(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; private: /** * Reference to OncillaSynchronizer * @todo This is a dangerous reference which will become invalid as soon as * OncillaSynchronizer gets deleted outside. */ OncillaSynchronizer &synchronizer; }; } } diff --git a/src/OncillaL2.cpp b/src/OncillaL2.cpp deleted file mode 100644 index f2c7565..0000000 --- a/src/OncillaL2.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#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() - , VelocityControlled() - , TorqueControlled() - , ImpedanceControlled() - , synchronizer(s) { - // Two encoder values - difference is due to passive compliance - this->dimension = 2; - this->_lastCommandedPosition = JointAngles::create(1,0.0); - this->_latestJointPosition = JointAngles::create(2,0.0); -} - -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 ) { - throw std::runtime_error("Not yet implemented."); -} - -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 ) { - 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; -} - -void OncillaL2::setRawLocalCommand(double value){ - this->_lastCommandedPosition->setValue(0,value); -} - -double OncillaL2::getRawLocalCommand() const{ - return this->_lastCommandedPosition->asDouble(0); -} - -double OncillaL2::getRawLocalMotorAxisPosition() const{ - return this->_latestJointPosition->asDouble(MotorAxisIndex); -} - -double OncillaL2::getRawLocalMagneticEncoderPosition() const{ - return this->_latestJointPosition->asDouble(MagneticEncoderIndex); -} - -void OncillaL2::updateRawLocalMotorAxisPosition(double value){ - this->_latestJointPosition->setValue(MotorAxisIndex,value); -} - - -void OncillaL2::updateRawLocalMagneticEncoderPosition(double value){ - this->_latestJointPosition->setValue(MagneticEncoderIndex,value); -} - - -} -} diff --git a/src/OncillaL2.h b/src/OncillaL2.h deleted file mode 100644 index 6798d9e..0000000 --- a/src/OncillaL2.h +++ /dev/null @@ -1,116 +0,0 @@ -#pragma once - -#include -#include - -#include -#include -#include -#include - -#include - -#include "OncillaSynchronizer.h" - -namespace rci { -namespace oncilla { - -class OncillaL2; -typedef std::tr1::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: - const static unsigned int MotorAxisIndex = 0; - const static unsigned int MagneticEncoderIndex = 1; - - OncillaL2(OncillaSynchronizer &s, 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); - - - void setRawLocalCommand(double value); - - double getRawLocalCommand() const ; - /** - * Returns current joint position. - * @return Current joint position - */ - virtual JointAnglesPtr getJointPosition() const; - - - double getRawLocalMotorAxisPosition() const; - - double getRawLocalMagneticEncoderPosition() const; - - - void updateRawLocalMotorAxisPosition(double value); - - void updateRawLocalMagneticEncoderPosition(double value); - - /** - * 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(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; - -private: - OncillaSynchronizer &synchronizer; -}; - -} -} diff --git a/src/OncillaSynchronizer.h b/src/OncillaSynchronizer.h index adb4126..8a9cb80 100644 --- a/src/OncillaSynchronizer.h +++ b/src/OncillaSynchronizer.h @@ -1,99 +1,98 @@ #pragma once #include #include #include #include #include "Oncilla.h" namespace rci { namespace oncilla { class OncillaSynchronizer; typedef std::tr1::shared_ptr OncillaSynchronizerPtr; class OncillaTrunk; typedef std::tr1::shared_ptr OncillaTrunkPtr; class OncillaL0; typedef std::tr1::shared_ptr OncillaL0Ptr; -class OncillaL1; -typedef std::tr1::shared_ptr OncillaL1Ptr; -class OncillaL2; -typedef std::tr1::shared_ptr OncillaL2Ptr; +class OncillaL1L2; +typedef std::tr1::shared_ptr OncillaL1Ptr; +typedef std::tr1::shared_ptr OncillaL2Ptr; class OncillaL3; typedef std::tr1::shared_ptr OncillaL3Ptr; class OncillaL4; typedef std::tr1::shared_ptr OncillaL4Ptr; /** * 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: enum Synchronization { INTERNAL, EXTERNAL }; OncillaSynchronizer(const std::string &name); virtual ~OncillaSynchronizer(); /** * Registers a trunk node. */ virtual void registerTrunkNode(OncillaTrunkPtr node) = 0; /** * Registers an L0 node. */ virtual void registerL0Node(Oncilla::Leg l, OncillaL0Ptr node) = 0; /** * Registers an L1 node. */ virtual void registerL1Node(Oncilla::Leg l, OncillaL1Ptr node) = 0; /** * Registers an L2 node. */ virtual void registerL2Node(Oncilla::Leg l, OncillaL2Ptr node) = 0; /** * Registers an L3 node. */ virtual void registerL3Node(Oncilla::Leg l, OncillaL3Ptr node) = 0; /** * Registers an L4 node. */ virtual void registerL4Node(Oncilla::Leg l, OncillaL4Ptr node) = 0; /** * */ friend std::ostream & operator<<(std::ostream& os, const OncillaSynchronizer& val); double latestProcessLoopDuration() const; Synchronization synchronizationMode() const; void setSynchronizationMode(Synchronization s); protected : virtual double latestProcessLoopDurationPrimpl() const = 0; virtual void switchToSynchronizationModeHook() = 0; Synchronization d_mode; }; } } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6aeb7f7..97c6cb5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,20 +1,20 @@ ENABLE_TESTING() SET(TEST_RESULT_DIR ${CMAKE_BINARY_DIR}/testresults) SET(TEST_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(BEFORE SYSTEM ${GMOCK_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) CONFIGURE_FILE(testconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/testconfig.h) # --- DTO tests --- SET(TEST_SOURCES nodes/NodeTestSuite.cpp nodes/OncillaL0Test.cpp - nodes/OncillaL1Test.cpp + nodes/OncillaL1L2Test.cpp ) ADD_EXECUTABLE(${NODE_TEST_NAME} ${TEST_SOURCES}) TARGET_LINK_LIBRARIES(${NODE_TEST_NAME} ${LIBONCILLA_NAME} ${GMOCK_LIBRARIES}) ADD_TEST(${NODE_TEST_NAME} ${EXECUTABLE_OUTPUT_PATH}/${NODE_TEST_NAME} "--gtest_output=xml:${TEST_RESULT_DIR}/") diff --git a/test/nodes/OncillaL1Test.cpp b/test/nodes/OncillaL1L2Test.cpp similarity index 87% rename from test/nodes/OncillaL1Test.cpp rename to test/nodes/OncillaL1L2Test.cpp index 4ccf072..1a67133 100644 --- a/test/nodes/OncillaL1Test.cpp +++ b/test/nodes/OncillaL1L2Test.cpp @@ -1,85 +1,85 @@ #include -#include "OncillaL1.h" +#include "OncillaL1L2.h" #include "OncillaSynchronizer.h" using namespace nemo; using namespace rci; using namespace rci::oncilla; class MockSynchronizer: public OncillaSynchronizer { public: MockSynchronizer() : OncillaSynchronizer("Sync") { } virtual void processAsync() { } virtual void waitForProcessAsync() { } virtual void registerTrunkNode(rci::oncilla::OncillaTrunkPtr) { } virtual void registerL0Node(rci::oncilla::Oncilla::Leg, rci::oncilla::OncillaL0Ptr) { } virtual void registerL1Node(rci::oncilla::Oncilla::Leg, rci::oncilla::OncillaL1Ptr) { } virtual void registerL2Node(rci::oncilla::Oncilla::Leg, rci::oncilla::OncillaL2Ptr) { } virtual void registerL3Node(rci::oncilla::Oncilla::Leg, rci::oncilla::OncillaL3Ptr) { } virtual void registerL4Node(rci::oncilla::Oncilla::Leg, rci::oncilla::OncillaL4Ptr) { } virtual double latestProcessLoopDurationPrimpl() const { return 0.005; } virtual void switchToSynchronizationModeHook(){ } }; -class OncillaL1Test: public ::testing::Test { +class OncillaL1L2Test: public ::testing::Test { protected: - OncillaL1Test() : + OncillaL1L2Test() : joint(), ja_values(), ji_values(), ja(), ji(), synchr() { - joint = OncillaL1Ptr(new OncillaL1(synchr, "FooBar")); + joint = OncillaL1Ptr(new OncillaL1L2(synchr, "FooBar")); ja_values = RealVector(dim(1), 1.234); ji_values = RealVector(dim(2), 1.234); ji_values[1] = 2.345; ja = JointAngles::fromRad(ja_values); ji = JointImpedancePtr(new JointImpedance(ji_values)); } - virtual ~OncillaL1Test() { + virtual ~OncillaL1L2Test() { } OncillaL1Ptr joint; RealVector ja_values, ji_values; JointAnglesPtr ja; JointImpedancePtr ji; MockSynchronizer synchr; }; -TEST_F(OncillaL1Test, testInitialialState) +TEST_F(OncillaL1L2Test, testInitialialState) { EXPECT_NO_THROW(joint->getLastPositionCommand()); EXPECT_EQ(0.0,joint->getLastPositionCommand()->rad()); } -TEST_F(OncillaL1Test, testPositionCommand) +TEST_F(OncillaL1L2Test, testPositionCommand) { EXPECT_NO_THROW(joint->getLastPositionCommand()); EXPECT_EQ(0.0,joint->getLastPositionCommand()->rad()); joint->setJointPosition(ja); EXPECT_EQ(1.234, joint->getLastPositionCommand()->rad()); }