Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add test for joint creation.
- Loading branch information
Antonio El Khoury
committed
Oct 11, 2012
1 parent
f55b12f
commit de15c7e
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Add Boost path to include directories. | ||
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) | ||
|
||
# Make Boost.Test generates the main function in test cases. | ||
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN) | ||
|
||
# ADD_TESTCASE(NAME) | ||
# ------------------------ | ||
# | ||
# Define a test named `NAME'. | ||
# | ||
# This macro will create a binary from `NAME.cc', link it against | ||
# Boost and add it to the test suite. | ||
# | ||
MACRO(ADD_TESTCASE NAME) | ||
ADD_EXECUTABLE(${NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${NAME}.cc) | ||
ADD_TEST(${NAME} ${RUNTIME_OUTPUT_DIRECTORY}/${NAME}) | ||
|
||
PKG_CONFIG_USE_DEPENDENCY(${NAME} abstract-robot-dynamics) | ||
ROSPACK_USE_DEPENDENCY(${NAME} rbdl) | ||
|
||
# Link against package library. | ||
TARGET_LINK_LIBRARIES(${NAME} | ||
${Boost_LIBRARIES} | ||
${PROJECT_NAME}) | ||
ENDMACRO(ADD_TESTCASE) | ||
|
||
# Generated tests. | ||
ADD_TESTCASE(create-joint) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (C) 2012 by Antonio El Khoury. | ||
// | ||
// This file is part of the ard-rbdl. | ||
// | ||
// ard-rbdl is free software: you can redistribute it and/or modify it | ||
// under the terms of the GNU Lesser General Public License as | ||
// published by the Free Software Foundation, either version 3 of the | ||
// License, or (at your option) any later version. | ||
// | ||
// ard-rbdl is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with ard-rbdl. If not, see | ||
// <http://www.gnu.org/licenses/>. | ||
|
||
#define BOOST_TEST_MODULE create-joint | ||
|
||
#include <boost/test/unit_test.hpp> | ||
#include <boost/test/output_test_stream.hpp> | ||
|
||
#include <ard/rbdl/tools/util.hh> | ||
#include <ard/rbdl/model/joint.hh> | ||
#include <ard/rbdl/model/robot-dynamics-object-factory.hh> | ||
|
||
BOOST_AUTO_TEST_CASE (create_joint) | ||
{ | ||
using namespace ard::rbdl; | ||
|
||
// Create joint with defaut constructor. | ||
ardJointShPtr_t joint (new joint_t ()); | ||
|
||
BOOST_CHECK_EQUAL (!joint, 0); | ||
|
||
// Create joints from factory. | ||
RobotDynamicsObjectFactory factory = RobotDynamicsObjectFactory (); | ||
matrix4d mat; | ||
mat.setIdentity (); | ||
|
||
ardJointShPtr_t jointRotation = factory.createJointRotation (mat); | ||
ardJointShPtr_t jointTranslation = factory.createJointTranslation (mat); | ||
|
||
BOOST_CHECK_EQUAL (!jointRotation, 0); | ||
BOOST_CHECK_EQUAL (!jointTranslation, 0); | ||
|
||
// Create joint with copy constructor. | ||
jointShPtr_t jointRotationDynCast; | ||
getPtrFromBase (jointRotationDynCast, jointRotation); | ||
ardJointShPtr_t jointRotationCopy (new joint_t (*jointRotationDynCast)); | ||
|
||
BOOST_CHECK_EQUAL (!jointRotationCopy, 0); | ||
} |