srdf_writer.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2012, 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 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: Dave Coleman */
36 
37 #ifndef _SRDFDOM_SRDF_WRITER_
38 #define _SRDFDOM_SRDF_WRITER_
39 
40 #include <memory>
41 #include <srdfdom/model.h> // use their struct datastructures
42 
43 namespace srdf
44 {
45 // ******************************************************************************************
46 // ******************************************************************************************
47 // Class
48 // ******************************************************************************************
49 // ******************************************************************************************
50 
51 class SRDFWriter
52 {
53 public:
54  // ******************************************************************************************
55  // Public Functions
56  // ******************************************************************************************
60  SRDFWriter();
61 
65  ~SRDFWriter();
66 
75  bool initString(const urdf::ModelInterface& robot_model, const std::string& srdf_string);
76 
83  void initModel(const urdf::ModelInterface& robot_model, const srdf::Model& srdf_model);
84 
90  void updateSRDFModel(const urdf::ModelInterface& robot_model);
91 
98  bool writeSRDF(const std::string& file_path);
99 
105  std::string getSRDFString();
106 
112  void generateSRDF(tinyxml2::XMLDocument& document);
113 
119  void createGroupsXML(tinyxml2::XMLElement* root);
120 
126  void createLinkSphereApproximationsXML(tinyxml2::XMLElement* root);
127 
133  void createCollisionDefaultsXML(tinyxml2::XMLElement* root);
134 
140  void createDisabledCollisionPairsXML(tinyxml2::XMLElement* root);
141 
147  void createGroupStatesXML(tinyxml2::XMLElement* root);
148 
154  void createEndEffectorsXML(tinyxml2::XMLElement* root);
155 
161  void createVirtualJointsXML(tinyxml2::XMLElement* root);
162 
168  void createPassiveJointsXML(tinyxml2::XMLElement* root);
169 
170 protected:
176  void createCollisionPairsXML(tinyxml2::XMLElement* root, const char* tag_name,
177  const std::vector<Model::CollisionPair>& pairs);
178 
179 public:
180  // ******************************************************************************************
181  // Group Datastructures
182  // ******************************************************************************************
183 
184  std::vector<Model::Group> groups_;
185  std::vector<Model::GroupState> group_states_;
186  std::vector<Model::VirtualJoint> virtual_joints_;
187  std::vector<Model::EndEffector> end_effectors_;
188  std::vector<Model::LinkSpheres> link_sphere_approximations_;
189  std::vector<std::string> no_default_collision_links_;
190  std::vector<Model::CollisionPair> disabled_collision_pairs_;
191  std::vector<Model::CollisionPair> enabled_collision_pairs_;
192  std::vector<Model::PassiveJoint> passive_joints_;
193 
194  // Store the SRDF Model for updating the kinematic_model
196 
197  // Robot name
198  std::string robot_name_;
199 };
200 
201 // ******************************************************************************************
202 // Typedef
203 // ******************************************************************************************
204 typedef std::shared_ptr<SRDFWriter> SRDFWriterPtr;
205 } // namespace srdf
206 
207 #endif
srdf::SRDFWriter::createCollisionDefaultsXML
void createCollisionDefaultsXML(tinyxml2::XMLElement *root)
Definition: srdf_writer.cpp:325
model.h
srdf::SRDFWriter::updateSRDFModel
void updateSRDFModel(const urdf::ModelInterface &robot_model)
Definition: srdf_writer.cpp:118
srdf::SRDFWriter::initString
bool initString(const urdf::ModelInterface &robot_model, const std::string &srdf_string)
Definition: srdf_writer.cpp:75
srdf::SRDFWriter::createLinkSphereApproximationsXML
void createLinkSphereApproximationsXML(tinyxml2::XMLElement *root)
Definition: srdf_writer.cpp:285
srdf::ModelSharedPtr
std::shared_ptr< Model > ModelSharedPtr
Definition: model.h:315
srdf::SRDFWriter::srdf_model_
ModelSharedPtr srdf_model_
Definition: srdf_writer.h:259
srdf::SRDFWriter::SRDFWriter
SRDFWriter()
Definition: srdf_writer.cpp:59
srdf::SRDFWriter::passive_joints_
std::vector< Model::PassiveJoint > passive_joints_
Definition: srdf_writer.h:256
srdf::SRDFWriter::createVirtualJointsXML
void createVirtualJointsXML(tinyxml2::XMLElement *root)
Definition: srdf_writer.cpp:455
srdf::SRDFWriter::end_effectors_
std::vector< Model::EndEffector > end_effectors_
Definition: srdf_writer.h:251
srdf::SRDFWriter::createEndEffectorsXML
void createEndEffectorsXML(tinyxml2::XMLElement *root)
Definition: srdf_writer.cpp:427
srdf::SRDFWriter::generateSRDF
void generateSRDF(tinyxml2::XMLDocument &document)
Definition: srdf_writer.cpp:163
srdf::SRDFWriter::robot_name_
std::string robot_name_
Definition: srdf_writer.h:262
srdf::SRDFWriter::createDisabledCollisionPairsXML
void createDisabledCollisionPairsXML(tinyxml2::XMLElement *root)
Definition: srdf_writer.cpp:371
srdf::SRDFWriter::disabled_collision_pairs_
std::vector< Model::CollisionPair > disabled_collision_pairs_
Definition: srdf_writer.h:254
srdf::SRDFWriter::virtual_joints_
std::vector< Model::VirtualJoint > virtual_joints_
Definition: srdf_writer.h:250
srdf::SRDFWriter::createGroupsXML
void createGroupsXML(tinyxml2::XMLElement *root)
Definition: srdf_writer.cpp:209
srdf::SRDFWriter::createCollisionPairsXML
void createCollisionPairsXML(tinyxml2::XMLElement *root, const char *tag_name, const std::vector< Model::CollisionPair > &pairs)
Definition: srdf_writer.cpp:351
srdf::SRDFWriter::enabled_collision_pairs_
std::vector< Model::CollisionPair > enabled_collision_pairs_
Definition: srdf_writer.h:255
srdf::SRDFWriter::group_states_
std::vector< Model::GroupState > group_states_
Definition: srdf_writer.h:249
srdf::SRDFWriter::initModel
void initModel(const urdf::ModelInterface &robot_model, const srdf::Model &srdf_model)
Definition: srdf_writer.cpp:92
srdf::SRDFWriter::writeSRDF
bool writeSRDF(const std::string &file_path)
Definition: srdf_writer.cpp:133
srdf::SRDFWriter::getSRDFString
std::string getSRDFString()
Definition: srdf_writer.cpp:146
srdf::SRDFWriter::createPassiveJointsXML
void createPassiveJointsXML(tinyxml2::XMLElement *root)
Definition: srdf_writer.cpp:482
srdf
Main namespace.
Definition: model.h:49
srdf::SRDFWriter::groups_
std::vector< Model::Group > groups_
Definition: srdf_writer.h:248
srdf::SRDFWriter::no_default_collision_links_
std::vector< std::string > no_default_collision_links_
Definition: srdf_writer.h:253
srdf::SRDFWriter::~SRDFWriter
~SRDFWriter()
Definition: srdf_writer.cpp:68
srdf::SRDFWriter::createGroupStatesXML
void createGroupStatesXML(tinyxml2::XMLElement *root)
Definition: srdf_writer.cpp:389
srdf::Model
Representation of semantic information about the robot.
Definition: model.h:84
srdf::SRDFWriterPtr
std::shared_ptr< SRDFWriter > SRDFWriterPtr
Definition: srdf_writer.h:236
srdf::SRDFWriter::link_sphere_approximations_
std::vector< Model::LinkSpheres > link_sphere_approximations_
Definition: srdf_writer.h:252


srdfdom
Author(s): Ioan Sucan , Guillaume Walck
autogenerated on Wed Mar 2 2022 01:03:43