tesseract_srdf_serialization_unit.cpp
Go to the documentation of this file.
1 
27 #include <gtest/gtest.h>
28 #include <boost/serialization/shared_ptr.hpp>
30 
34 #include <tesseract_common/utils.h>
40 
41 using namespace tesseract_common;
42 using namespace tesseract_scene_graph;
43 using namespace tesseract_srdf;
44 
46 {
47  SceneGraph g;
48 
49  g.setName("kuka_lbr_iiwa_14_r820");
50 
51  Link base_link("base_link");
52  Link link_1("link_1");
53  Link link_2("link_2");
54  Link link_3("link_3");
55  Link link_4("link_4");
56  Link link_5("link_5");
57  Link link_6("link_6");
58  Link link_7("link_7");
59  Link tool0("tool0");
60 
61  EXPECT_TRUE(g.addLink(base_link));
62  EXPECT_TRUE(g.addLink(link_1));
63  EXPECT_TRUE(g.addLink(link_2));
64  EXPECT_TRUE(g.addLink(link_3));
65  EXPECT_TRUE(g.addLink(link_4));
66  EXPECT_TRUE(g.addLink(link_5));
67  EXPECT_TRUE(g.addLink(link_6));
68  EXPECT_TRUE(g.addLink(link_7));
69  EXPECT_TRUE(g.addLink(tool0));
70 
71  Joint joint_1("joint_a1");
72  joint_1.parent_link_name = "base_link";
73  joint_1.child_link_name = "link_1";
74  joint_1.type = JointType::FIXED;
75  EXPECT_TRUE(g.addJoint(joint_1));
76 
77  Joint joint_2("joint_a2");
78  joint_2.parent_link_name = "link_1";
79  joint_2.child_link_name = "link_2";
80  joint_2.type = JointType::REVOLUTE;
81  joint_2.limits = std::make_shared<JointLimits>(-7, 7, 0, 5, 10, 20);
82  EXPECT_TRUE(g.addJoint(joint_2));
83 
84  Joint joint_3("joint_a3");
85  joint_3.parent_to_joint_origin_transform.translation()(0) = 1.25;
86  joint_3.parent_link_name = "link_2";
87  joint_3.child_link_name = "link_3";
88  joint_3.type = JointType::REVOLUTE;
89  joint_3.limits = std::make_shared<JointLimits>(-7, 7, 0, 5, 10, 20);
90  EXPECT_TRUE(g.addJoint(joint_3));
91 
92  Joint joint_4("joint_a4");
93  joint_4.parent_to_joint_origin_transform.translation()(0) = 1.25;
94  joint_4.parent_link_name = "link_3";
95  joint_4.child_link_name = "link_4";
96  joint_4.type = JointType::REVOLUTE;
97  joint_4.limits = std::make_shared<JointLimits>(-7, 7, 0, 5, 10, 20);
98  EXPECT_TRUE(g.addJoint(joint_4));
99 
100  Joint joint_5("joint_a5");
101  joint_5.parent_to_joint_origin_transform.translation()(1) = 1.25;
102  joint_5.parent_link_name = "link_4";
103  joint_5.child_link_name = "link_5";
104  joint_5.type = JointType::REVOLUTE;
105  joint_5.limits = std::make_shared<JointLimits>(-7, 7, 0, 5, 10, 20);
106  EXPECT_TRUE(g.addJoint(joint_5));
107 
108  Joint joint_6("joint_a6");
109  joint_6.parent_to_joint_origin_transform.translation()(1) = 1.25;
110  joint_6.parent_link_name = "link_5";
111  joint_6.child_link_name = "link_6";
112  joint_6.type = JointType::REVOLUTE;
113  joint_6.limits = std::make_shared<JointLimits>(-7, 7, 0, 5, 10, 20);
114  EXPECT_TRUE(g.addJoint(joint_6));
115 
116  Joint joint_7("joint_a7");
117  joint_7.parent_to_joint_origin_transform.translation()(1) = 1.25;
118  joint_7.parent_link_name = "link_6";
119  joint_7.child_link_name = "link_7";
120  joint_7.type = JointType::REVOLUTE;
121  joint_7.limits = std::make_shared<JointLimits>(-7, 7, 0, 5, 10, 20);
122  EXPECT_TRUE(g.addJoint(joint_7));
123 
124  Joint joint_tool0("joint_tool0");
125  joint_tool0.parent_link_name = "link_7";
126  joint_tool0.child_link_name = "tool0";
127  joint_tool0.type = JointType::FIXED;
128  EXPECT_TRUE(g.addJoint(joint_tool0));
129 
130  return g;
131 }
132 
134 {
135  std::string path = locator.locateResource("package://tesseract_support/urdf/lbr_iiwa_14_r820.srdf")->getFilePath();
136 
137  auto srdf = std::make_shared<SRDFModel>();
138  srdf->initFile(scene_graph, path, locator);
139 
140  return srdf;
141 }
142 
143 TEST(TesseractSRDFSerializeUnit, KinematicsInformation) // NOLINT
144 {
145  GeneralResourceLocator locator;
146  auto graph = getSceneGraph();
147  auto srdf = getSRDFModel(graph, locator);
148 
149  tesseract_common::testSerialization<KinematicsInformation>(srdf->kinematics_information, "KinematicsInformation");
150 }
151 
152 TEST(TesseractSRDFSerializeUnit, SRDFModel) // NOLINT
153 {
154  GeneralResourceLocator locator;
155  auto graph = getSceneGraph();
156  auto srdf = getSRDFModel(graph, locator);
157 
158  tesseract_common::testSerialization<SRDFModel>(*srdf, "SRDFModel");
159 }
160 
161 int main(int argc, char** argv)
162 {
163  testing::InitGoogleTest(&argc, argv);
164 
165  return RUN_ALL_TESTS();
166 }
graph.h
tesseract_srdf::SRDFModel::Ptr
std::shared_ptr< SRDFModel > Ptr
Definition: srdf_model.h:61
tesseract_srdf
Main namespace.
Definition: collision_margins.h:43
tesseract_common
utils.h
resource_locator.h
main
int main(int argc, char **argv)
Definition: tesseract_srdf_serialization_unit.cpp:161
tesseract_common::ResourceLocator::locateResource
virtual std::shared_ptr< Resource > locateResource(const std::string &url) const=0
joint.h
tesseract_scene_graph::Joint::parent_to_joint_origin_transform
Eigen::Isometry3d parent_to_joint_origin_transform
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
tesseract_scene_graph::SceneGraph
tesseract_srdf::SRDFModel
Representation of semantic information about the robot.
Definition: srdf_model.h:54
tesseract_scene_graph::SceneGraph::addLink
bool addLink(const Link &link, bool replace_allowed=false)
getSRDFModel
SRDFModel::Ptr getSRDFModel(const SceneGraph &scene_graph, const tesseract_common::ResourceLocator &locator)
Definition: tesseract_srdf_serialization_unit.cpp:133
tesseract_scene_graph::Joint::child_link_name
std::string child_link_name
tesseract_scene_graph::Joint::limits
JointLimits::Ptr limits
tesseract_scene_graph::SceneGraph::addJoint
bool addJoint(const Joint &joint)
serialization.h
tesseract_common::ResourceLocator
tesseract_srdf::KinematicsInformation
This hold the kinematics information used to create the SRDF and is the data container for the manipu...
Definition: kinematics_information.h:66
TEST
TEST(TesseractSRDFSerializeUnit, KinematicsInformation)
Definition: tesseract_srdf_serialization_unit.cpp:143
kinematics_information.h
This hold the kinematics information.
getSceneGraph
SceneGraph getSceneGraph()
Definition: tesseract_srdf_serialization_unit.cpp:45
tesseract_scene_graph::Joint
TESSERACT_COMMON_IGNORE_WARNINGS_POP
#define TESSERACT_COMMON_IGNORE_WARNINGS_POP
tesseract_scene_graph::SceneGraph::setName
void setName(const std::string &name)
tesseract_common::GeneralResourceLocator
tesseract_scene_graph::Joint::type
JointType type
unit_test_utils.h
srdf_model.h
Parse srdf xml.
macros.h
tesseract_scene_graph
tesseract_scene_graph::Joint::parent_link_name
std::string parent_link_name


tesseract_srdf
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:02:04