diff --git a/.cproject b/.cproject
index 4b4d075..e8d7324 100644
--- a/.cproject
+++ b/.cproject
@@ -1,1006 +1,599 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
cmake
-E chdir ../build cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} -DCMAKE_BUILD_TYPE=debug ..
true
false
true
make
true
true
true
make
clean
true
true
true
make
install
true
true
true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
cmake
-E chdir ../build cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} -DCMAKE_BUILD_TYPE=debug ..
true
false
true
make
true
true
true
make
clean
true
true
true
make
install
true
true
true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c3300b7..0df0acd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,170 +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
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 "${PROJECT_NAME}Tests")
-SET(DTO_TEST_NAME "${DRIVER_TEST_NAME}DTO")
+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(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_TESTS)
+ ENABLE_TESTING()
ADD_SUBDIRECTORY(test)
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(${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/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/OncillaL01.cpp b/src/OncillaL01.cpp
index aac219c..fed9ccc 100644
--- a/src/OncillaL01.cpp
+++ b/src/OncillaL01.cpp
@@ -1,106 +1,103 @@
#include "OncillaL01.h"
using namespace std;
namespace rci {
namespace oncilla {
OncillaL0::OncillaL0(const std::string &name) :
- ResourceNode(name), Controlled(), PositionControlled() {
+ ResourceNode(name), Controlled(), PositionControlled() {
}
bool OncillaL0::isConverged() const {
- return false;
+ return false;
}
bool OncillaL0::setJointPosition(JointAnglesPtr position) {
- // Successfull
- this->_lastCommandedPosition = position;
- return true;
+ // 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();
+ 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();
+ 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) {
- this->_dimension = 2; // Two encoder values - should always be the same
+OncillaL1::OncillaL1(OncillaSynchronizer &s, const std::string &name) :
+ ResourceNode(name), Controlled(), Sensing(), PositionControlled(), PositionSensing(), TorqueControlled(), ImpedanceControlled(), synchronizer(
+ s) {
+ this->_dimension = 2; // Two encoder values - should always be the same
}
bool OncillaL1::isConverged() const {
- throw std::runtime_error("Not yet implemented.");
- return false;
+ throw std::runtime_error("Not yet implemented.");
+ return false;
}
bool OncillaL1::setJointPosition(JointAnglesPtr position) {
- // Successfull
- this->_lastCommandedPosition = position;
- return true;
+ // Successfull
+ this->_lastCommandedPosition = position;
+ return true;
}
JointAnglesPtr OncillaL1::getJointPosition() const {
- return this->_latestJointPosition;
+ return this->_latestJointPosition;
}
bool OncillaL1::setJointVelocity(JointVelocitiesPtr vel) {
- throw std::runtime_error("Not yet implemented.");
+ throw std::runtime_error("Not yet implemented.");
}
bool OncillaL1::setJointTorque(JointTorquesPtr torque) {
- throw std::runtime_error("Not yet implemented.");
+ throw std::runtime_error("Not yet implemented.");
}
bool OncillaL1::setJointImpedance(JointImpedancePtr imped) {
- 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.");
- }
+ 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 {
- // 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;
+ 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();
+ ostringstream outstream(ostringstream::out);
+ outstream.precision(3); // Precision when printing double values
+ outstream << "" << endl;
+ return outstream.str();
}
}
}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 4a3256d..445a306 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1 +1,20 @@
ENABLE_TESTING()
+
+SET(TEST_RESULT_DIR ${CMAKE_BINARY_DIR}/testresults)
+SET(TEST_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
+
+INCLUDE_DIRECTORIES(BEFORE SYSTEM ${GTEST_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
+ )
+ADD_EXECUTABLE(${NODE_TEST_NAME} ${TEST_SOURCES})
+TARGET_LINK_LIBRARIES(${NODE_TEST_NAME}
+ ${LIBONCILLA_NAME}
+ ${GTEST_BOTH_LIBRARIES})
+ADD_TEST(${NODE_TEST_NAME} ${EXECUTABLE_OUTPUT_PATH}/${NODE_TEST_NAME} "--gtest_output=xml:${TEST_RESULT_DIR}/")
diff --git a/test/nodes/NodeTestSuite.cpp b/test/nodes/NodeTestSuite.cpp
new file mode 100644
index 0000000..64becff
--- /dev/null
+++ b/test/nodes/NodeTestSuite.cpp
@@ -0,0 +1,6 @@
+#include
+
+int main(int argc, char **argv) {
+ testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/nodes/OncillaL0Test.cpp b/test/nodes/OncillaL0Test.cpp
new file mode 100644
index 0000000..9e5c2dd
--- /dev/null
+++ b/test/nodes/OncillaL0Test.cpp
@@ -0,0 +1,45 @@
+#include
+
+#include "OncillaL01.h"
+
+using namespace nemo;
+using namespace rci;
+using namespace rci::oncilla;
+
+class OncillaL0Test: public ::testing::Test {
+protected:
+
+ OncillaL0Test() :
+ joint(), ja_values(), ji_values(), ja(), ji() {
+
+ joint = OncillaL0Ptr(new OncillaL0("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 ~OncillaL0Test() {
+ }
+
+ OncillaL0Ptr joint;
+ RealVector ja_values, ji_values;
+
+ JointAnglesPtr ja;
+ JointImpedancePtr ji;
+};
+
+TEST_F(OncillaL0Test, testInitialialState)
+{
+ EXPECT_THROW(joint->getLastPositionCommand(), std::runtime_error);
+}
+
+TEST_F(OncillaL0Test, testPositionCommand)
+{
+ EXPECT_THROW(joint->getLastPositionCommand(), std::runtime_error);
+ joint->setJointPosition(ja);
+ EXPECT_EQ(1.234, joint->getLastPositionCommand()->rad());
+}
diff --git a/test/nodes/OncillaL1Test.cpp b/test/nodes/OncillaL1Test.cpp
new file mode 100644
index 0000000..6ef9ff3
--- /dev/null
+++ b/test/nodes/OncillaL1Test.cpp
@@ -0,0 +1,76 @@
+#include
+
+#include "OncillaL01.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) {
+ }
+};
+
+class OncillaL1Test: public ::testing::Test {
+protected:
+
+ OncillaL1Test() :
+ joint(), ja_values(), ji_values(), ja(), ji(), synchr() {
+
+ joint = OncillaL1Ptr(new OncillaL1(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() {
+ }
+
+ OncillaL1Ptr joint;
+ RealVector ja_values, ji_values;
+
+ JointAnglesPtr ja;
+ JointImpedancePtr ji;
+
+ MockSynchronizer synchr;
+};
+
+TEST_F(OncillaL1Test, testInitialialState)
+{
+ EXPECT_THROW(joint->getLastPositionCommand(), std::runtime_error);
+}
+
+TEST_F(OncillaL1Test, testPositionCommand)
+{
+ EXPECT_THROW(joint->getLastPositionCommand(), std::runtime_error);
+ joint->setJointPosition(ja);
+ EXPECT_EQ(1.234, joint->getLastPositionCommand()->rad());
+}
diff --git a/test/testconfig.h.in b/test/testconfig.h.in
new file mode 100644
index 0000000..dd41469
--- /dev/null
+++ b/test/testconfig.h.in
@@ -0,0 +1,4 @@
+#pragma once
+#include
+
+const static std::string TEST_ROOT = "@TEST_ROOT@";