test_subclass.cpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2016, Open Source Robotics Foundation, 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 Willow Garage, Inc. 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 #include <gtest/gtest.h>
36 
37 #include <urdf/model.h>
38 
40 
43 
45 {
47 {
48 public:
50  const KDL::Tree& tree, const MimicMap& m, const urdf::Model& model) :
52  {
53  }
54 
55  bool usingTfStatic() const {
56  return use_tf_static_;
57  }
58 };
59 
61 {
62 public:
63 
65  robot_state_publisher::RobotStatePublisher(tree, model)
66  {
67  }
68 
69  const urdf::Model & getModel() const {
70  return model_;
71  }
72 };
73 } // robot_state_publisher_test
74 
75 TEST(TestRobotStatePubSubclass, robot_state_pub_subclass)
76 {
77  urdf::Model model;
78  model.initParam("robot_description");
79  KDL::Tree tree;
80  if (!kdl_parser::treeFromUrdfModel(model, tree)){
81  ROS_ERROR("Failed to extract kdl tree from xml robot description");
82  FAIL();
83  }
84 
85  MimicMap mimic;
86 
87  for(std::map< std::string, urdf::JointSharedPtr >::iterator i = model.joints_.begin(); i != model.joints_.end(); i++){
88  if(i->second->mimic){
89  mimic.insert(make_pair(i->first, i->second->mimic));
90  }
91  }
92 
94 
95  EXPECT_EQ(model.name_, state_pub.getModel().name_);
96  EXPECT_EQ(model.root_link_, state_pub.getModel().root_link_);
97 
98  robot_state_publisher_test::AccessibleJointStateListener state_listener(tree, mimic, model);
99  EXPECT_TRUE(state_listener.usingTfStatic());
100 }
101 
102 int main(int argc, char** argv)
103 {
104  ros::init(argc, argv, "test_subclass");
105  testing::InitGoogleTest(&argc, argv);
106 
107  int res = RUN_ALL_TESTS();
108 
109  return res;
110 }
KDL_PARSER_PUBLIC bool treeFromUrdfModel(const urdf::ModelInterface &robot_model, KDL::Tree &tree)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
#define ROS_ERROR(...)
AccessibleJointStateListener(const KDL::Tree &tree, const MimicMap &m, const urdf::Model &model)
TEST(TestRobotStatePubSubclass, robot_state_pub_subclass)
JointStateListener(const KDL::Tree &tree, const MimicMap &m, const urdf::Model &model=urdf::Model())
URDF_EXPORT bool initParam(const std::string &param)
int main(int argc, char **argv)
std::map< std::string, urdf::JointMimicSharedPtr > MimicMap
AccessibleRobotStatePublisher(const KDL::Tree &tree, const urdf::Model &model)


robot_state_publisher
Author(s): Ioan Sucan , Jackie Kay , Wim Meeussen
autogenerated on Mon Feb 28 2022 23:26:24