Commit 8e1d7a93 authored by Olivier Stasse's avatar Olivier Stasse
Browse files

[unitTesting] Add unitTest for control-manager.

To be completed but at least it is testing sendMsg.
parent cecbefd6
# Make Boost.Test generates the main function in test cases.
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)
# Add unit tests for validation
MACRO(SOT_TOR_CTR_TEST NAME)
ADD_EXECUTABLE(test-${NAME} test-${NAME}.cpp)
IF (test-${NAME}-args)
ADD_TEST(test-${NAME} ${RUNTIME_OUTPUT_DIRECTORY}/test-${NAME} ${test-${NAME}-args} )
ELSE (test-${NAME}-args)
ADD_TEST(test-${NAME} ${RUNTIME_OUTPUT_DIRECTORY}/test-${NAME} )
ENDIF (test-${NAME}-args)
TARGET_LINK_LIBRARIES(test-${NAME} ${PROJECT_NAME})
ADD_DEPENDENCIES(test-${NAME} ${PROJECT_NAME})
PKG_CONFIG_USE_DEPENDENCY(test-${NAME} pinocchio)
IF (test-${NAME}-libs)
TARGET_LINK_LIBRARIES(test-${NAME} ${test-${NAME}-libs})
ADD_DEPENDENCIES(test-${NAME} ${test-${NAME}-libs})
ENDIF (test-${NAME}-libs)
# Link against Boost.
TARGET_LINK_LIBRARIES(test-${NAME} ${Boost_LIBRARIES})
ENDMACRO(SOT_TOR_CTR_TEST)
SET(urdfpath
${SIMPLE_HUMANOID_DESCRIPTION_PKGDATAROOTDIR}/simple_humanoid_description/urdf/simple_humanoid.urdf
)
SET(srdfpath
${SIMPLE_HUMANOID_DESCRIPTION_PKGDATAROOTDIR}/simple_humanoid_description/srdf/simple_humanoid.srdf
)
SET(test-control-manager-args ${urdfpath} ${srdfpath} )
SET(test-control-manager-libs control-manager)
SOT_TOR_CTR_TEST(control-manager)
IF(BUILD_PYTHON_INTERFACE)
SET(LIST_OF_TESTS
unit_test_control_manager.py
......
/* Copyright 2019, LAAS-CNRS
*
* Olivier Stasse
*
*/
#include <sstream>
#include <iostream>
#include <dynamic-graph/factory.h>
// Needed for sendMsg.
#define ENABLE_RT_LOG
#include <dynamic-graph/real-time-logger.h>
#include <sot/torque_control/control-manager.hh>
#include <sot/core/robot-utils.hh>
#include <sot/core/debug.hh>
#define BOOST_TEST_MODULE test-control-manager
#include <boost/test/unit_test.hpp>
#include <boost/test/output_test_stream.hpp>
using boost::test_tools::output_test_stream;
namespace dyn_sot_tc = dynamicgraph::sot::torque_control;
void robot_utils_for_simple_humanoid()
{
std::string robotName("simple_humanoid");
robot_util = createRobotUtil(robotName);
robot_util->m_urdf_filename =
boost::unit_test::framework::master_test_suite().argv[1];
}
BOOST_AUTO_TEST_CASE(testControlManager)
{
RealTimeLogger& rtl = RealTimeLogger::instance();
dgADD_OSTREAM_TO_RTLOG (std::cout);
dyn_sot_tc::ControlManager &a_control_manager =
*(dynamic_cast<dyn_sot_tc::ControlManager *>
(dynamicgraph::FactoryStorage::
getInstance()->newEntity("ControlManager",
"a_control_manager")));
if (boost::unit_test::framework::master_test_suite().argc!=3)
BOOST_CHECK(false);
a_control_manager.setLoggerVerbosityLevel(dynamicgraph::VERBOSITY_ALL);
std::string urdfFile = boost::unit_test::framework::
master_test_suite().argv[1];
std::string robotRef("simple_humanoid_description");
a_control_manager.init(0.001,urdfFile,robotRef);
dynamicgraph::Vector av;
a_control_manager.m_uSOUT.needUpdate(6);
RealTimeLogger::destroy();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment