update to collada 2.4.0 support and assimp3.0 support. collada_parser now including urdf_model/X.h (from urdfdom) instead of urdf_interface/X.h

This commit is contained in:
Rosen Diankov 2012-06-21 14:14:09 +09:00
parent 4195e88320
commit 4ffd7658d7
6 changed files with 69 additions and 25 deletions

View File

@ -11,11 +11,15 @@ include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
rosbuild_init() rosbuild_init()
rosbuild_add_boost_directories()
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake-extensions/ ) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake-extensions/ )
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules(COLLADADOM collada15dom) find_package(COLLADA_DOM 2.3 COMPONENTS 1.5)
include_directories(${COLLADADOM_INCLUDE_DIRS}) if( COLLADA_DOM_FOUND )
#link_directories(${COLLADADOM_LIBRARY_DIRS}) include_directories(${COLLADA_DOM_INCLUDE_DIRS})
#link_directories(${COLLADA_DOM_LIBRARY_DIRS})
endif()
#set the default path for built executables to the "bin" directory #set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
@ -31,11 +35,14 @@ endif()
#common commands for building c++ executables and libraries #common commands for building c++ executables and libraries
rosbuild_add_library(${PROJECT_NAME} src/collada_parser.cpp) rosbuild_add_library(${PROJECT_NAME} src/collada_parser.cpp)
rosbuild_add_compile_flags(${PROJECT_NAME} "${COLLADA_DOM_CFLAGS_OTHER}")
rosbuild_add_link_flags(${PROJECT_NAME} "${COLLADA_DOM_LDFLAGS_OTHER}")
if(APPLE) if(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") rosbuild_add_link_flags(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
endif(APPLE) endif(APPLE)
#target_link_libraries(${PROJECT_NAME} another_library) #target_link_libraries(${PROJECT_NAME} another_library)
rosbuild_add_boost_directories()
#rosbuild_link_boost(${PROJECT_NAME} thread) #rosbuild_link_boost(${PROJECT_NAME} thread)

View File

@ -1,13 +1,13 @@
/********************************************************************* /*********************************************************************
* Software License Agreement (BSD License) * Software License Agreement (BSD License)
* *
* Copyright (c) 2008, Willow Garage, Inc. * Copyright (c) 2008, Willow Garage, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* *
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above * * Redistributions in binary form must reproduce the above
@ -17,7 +17,7 @@
* * Neither the name of the Willow Garage nor the names of its * * Neither the name of the Willow Garage nor the names of its
* contributors may be used to endorse or promote products derived * contributors may be used to endorse or promote products derived
* from this software without specific prior written permission. * from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@ -41,13 +41,13 @@
#include <map> #include <map>
#include <boost/function.hpp> #include <boost/function.hpp>
#include <urdf_interface/model.h> #include <urdf_model/model.h>
namespace urdf{ namespace urdf {
/// \brief Load Model from string /// \brief Load Model from string
boost::shared_ptr<ModelInterface> parseCollada(const std::string &xml_string ); boost::shared_ptr<ModelInterface> parseCollada(const std::string &xml_string );
} }

View File

@ -17,8 +17,8 @@
<rosdep name="colladadom"/> <rosdep name="colladadom"/>
<export> <export>
<cpp cflags="-I${prefix}/include `pkg-config --cflags collada15dom`" <cpp cflags="-I${prefix}/include `pkg-config --silence-errors --cflags collada15dom` `pkg-config --silence-errors --cflags collada-dom-150` "
lflags="-Wl,-rpath,${prefix}/lib -L${prefix}/lib -lcollada_parser `pkg-config --libs collada15dom`"/> lflags="-Wl,-rpath,${prefix}/lib -L${prefix}/lib -lcollada_parser `pkg-config --silence-errors --libs collada15dom` `pkg-config --silence-errors --libs collada-dom-150`"/>
</export> </export>
</package> </package>

View File

@ -56,7 +56,7 @@
#include <ros/ros.h> #include <ros/ros.h>
#include <collada_parser/collada_parser.h> #include <collada_parser/collada_parser.h>
#include <urdf_interface/model.h> #include <urdf_model/model.h>
#ifndef HAVE_MKSTEMPS #ifndef HAVE_MKSTEMPS
#include <fstream> #include <fstream>
@ -419,7 +419,7 @@ public:
bool InitFromFile(const std::string& filename) { bool InitFromFile(const std::string& filename) {
ROS_DEBUG_STREAM(str(boost::format("init COLLADA reader version: %s, namespace: %s, filename: %s\n")%COLLADA_VERSION%COLLADA_NAMESPACE%filename)); ROS_DEBUG_STREAM(str(boost::format("init COLLADA reader version: %s, namespace: %s, filename: %s\n")%COLLADA_VERSION%COLLADA_NAMESPACE%filename));
_collada.reset(new DAE); _collada.reset(new DAE);
_dom = _collada->open(filename); _dom = (domCOLLADA*)_collada->open(filename);
if (!_dom) { if (!_dom) {
return false; return false;
} }
@ -438,7 +438,7 @@ public:
bool InitFromData(const std::string& pdata) { bool InitFromData(const std::string& pdata) {
ROS_DEBUG_STREAM(str(boost::format("init COLLADA reader version: %s, namespace: %s\n")%COLLADA_VERSION%COLLADA_NAMESPACE)); ROS_DEBUG_STREAM(str(boost::format("init COLLADA reader version: %s, namespace: %s\n")%COLLADA_VERSION%COLLADA_NAMESPACE));
_collada.reset(new DAE); _collada.reset(new DAE);
_dom = _collada->openFromMemory(".",pdata.c_str()); _dom = (domCOLLADA*)_collada->openFromMemory(".",pdata.c_str());
if (!_dom) { if (!_dom) {
return false; return false;
} }

View File

@ -6,9 +6,34 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
link_libraries(tinyxml) link_libraries(tinyxml)
find_package(ASSIMP)
if( NOT ASSIMP_FOUND )
pkg_check_modules(ASSIMP assimp)
endif()
if( ASSIMP_FOUND )
if( ${ASSIMP_VERSION} STRGREATER "2.0.0" )
set(IS_ASSIMP3 1)
add_definitions(-DIS_ASSIMP3)
endif()
include_directories(${ASSIMP_INCLUDE_DIRS})
link_directories(${ASSIMP_LIBRARY_DIRS})
else()
message(STATUS "could not find assimp (perhaps available thorugh ROS package?), so assimping assimp v2")
set(ASSIMP_LIBRARIES assimp)
set(ASSIMP_LIBRARY_DIRS)
set(ASSIMP_CXX_FLAGS)
set(ASSIMP_CFLAGS_OTHER)
set(ASSIMP_LINK_FLAGS)
set(ASSIMP_INCLUDE_DIRS)
set(IS_ASSIMP3 0) # most likely not
endif()
rosbuild_add_library(collada_urdf src/collada_urdf.cpp) rosbuild_add_library(collada_urdf src/collada_urdf.cpp)
rosbuild_link_boost(collada_urdf system) rosbuild_link_boost(collada_urdf system)
target_link_libraries(collada_urdf assimp) target_link_libraries(collada_urdf ${ASSIMP_LIBRARIES})
rosbuild_add_compile_flags(collada_urdf "${ASSIMP_CXX_FLAGS} ${ASSIMP_CFLAGS_OTHER}")
rosbuild_add_link_flags(collada_urdf "${ASSIMP_LINK_FLAGS}")
rosbuild_add_executable(urdf_to_collada src/urdf_to_collada.cpp) rosbuild_add_executable(urdf_to_collada src/urdf_to_collada.cpp)
target_link_libraries(urdf_to_collada collada_urdf) target_link_libraries(urdf_to_collada collada_urdf)

View File

@ -51,7 +51,7 @@
#include <dom/domTypes.h> #include <dom/domTypes.h>
#include <resource_retriever/retriever.h> #include <resource_retriever/retriever.h>
#include <urdf/model.h> #include <urdf/model.h>
#include <urdf_interface/pose.h> #include <urdf_model/pose.h>
#include <angles/angles.h> #include <angles/angles.h>
#include <ros/assert.h> #include <ros/assert.h>
@ -60,11 +60,23 @@
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/array.hpp> #include <boost/array.hpp>
#include <assimp/assimp.hpp> #if defined(IS_ASSIMP3)
#include <assimp/aiScene.h> #include <assimp/scene.h>
#include <assimp/aiPostProcess.h> #include <assimp/LogStream.hpp>
#include <assimp/IOStream.h> #include <assimp/DefaultLogger.hpp>
#include <assimp/IOSystem.h> #include <assimp/IOStream.hpp>
#include <assimp/IOSystem.hpp>
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
#else
#include <assimp.hpp>
#include <aiScene.h>
#include <aiPostProcess.h>
#include <DefaultLogger.h>
#include <IOStream.h>
#include <IOSystem.h>
#endif
#define FOREACH(it, v) for(typeof((v).begin())it = (v).begin(); it != (v).end(); (it)++) #define FOREACH(it, v) for(typeof((v).begin())it = (v).begin(); it != (v).end(); (it)++)
#define FOREACHC FOREACH #define FOREACHC FOREACH