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 
175  void createJointPropertiesXML(tinyxml2::XMLElement* root);
176 
177 protected:
183  void createCollisionPairsXML(tinyxml2::XMLElement* root, const char* tag_name,
184  const std::vector<Model::CollisionPair>& pairs);
185 
186 public:
187  // ******************************************************************************************
188  // Group Datastructures
189  // ******************************************************************************************
190 
191  std::vector<Model::Group> groups_;
192  std::vector<Model::GroupState> group_states_;
193  std::vector<Model::VirtualJoint> virtual_joints_;
194  std::vector<Model::EndEffector> end_effectors_;
195  std::vector<Model::LinkSpheres> link_sphere_approximations_;
196  std::vector<std::string> no_default_collision_links_;
197  std::vector<Model::CollisionPair> disabled_collision_pairs_;
198  std::vector<Model::CollisionPair> enabled_collision_pairs_;
199  std::vector<Model::PassiveJoint> passive_joints_;
201 
202  // Store the SRDF Model for updating the kinematic_model
204 
205  // Robot name
206  std::string robot_name_;
207 };
208 
209 // ******************************************************************************************
210 // Typedef
211 // ******************************************************************************************
212 typedef std::shared_ptr<SRDFWriter> SRDFWriterPtr;
213 } // namespace srdf
214 
215 #endif
srdf::SRDFWriter::joint_properties_
Model::JointPropertyMap joint_properties_
Definition: srdf_writer.h:264
srdf::SRDFWriter::createCollisionDefaultsXML
void createCollisionDefaultsXML(tinyxml2::XMLElement *root)
Definition: srdf_writer.cpp:329
model.h
srdf::Model::JointPropertyMap
std::map< std::string, PropertyMap > JointPropertyMap
Definition: model.h:120
srdf::SRDFWriter::updateSRDFModel
void updateSRDFModel(const urdf::ModelInterface &robot_model)
Definition: srdf_writer.cpp:119
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:289
srdf::ModelSharedPtr
std::shared_ptr< Model > ModelSharedPtr
Definition: model.h:340
srdf::SRDFWriter::srdf_model_
ModelSharedPtr srdf_model_
Definition: srdf_writer.h:267
srdf::SRDFWriter::SRDFWriter
SRDFWriter()
Definition: srdf_writer.cpp:59
srdf::SRDFWriter::passive_joints_
std::vector< Model::PassiveJoint > passive_joints_
Definition: srdf_writer.h:263
srdf::SRDFWriter::createVirtualJointsXML
void createVirtualJointsXML(tinyxml2::XMLElement *root)
Definition: srdf_writer.cpp:459
srdf::SRDFWriter::end_effectors_
std::vector< Model::EndEffector > end_effectors_
Definition: srdf_writer.h:258
srdf::SRDFWriter::createEndEffectorsXML
void createEndEffectorsXML(tinyxml2::XMLElement *root)
Definition: srdf_writer.cpp:431
srdf::SRDFWriter::generateSRDF
void generateSRDF(tinyxml2::XMLDocument &document)
Definition: srdf_writer.cpp:164
srdf::SRDFWriter::robot_name_
std::string robot_name_
Definition: srdf_writer.h:270
srdf::SRDFWriter::createDisabledCollisionPairsXML
void createDisabledCollisionPairsXML(tinyxml2::XMLElement *root)
Definition: srdf_writer.cpp:375
srdf::SRDFWriter::disabled_collision_pairs_
std::vector< Model::CollisionPair > disabled_collision_pairs_
Definition: srdf_writer.h:261
srdf::SRDFWriter::virtual_joints_
std::vector< Model::VirtualJoint > virtual_joints_
Definition: srdf_writer.h:257
srdf::SRDFWriter::createGroupsXML
void createGroupsXML(tinyxml2::XMLElement *root)
Definition: srdf_writer.cpp:213
srdf::SRDFWriter::createCollisionPairsXML
void createCollisionPairsXML(tinyxml2::XMLElement *root, const char *tag_name, const std::vector< Model::CollisionPair > &pairs)
Definition: srdf_writer.cpp:355
srdf::SRDFWriter::enabled_collision_pairs_
std::vector< Model::CollisionPair > enabled_collision_pairs_
Definition: srdf_writer.h:262
srdf::SRDFWriter::group_states_
std::vector< Model::GroupState > group_states_
Definition: srdf_writer.h:256
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:134
srdf::SRDFWriter::getSRDFString
std::string getSRDFString()
Definition: srdf_writer.cpp:147
srdf::SRDFWriter::createPassiveJointsXML
void createPassiveJointsXML(tinyxml2::XMLElement *root)
Definition: srdf_writer.cpp:486
srdf
Main namespace.
Definition: model.h:49
srdf::SRDFWriter::groups_
std::vector< Model::Group > groups_
Definition: srdf_writer.h:255
srdf::SRDFWriter::createJointPropertiesXML
void createJointPropertiesXML(tinyxml2::XMLElement *root)
Definition: srdf_writer.cpp:506
srdf::SRDFWriter::no_default_collision_links_
std::vector< std::string > no_default_collision_links_
Definition: srdf_writer.h:260
srdf::SRDFWriter::~SRDFWriter
~SRDFWriter()
Definition: srdf_writer.cpp:68
srdf::SRDFWriter::createGroupStatesXML
void createGroupStatesXML(tinyxml2::XMLElement *root)
Definition: srdf_writer.cpp:393
srdf::Model
Representation of semantic information about the robot.
Definition: model.h:84
srdf::SRDFWriterPtr
std::shared_ptr< SRDFWriter > SRDFWriterPtr
Definition: srdf_writer.h:244
srdf::SRDFWriter::link_sphere_approximations_
std::vector< Model::LinkSpheres > link_sphere_approximations_
Definition: srdf_writer.h:259


srdfdom
Author(s): Ioan Sucan , Guillaume Walck
autogenerated on Wed Oct 16 2024 02:22:59