collada_urdf: link Boost.System
This commit is contained in:
parent
b24bcc5aa6
commit
2083f8ef9a
|
@ -3,6 +3,12 @@ include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
|
|||
set(ROS_BUILD_TYPE Debug)
|
||||
rosbuild_init()
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
|
||||
rosbuild_add_executable(urdf_to_collada src/urdf_to_collada.cpp src/collada_writer.cpp src/stl_loader.cpp)
|
||||
|
||||
rosbuild_add_gtest(test_collada_writer test/test_collada_writer.cpp src/collada_writer.cpp src/stl_loader.cpp)
|
||||
rosbuild_add_library(collada_urdf src/collada_urdf.cpp src/collada_writer.cpp src/stl_loader.cpp)
|
||||
rosbuild_link_boost(collada_urdf system)
|
||||
|
||||
rosbuild_add_executable(urdf_to_collada src/urdf_to_collada.cpp)
|
||||
target_link_libraries(urdf_to_collada collada_urdf)
|
||||
|
||||
rosbuild_add_gtest(test_collada_writer test/test_collada_urdf.cpp)
|
||||
target_link_libraries(test_collada_writer collada_urdf)
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*********************************************************************/
|
||||
|
||||
/* Author: Tim Field */
|
||||
|
||||
#ifndef COLLADA_URDF_COLLADA_WRITER_H
|
||||
#define COLLADA_URDF_COLLADA_WRITER_H
|
||||
|
||||
|
@ -59,36 +61,6 @@ public:
|
|||
ColladaWriterException(std::string const& what) : std::runtime_error(what) { }
|
||||
};
|
||||
|
||||
/** Constructs a COLLADA DOM from a file, given the file name
|
||||
* \param file The filename from where to read the XML
|
||||
* \param dom The resulting COLLADA DOM
|
||||
* \return true on success, false on failure
|
||||
*/
|
||||
bool colladaFromFile(std::string const& file, boost::shared_ptr<DAE>& dom);
|
||||
|
||||
/** Constructs a COLLADA DOM from a string containing XML
|
||||
* \param xml A string containing the XML description of the robot
|
||||
* \param dom The resulting COLLADA DOM
|
||||
* \return true on success, false on failure
|
||||
*/
|
||||
bool colladaFromString(std::string const& xml, boost::shared_ptr<DAE>& dom);
|
||||
|
||||
/** Constructs a COLLADA DOM from a TiXmlDocument
|
||||
* \param xml_doc The TiXmlDocument containing the XML description of the robot
|
||||
* \param dom The resulting COLLADA DOM
|
||||
* \return true on success, false on failure
|
||||
*/
|
||||
bool colladaFromXml(TiXmlDocument* xml_doc, boost::shared_ptr<DAE>& dom);
|
||||
|
||||
/** Constructs a COLLADA DOM from a URDF robot model
|
||||
* \param robot_model The URDF robot model
|
||||
* \param dom The resulting COLLADA DOM
|
||||
* \return true on success, false on failure
|
||||
*/
|
||||
bool colladaFromUrdfModel(urdf::Model const& robot_model, boost::shared_ptr<DAE>& dom);
|
||||
|
||||
//
|
||||
|
||||
class Mesh;
|
||||
|
||||
class ColladaWriter : public daeErrorHandler
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*********************************************************************/
|
||||
|
||||
/* Author: Tim Field */
|
||||
|
||||
#ifndef COLLADA_URDF_STL_LOADER_H
|
||||
#define COLLADA_URDF_STL_LOADER_H
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*********************************************************************/
|
||||
|
||||
/* Author: Tim Field */
|
||||
|
||||
#include "collada_urdf/collada_writer.h"
|
||||
|
||||
#include "collada_urdf/stl_loader.h"
|
||||
|
@ -49,45 +51,6 @@ using boost::shared_ptr;
|
|||
|
||||
namespace collada_urdf {
|
||||
|
||||
bool colladaFromFile(std::string const& file, boost::shared_ptr<DAE>& dom) {
|
||||
TiXmlDocument urdf_xml;
|
||||
if (!urdf_xml.LoadFile(file)) {
|
||||
ROS_ERROR("Could not load XML file");
|
||||
return false;
|
||||
}
|
||||
|
||||
return colladaFromXml(&urdf_xml, dom);
|
||||
}
|
||||
|
||||
bool colladaFromString(std::string const& xml, boost::shared_ptr<DAE>& dom) {
|
||||
TiXmlDocument urdf_xml;
|
||||
if (urdf_xml.Parse(xml.c_str()) == 0) {
|
||||
ROS_ERROR("Could not parse XML document");
|
||||
return false;
|
||||
}
|
||||
|
||||
return colladaFromXml(&urdf_xml, dom);
|
||||
}
|
||||
|
||||
bool colladaFromXml(TiXmlDocument* xml_doc, boost::shared_ptr<DAE>& dom) {
|
||||
urdf::Model robot_model;
|
||||
if (!robot_model.initXml(xml_doc)) {
|
||||
ROS_ERROR("Could not generate robot model");
|
||||
return false;
|
||||
}
|
||||
|
||||
return colladaFromUrdfModel(robot_model, dom);
|
||||
}
|
||||
|
||||
bool colladaFromUrdfModel(urdf::Model const& robot_model, boost::shared_ptr<DAE>& dom) {
|
||||
ColladaWriter writer(robot_model);
|
||||
dom = writer.convert();
|
||||
|
||||
return dom != shared_ptr<DAE>();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
ColladaWriter::ColladaWriter(urdf::Model const& robot) : robot_(robot), dom_(NULL) { }
|
||||
|
||||
shared_ptr<DAE> ColladaWriter::convert() {
|
||||
|
@ -310,7 +273,7 @@ bool ColladaWriter::loadMeshWithSTLLoader(resource_retriever::MemoryResource con
|
|||
if (fd == -1)
|
||||
throw ColladaWriterException("Couldn't create temporary file");
|
||||
|
||||
if (write(fd, resource.data.get(), resource.size) != resource.size) {
|
||||
if ((uint32_t) write(fd, resource.data.get(), resource.size) != resource.size) {
|
||||
close(fd);
|
||||
unlink(tmp_filename);
|
||||
throw ColladaWriterException("Couldn't write resource to file");
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*********************************************************************/
|
||||
|
||||
/* Author: Tim Field */
|
||||
|
||||
#include "collada_urdf/stl_loader.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
|
|
@ -32,7 +32,9 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*********************************************************************/
|
||||
|
||||
#include "collada_urdf/collada_writer.h"
|
||||
/* Author: Tim Field */
|
||||
|
||||
#include "collada_urdf/collada_urdf.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "collada_urdf/collada_writer.h"
|
||||
/* Author: Tim Field */
|
||||
|
||||
#include "collada_urdf/collada_urdf.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
Loading…
Reference in New Issue