rdf_loader.cpp
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2011, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Willow Garage nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 /* Author: Ioan Sucan */
00036 
00037 #include <moveit/rdf_loader/rdf_loader.h>
00038 #include <moveit/profiler/profiler.h>
00039 #include <ros/ros.h>
00040 
00041 rdf_loader::RDFLoader::RDFLoader(const std::string& robot_description)
00042 {
00043   moveit::tools::Profiler::ScopedStart prof_start;
00044   moveit::tools::Profiler::ScopedBlock prof_block("RDFLoader(robot_description)");
00045 
00046   ros::WallTime start = ros::WallTime::now();
00047   ros::NodeHandle nh("~");
00048   std::string content;
00049 
00050   if (!nh.searchParam(robot_description, robot_description_) || !nh.getParam(robot_description_, content))
00051   {
00052     ROS_ERROR("Robot model parameter not found! Did you remap '%s'?", robot_description.c_str());
00053     return;
00054   }
00055 
00056   urdf::Model* umodel = new urdf::Model();
00057   if (!umodel->initString(content))
00058   {
00059     ROS_ERROR("Unable to parse URDF from parameter '%s'", robot_description_.c_str());
00060     return;
00061   }
00062   urdf_.reset(umodel);
00063 
00064   const std::string srdf_description(robot_description_ + "_semantic");
00065   std::string scontent;
00066   if (!nh.getParam(srdf_description, scontent))
00067   {
00068     ROS_ERROR("Robot semantic description not found. Did you forget to define or remap '%s'?",
00069               srdf_description.c_str());
00070     return;
00071   }
00072 
00073   srdf_.reset(new srdf::Model());
00074   if (!srdf_->initString(*urdf_, scontent))
00075   {
00076     ROS_ERROR("Unable to parse SRDF from parameter '%s'", srdf_description.c_str());
00077     srdf_.reset();
00078     return;
00079   }
00080 
00081   ROS_DEBUG_STREAM_NAMED("rdf", "Loaded robot model in " << (ros::WallTime::now() - start).toSec() << " seconds");
00082 }
00083 
00084 rdf_loader::RDFLoader::RDFLoader(const std::string& urdf_string, const std::string& srdf_string)
00085 {
00086   moveit::tools::Profiler::ScopedStart prof_start;
00087   moveit::tools::Profiler::ScopedBlock prof_block("RDFLoader(string)");
00088 
00089   urdf::Model* umodel = new urdf::Model();
00090   urdf_.reset(umodel);
00091   if (umodel->initString(urdf_string))
00092   {
00093     srdf_.reset(new srdf::Model());
00094     if (!srdf_->initString(*urdf_, srdf_string))
00095     {
00096       ROS_ERROR("Unable to parse SRDF");
00097       srdf_.reset();
00098     }
00099   }
00100   else
00101   {
00102     ROS_ERROR("Unable to parse URDF");
00103     urdf_.reset();
00104   }
00105 }
00106 
00107 rdf_loader::RDFLoader::RDFLoader(TiXmlDocument* urdf_doc, TiXmlDocument* srdf_doc)
00108 {
00109   moveit::tools::Profiler::ScopedStart prof_start;
00110   moveit::tools::Profiler::ScopedBlock prof_block("RDFLoader(XML)");
00111 
00112   urdf::Model* umodel = new urdf::Model();
00113   urdf_.reset(umodel);
00114   if (umodel->initXml(urdf_doc))
00115   {
00116     srdf_.reset(new srdf::Model());
00117     if (!srdf_->initXml(*urdf_, srdf_doc))
00118     {
00119       ROS_ERROR("Unable to parse SRDF");
00120       srdf_.reset();
00121     }
00122   }
00123   else
00124   {
00125     ROS_ERROR("Unable to parse URDF");
00126     urdf_.reset();
00127   }
00128 }


planning
Author(s): Ioan Sucan , Sachin Chitta
autogenerated on Wed Jun 19 2019 19:24:16