From 84b96c265f78d9bd6dd22a39afffe699a56f8224 Mon Sep 17 00:00:00 2001 From: Ioan Sucan Date: Mon, 20 May 2013 14:44:44 +0300 Subject: [PATCH] export collada parser as plugin --- ChangeList.txt | 2 +- collada_parser/CMakeLists.txt | 15 ++++-- .../collada_parser_plugin_description.xml | 7 +++ .../collada_parser/collada_parser_plugin.h | 54 +++++++++++++++++++ collada_parser/package.xml | 2 + collada_parser/src/collada_parser_plugin.cpp | 46 ++++++++++++++++ robot_model/package.xml | 2 +- .../include/urdf_parser_plugin/parser.h | 5 ++ 8 files changed, 128 insertions(+), 5 deletions(-) create mode 100644 collada_parser/collada_parser_plugin_description.xml create mode 100644 collada_parser/include/collada_parser/collada_parser_plugin.h create mode 100644 collada_parser/src/collada_parser_plugin.cpp diff --git a/ChangeList.txt b/ChangeList.txt index ce1922c..49c4b2d 100644 --- a/ChangeList.txt +++ b/ChangeList.txt @@ -1,4 +1,4 @@ -= 1.9.0 (Forthcoming) = += 1.9.0 = * Branch from 1.8.0 * [[collada_parser]] diff --git a/collada_parser/CMakeLists.txt b/collada_parser/CMakeLists.txt index 1737882..25e912c 100644 --- a/collada_parser/CMakeLists.txt +++ b/collada_parser/CMakeLists.txt @@ -3,7 +3,7 @@ project(collada_parser) find_package(Boost REQUIRED system) -find_package(catkin REQUIRED COMPONENTS urdfdom_headers urdf_parser_plugin roscpp) +find_package(catkin REQUIRED COMPONENTS urdfdom_headers urdf_parser_plugin roscpp class_loader) catkin_package( LIBRARIES ${PROJECT_NAME} @@ -31,12 +31,18 @@ if(HAVE_MKSTEMPS) add_definitions("-DHAVE_MKSTEMPS") endif() -#common commands for building c++ executables and libraries +# build the parser lib add_library(${PROJECT_NAME} src/collada_parser.cpp) target_link_libraries(${PROJECT_NAME} ${COLLADA_DOM_LIBRARIES} ${Boost_LIBRARIES} ${catkin_LIBRARIES} ) +# build the plugin for the parser +add_library(${PROJECT_NAME}_plugin src/collada_parser_plugin.cpp) +target_link_libraries(${PROJECT_NAME}_plugin + ${PROJECT_NAME} ${Boost_LIBRARIES} ${catkin_LIBRARIES} +) + set_target_properties(${PROJECT_NAME} PROPERTIES COMPILER_FLAGS "${COLLADA_DOM_CFLAGS_OTHER}" ) @@ -51,8 +57,11 @@ else() ) endif() -install(TARGETS ${PROJECT_NAME} +install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_plugin DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) install(DIRECTORY include/${PROJECT_NAME}/ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}) + +install(FILES collada_parser_plugin_description.xml + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}) diff --git a/collada_parser/collada_parser_plugin_description.xml b/collada_parser/collada_parser_plugin_description.xml new file mode 100644 index 0000000..57f16b7 --- /dev/null +++ b/collada_parser/collada_parser_plugin_description.xml @@ -0,0 +1,7 @@ + + + + Parse models as URDF from Collada files. + + + diff --git a/collada_parser/include/collada_parser/collada_parser_plugin.h b/collada_parser/include/collada_parser/collada_parser_plugin.h new file mode 100644 index 0000000..32974db --- /dev/null +++ b/collada_parser/include/collada_parser/collada_parser_plugin.h @@ -0,0 +1,54 @@ +/********************************************************************* +* Software License Agreement (BSD License) +* +* Copyright (c) 2013, Willow Garage, Inc. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. +* * Neither the name of the Willow Garage nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +*********************************************************************/ + +/* Author: Ioan Sucan */ + +#ifndef COLLADA_PARSER_COLLADA_PARSER_PLUGIN_H +#define COLLADA_PARSER_COLLADA_PARSER_PLUGIN_H + +#include + +namespace urdf +{ + +class ColladaURDFParser : public URDFParser +{ +public: + + virtual boost::shared_ptr parse(const std::string &xml_string); +}; + +} + +#endif diff --git a/collada_parser/package.xml b/collada_parser/package.xml index 00048af..1cb3aa1 100644 --- a/collada_parser/package.xml +++ b/collada_parser/package.xml @@ -23,11 +23,13 @@ roscpp urdfdom_headers urdf_parser_plugin + class_loader collada-dom roscpp urdfdom_headers urdf_parser_plugin + class_loader diff --git a/collada_parser/src/collada_parser_plugin.cpp b/collada_parser/src/collada_parser_plugin.cpp new file mode 100644 index 0000000..c4d98b0 --- /dev/null +++ b/collada_parser/src/collada_parser_plugin.cpp @@ -0,0 +1,46 @@ +/********************************************************************* +* Software License Agreement (BSD License) +* +* Copyright (c) 2013, Willow Garage, Inc. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. +* * Neither the name of the Willow Garage nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +*********************************************************************/ + +/* Author: Ioan Sucan */ + +#include "collada_parser/collada_parser_plugin.h" +#include "collada_parser/collada_parser.h" +#include + +boost::shared_ptr urdf::ColladaURDFParser::parse(const std::string &xml_string) +{ + return urdf::parseCollada(xml_string); +} + +CLASS_LOADER_REGISTER_CLASS(urdf::ColladaURDFParser, urdf::URDFParser) diff --git a/robot_model/package.xml b/robot_model/package.xml index 74983d5..26276ff 100644 --- a/robot_model/package.xml +++ b/robot_model/package.xml @@ -38,7 +38,7 @@ ros_comm rosconsole_bridge urdf - urdf_parser + urdf_parser_plugin urdfdom urdfdom_headers joint_state_publisher diff --git a/urdf_parser_plugin/include/urdf_parser_plugin/parser.h b/urdf_parser_plugin/include/urdf_parser_plugin/parser.h index dd04dbf..7032b13 100644 --- a/urdf_parser_plugin/include/urdf_parser_plugin/parser.h +++ b/urdf_parser_plugin/include/urdf_parser_plugin/parser.h @@ -34,6 +34,9 @@ /* Author: Ioan Sucan */ +#ifndef URDF_PARSER_PLUGIN_H +#define URDF_PARSER_PLUGIN_H + #include namespace urdf @@ -55,3 +58,5 @@ public: }; } + +#endif