test_kdl_parser.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2008, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Willow Garage nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 /* Author: Wim Meeussen */
36 
37 #include <gtest/gtest.h>
38 #include <ros/ros.h>
40 
41 int g_argc;
42 char ** g_argv;
43 
44 class TestParser : public testing::Test
45 {
46 public:
47  KDL::Tree my_tree;
48 
49 protected:
51  TestParser()
52  {
53  }
54 
56  ~TestParser()
57  {
58  }
59 };
60 
61 
63  for (int i = 1; i < g_argc - 2; i++) {
64  ROS_ERROR("Testing file %s", g_argv[i]);
65  ASSERT_FALSE(kdl_parser::treeFromFile(g_argv[i], my_tree));
66  }
67 
68  ASSERT_TRUE(kdl_parser::treeFromFile(g_argv[g_argc - 1], my_tree));
69  ASSERT_EQ(8, my_tree.getNrOfJoints());
70  ASSERT_EQ(16, my_tree.getNrOfSegments());
71  ASSERT_TRUE(my_tree.getSegment("dummy_link") == my_tree.getRootSegment());
72  ASSERT_EQ((unsigned int)1, my_tree.getRootSegment()->second.children.size());
73  ASSERT_TRUE(my_tree.getSegment("base_link")->second.parent == my_tree.getRootSegment());
74  ASSERT_EQ(10.0, my_tree.getSegment("base_link")->second.segment.getInertia().getMass());
75  ASSERT_NEAR(1.000, my_tree.getSegment(
76  "base_link")->second.segment.getInertia().getRotationalInertia().data[0], 0.001);
77  SUCCEED();
78 }
79 
80 int main(int argc, char ** argv)
81 {
82  testing::InitGoogleTest(&argc, argv);
83  ros::init(argc, argv, "test_kdl_parser");
84  g_argc = argc;
85  g_argv = argv;
86  return RUN_ALL_TESTS();
87 }
SegmentMap::const_iterator getSegment(const std::string &segment_name) const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
TEST_F(TestParser, test)
int main(int argc, char **argv)
int g_argc
KDL_PARSER_PUBLIC bool treeFromFile(const std::string &file, KDL::Tree &tree)
Definition: kdl_parser.cpp:161
char ** g_argv
SegmentMap::const_iterator getRootSegment() const
unsigned int getNrOfSegments() const
unsigned int getNrOfJoints() const
#define ROS_ERROR(...)


kdl_parser
Author(s): Wim Meeussen , Ioan Sucan , Jackie Kay
autogenerated on Wed Jun 5 2019 21:10:57