fixed urdf compilation for older linux distros that do not have msktemps
This commit is contained in:
parent
7d260dc855
commit
2758eff268
|
@ -21,6 +21,12 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
|
||||||
|
|
||||||
rosbuild_gensrv()
|
rosbuild_gensrv()
|
||||||
|
|
||||||
|
# necessary for collada reader to create the temporary dae files due to limitations in the URDF geometry
|
||||||
|
check_function_exists(mkstemps HAVE_MKSTEMPS)
|
||||||
|
if( HAVE_MKSTEMPS )
|
||||||
|
add_definitions("-DHAVE_MKSTEMPS")
|
||||||
|
endif()
|
||||||
|
|
||||||
#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 src/collada_model_reader.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)
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <cstdlib>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -55,6 +56,11 @@
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
#ifndef HAVE_MKSTEMPS
|
||||||
|
#include <fstream>
|
||||||
|
#include <fcntl.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
|
||||||
|
|
||||||
|
@ -1110,9 +1116,19 @@ protected:
|
||||||
</scene>\n\
|
</scene>\n\
|
||||||
</COLLADA>")%name%name);
|
</COLLADA>")%name%name);
|
||||||
|
|
||||||
//= str(boost::format("%s/models/%s.dae")%_resourcedir%name);
|
#ifdef HAVE_MKSTEMPS
|
||||||
geometry->filename = str(boost::format("/tmp/collada_model_reader_%s_XXXXXX.dae")%name);
|
geometry->filename = str(boost::format("/tmp/collada_model_reader_%s_XXXXXX.dae")%name);
|
||||||
int fd = mkstemps(&geometry->filename[0],4);
|
int fd = mkstemps(&geometry->filename[0],4);
|
||||||
|
#else
|
||||||
|
do {
|
||||||
|
geometry->filename = str(boost::format("/tmp/collada_model_reader_%s_%d.dae")%name%rand());
|
||||||
|
} while(!!std::ifstream(geometry->filename.c_str()));
|
||||||
|
int fd = open(geometry->filename.c_str(),O_WRONLY|O_CREAT|O_EXCL);
|
||||||
|
if( fd == -1 ) {
|
||||||
|
ROS_ERROR("failed to open geometry dae file %s",geometry->filename.c_str());
|
||||||
|
return geometry;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
//ROS_INFO("temp file: %s",geometry->filename.c_str());
|
//ROS_INFO("temp file: %s",geometry->filename.c_str());
|
||||||
std::string daedatastr = daedata.str();
|
std::string daedatastr = daedata.str();
|
||||||
if( (size_t)write(fd,daedatastr.c_str(),daedatastr.size()) != daedatastr.size() ) {
|
if( (size_t)write(fd,daedatastr.c_str(),daedatastr.size()) != daedatastr.size() ) {
|
||||||
|
|
Loading…
Reference in New Issue