test_chain.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #include <ros/package.h>
31 #include <gtest/gtest.h>
32 #include <vector>
33 #include <boost/scoped_ptr.hpp>
36 #include <kdl/chainfksolverpos_recursive.hpp>
37 
38 using namespace pr2_mechanism_model;
39 using namespace std;
40 
41 
42 // Just three links
43 class ShortChainTest : public testing::Test
44 {
45 protected:
47  virtual ~ShortChainTest() {}
48 
49  virtual void SetUp() {}
50 
51  virtual void TearDown() {}
52 
54 };
55 
56 TEST_F(ShortChainTest, FKShouldMatchOnShortChainWhenStraight)
57 {
58  TiXmlDocument urdf_xml;
59  urdf_xml.LoadFile(ros::package::getPath("pr2_mechanism_model") + "/pr2.urdf");
60  TiXmlElement *root = urdf_xml.FirstChildElement("robot");
61  ASSERT_TRUE(root != NULL);
63  Robot model(&hw);
64  ASSERT_TRUE(model.initXml(root));
65  RobotState state(&model);
66 
67  // Test no longer valid because joint state is empty when actuators are not present
68  /*
69  // extract chain
70  Chain chain;
71  EXPECT_TRUE(chain.init(&state, "fl_caster_l_wheel_link", "r_gripper_palm_link"));
72  KDL::Chain kdl;
73  chain.toKDL(kdl);
74  unsigned int nr_segments = 13;
75  unsigned int nr_joints = 10;
76  ASSERT_EQ(nr_segments, kdl.getNrOfSegments());
77  ASSERT_EQ(nr_joints, kdl.getNrOfJoints());
78 
79  KDL::JntArray jnts(state.joint_states_.size());
80  chain.getPositions(jnts);
81  */
82 }
83 
84 int main(int argc, char **argv){
85  testing::InitGoogleTest(&argc, argv);
86  return RUN_ALL_TESTS();
87 }
ShortChainTest::SetUp
virtual void SetUp()
Definition: test_chain.cpp:49
robot.h
ros::package::getPath
ROSLIB_DECL std::string getPath(const std::string &package_name)
pr2_mechanism_model
Definition: chain.h:41
ShortChainTest
Definition: test_chain.cpp:43
pr2_hardware_interface::HardwareInterface
ShortChainTest::ShortChainTest
ShortChainTest()
Definition: test_chain.cpp:46
pr2_mechanism_model::RobotState
This class provides the controllers with an interface to the robot state.
Definition: robot.h:126
main
int main(int argc, char **argv)
Definition: test_chain.cpp:84
TEST_F
TEST_F(ShortChainTest, FKShouldMatchOnShortChainWhenStraight)
Definition: test_chain.cpp:56
ShortChainTest::hw
pr2_hardware_interface::HardwareInterface hw
Definition: test_chain.cpp:53
pr2_mechanism_model::Robot
This class provides the controllers with an interface to the robot model.
Definition: robot.h:78
chain.h
package.h
pr2_mechanism_model::Robot::initXml
bool initXml(TiXmlElement *root)
Initialize the robot model form xml.
Definition: robot.cpp:51
std
ShortChainTest::~ShortChainTest
virtual ~ShortChainTest()
Definition: test_chain.cpp:47
ShortChainTest::TearDown
virtual void TearDown()
Definition: test_chain.cpp:51


pr2_mechanism_model
Author(s): Eric Berger berger@willowgarage.com, Stuart Glaser, Wim Meeussen
autogenerated on Mon Mar 6 2023 03:49:17