Fawkes API Fawkes Development Version
test_kdlparser.cpp
1/***************************************************************************
2 * kdlparser-test.cpp - SyncPoint Unit Test
3 *
4 * Created on Mon Mar 24 15:47:30 2014
5 * Copyright (C) 2014
6 *
7 ****************************************************************************/
8
9/* This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Library General Public License for more details.
18 *
19 * Read the full text in the LICENSE.GPL file in the doc directory.
20 */
21
22#include <gtest/gtest.h>
23#include <libs/kdl_parser/kdl_parser.h>
24
25#include <kdl/tree.hpp>
26#include <string>
27
28using namespace fawkes;
29using namespace fawkes::kdl_parser;
30using namespace std;
31
32/** Test Class for KDLParser */
33class KDLParserTest : public ::testing::Test
34{
35protected:
36 /** Load the robot description and initialize the tree */
37 virtual void
39 {
40 urdf_file = SRCDIR "/caesar.urdf";
41 ASSERT_TRUE(tree_from_file(urdf_file, tree));
42 }
43 /** The result of parsing the URDF file */
44 KDL::Tree tree;
45 /** The URDF file path */
46 string urdf_file;
47};
48
49TEST_F(KDLParserTest, FileDoesNotExist)
50{
51 string filename = "invalidFileName";
52 KDL::Tree tree;
53 ASSERT_ANY_THROW(tree_from_file(filename, tree));
54}
55
56TEST_F(KDLParserTest, NumberOfJoints)
57{
58 EXPECT_EQ((unsigned int)9, tree.getNrOfJoints());
59 EXPECT_EQ((unsigned int)37, tree.getNrOfSegments());
60}
61
62TEST_F(KDLParserTest, ChainToKatanaFinger)
63{
64 KDL::Chain chain;
65 ASSERT_TRUE(tree.getChain("/base_link", "katana_l_finger_link", chain));
66 EXPECT_EQ(9, chain.getNrOfSegments());
67 EXPECT_EQ(6, chain.getNrOfJoints());
68}
69
70TEST_F(KDLParserTest, RootSegment)
71{
72 EXPECT_EQ("/base_link", tree.getRootSegment()->first);
73 EXPECT_EQ(tree.getSegment("/base_link"), tree.getRootSegment());
74}
Test Class for KDLParser.
string urdf_file
The URDF file path.
virtual void SetUp()
Load the robot description and initialize the tree.
KDL::Tree tree
The result of parsing the URDF file.
Fawkes library namespace.