initial draft of collada to urdf parser (taken from OpenRave implementation) per ticket #4330
This commit is contained in:
parent
ae9109c75b
commit
fa86ca0801
|
@ -52,3 +52,25 @@ Index: dom/make/domTest.mk
|
||||||
ifeq ($(os),ps3)
|
ifeq ($(os),ps3)
|
||||||
# PS3 doesn't support C++ locales, so tell boost not to use them
|
# PS3 doesn't support C++ locales, so tell boost not to use them
|
||||||
ccFlags += -DBOOST_NO_STD_LOCALE
|
ccFlags += -DBOOST_NO_STD_LOCALE
|
||||||
|
|
||||||
|
--- dom/src/dae/daeSIDResolver.cpp
|
||||||
|
+++ dom/src/dae/daeSIDResolver.cpp
|
||||||
|
@@ -152,6 +152,18 @@
|
||||||
|
list<string>& remainingPart) {
|
||||||
|
remainingPart.clear();
|
||||||
|
|
||||||
|
+ // custom change for following instance urls (Rosen Diankov)
|
||||||
|
+ if ( strncmp( container->getElementName(), "instance_", 9 ) == 0 ) {
|
||||||
|
+ daeURI *uri = (daeURI*)container->getAttributeValue("url");
|
||||||
|
+ if ( uri != NULL && uri->getElement() != NULL ) {
|
||||||
|
+ daeElement *e = findWithDots( uri->getElement(), s, profile, finder, remainingPart );
|
||||||
|
+ if ( e != NULL ) {
|
||||||
|
+ //found it
|
||||||
|
+ return e;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
// First see if the whole thing resolves correctly
|
||||||
|
if (daeElement* result = finder(container, s, profile))
|
||||||
|
return result;
|
||||||
|
|
|
@ -22,7 +22,7 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
|
||||||
rosbuild_gensrv()
|
rosbuild_gensrv()
|
||||||
|
|
||||||
#common commands for building c++ executables and libraries
|
#common commands for building c++ executables and libraries
|
||||||
rosbuild_add_library(${PROJECT_NAME} src/link.cpp src/joint.cpp src/model.cpp)
|
rosbuild_add_library(${PROJECT_NAME} src/link.cpp src/joint.cpp src/model.cpp src/collada_model_reader.cpp)
|
||||||
#target_link_libraries(${PROJECT_NAME} another_library)
|
#target_link_libraries(${PROJECT_NAME} another_library)
|
||||||
rosbuild_add_boost_directories()
|
rosbuild_add_boost_directories()
|
||||||
#rosbuild_link_boost(${PROJECT_NAME} thread)
|
#rosbuild_link_boost(${PROJECT_NAME} thread)
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
|
|
||||||
namespace urdf{
|
namespace urdf{
|
||||||
|
|
||||||
|
|
||||||
class Model
|
class Model
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -86,7 +85,7 @@ public:
|
||||||
/// \brief complete list of Materials
|
/// \brief complete list of Materials
|
||||||
std::map<std::string, boost::shared_ptr<Material> > materials_;
|
std::map<std::string, boost::shared_ptr<Material> > materials_;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
std::string name_;
|
std::string name_;
|
||||||
|
@ -105,13 +104,14 @@ private:
|
||||||
/// it's time to find the root Link
|
/// it's time to find the root Link
|
||||||
bool initRoot(std::map<std::string, std::string> &parent_link_tree);
|
bool initRoot(std::map<std::string, std::string> &parent_link_tree);
|
||||||
|
|
||||||
|
private:
|
||||||
/// Model is restricted to a tree for now, which means there exists one root link
|
/// Model is restricted to a tree for now, which means there exists one root link
|
||||||
/// typically, root link is the world(inertial). Where world is a special link
|
/// typically, root link is the world(inertial). Where world is a special link
|
||||||
/// or is the root_link_ the link attached to the world by PLANAR/FLOATING joint?
|
/// or is the root_link_ the link attached to the world by PLANAR/FLOATING joint?
|
||||||
/// hmm...
|
/// hmm...
|
||||||
boost::shared_ptr<Link> root_link_;
|
boost::shared_ptr<Link> root_link_;
|
||||||
|
|
||||||
|
friend class ColladaModelReader;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
<depend package="tinyxml" />
|
<depend package="tinyxml" />
|
||||||
<depend package="roscpp" />
|
<depend package="roscpp" />
|
||||||
|
<depend package="colladadom" />
|
||||||
<export>
|
<export>
|
||||||
<cpp cflags="-I${prefix}/include -I${prefix}/msg/cpp -I${prefix}/srv/cpp" lflags="-Wl,-rpath,${prefix}/lib -L${prefix}/lib -lurdf"/>
|
<cpp cflags="-I${prefix}/include -I${prefix}/msg/cpp -I${prefix}/srv/cpp" lflags="-Wl,-rpath,${prefix}/lib -L${prefix}/lib -lurdf"/>
|
||||||
</export>
|
</export>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -41,6 +41,11 @@
|
||||||
|
|
||||||
namespace urdf{
|
namespace urdf{
|
||||||
|
|
||||||
|
bool urdfFromColladaFile(std::string const& daefilename, Model& model);
|
||||||
|
bool urdfFromColladaData(std::string const& data, Model& model);
|
||||||
|
bool urdfFromTiXML(TiXmlElement *robot_xml, Model& model);
|
||||||
|
bool IsColladaFile(const std::string& filename);
|
||||||
|
bool IsColladaData(const std::string& data);
|
||||||
|
|
||||||
Model::Model()
|
Model::Model()
|
||||||
{
|
{
|
||||||
|
@ -59,6 +64,10 @@ void Model::clear()
|
||||||
|
|
||||||
bool Model::initFile(const std::string& filename)
|
bool Model::initFile(const std::string& filename)
|
||||||
{
|
{
|
||||||
|
// necessary for COLLADA compatibility
|
||||||
|
if( 0&&IsColladaFile(filename) ) {
|
||||||
|
return urdfFromColladaFile(filename,*this);
|
||||||
|
}
|
||||||
TiXmlDocument xml_doc;
|
TiXmlDocument xml_doc;
|
||||||
xml_doc.LoadFile(filename);
|
xml_doc.LoadFile(filename);
|
||||||
|
|
||||||
|
@ -89,6 +98,11 @@ bool Model::initParam(const std::string& param)
|
||||||
|
|
||||||
bool Model::initString(const std::string& xml_string)
|
bool Model::initString(const std::string& xml_string)
|
||||||
{
|
{
|
||||||
|
// necessary for COLLADA compatibility
|
||||||
|
if( IsColladaData(xml_string) ) {
|
||||||
|
return urdfFromColladaData(xml_string,*this);
|
||||||
|
}
|
||||||
|
|
||||||
TiXmlDocument xml_doc;
|
TiXmlDocument xml_doc;
|
||||||
xml_doc.Parse(xml_string.c_str());
|
xml_doc.Parse(xml_string.c_str());
|
||||||
|
|
||||||
|
@ -104,6 +118,13 @@ bool Model::initXml(TiXmlDocument *xml_doc)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// necessary for COLLADA compatibility
|
||||||
|
if( !!xml_doc->RootElement() ) {
|
||||||
|
if( std::string("COLLADA") == xml_doc->RootElement()->ValueStr() ) {
|
||||||
|
return urdfFromTiXML(xml_doc->RootElement(),*this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TiXmlElement *robot_xml = xml_doc->FirstChildElement("robot");
|
TiXmlElement *robot_xml = xml_doc->FirstChildElement("robot");
|
||||||
if (!robot_xml)
|
if (!robot_xml)
|
||||||
{
|
{
|
||||||
|
@ -120,6 +141,11 @@ bool Model::initXml(TiXmlElement *robot_xml)
|
||||||
ROS_DEBUG("Parsing robot xml");
|
ROS_DEBUG("Parsing robot xml");
|
||||||
if (!robot_xml) return false;
|
if (!robot_xml) return false;
|
||||||
|
|
||||||
|
// necessary for COLLADA compatibility
|
||||||
|
if( std::string("COLLADA") == robot_xml->ValueStr() ) {
|
||||||
|
return urdfFromTiXML(robot_xml,*this);
|
||||||
|
}
|
||||||
|
|
||||||
// Get robot name
|
// Get robot name
|
||||||
const char *name = robot_xml->Attribute("name");
|
const char *name = robot_xml->Attribute("name");
|
||||||
if (!name)
|
if (!name)
|
||||||
|
|
Loading…
Reference in New Issue