Skip to content
This repository was archived by the owner on Aug 3, 2020. It is now read-only.

Commit f5a3b80

Browse files
rhaschkewjwwood
authored andcommitted
provide urdf_compatibility.h to define SharedPtr types (#160)
* provide urdf_compatibility.h to define SharedPtr types * create exported include directory * include compatibility header in model.h
1 parent 1bc2669 commit f5a3b80

File tree

3 files changed

+99
-1
lines changed

3 files changed

+99
-1
lines changed

urdf/CMakeLists.txt

+14-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,25 @@ find_package(catkin REQUIRED COMPONENTS
1010

1111
find_package(TinyXML REQUIRED)
1212

13+
if("${urdfdom_headers_VERSION}" VERSION_LESS "1.0")
14+
# for Wily: maintain compatibility between urdfdom 0.3 and 0.4 (definining SharedPtr types)
15+
set(URDFDOM_DECLARE_TYPES 1)
16+
else()
17+
# declare ModelInterface's SharedPtr
18+
set(URDFDOM_DECLARE_TYPES 0)
19+
endif()
20+
set(generated_compat_header "${CATKIN_DEVEL_PREFIX}/include/${PROJECT_NAME}/urdfdom_compatibility.h")
21+
include_directories("${CATKIN_DEVEL_PREFIX}/include")
22+
configure_file(urdfdom_compatibility.h.in "${generated_compat_header}" @ONLY)
23+
1324
catkin_package(
1425
LIBRARIES ${PROJECT_NAME}
15-
INCLUDE_DIRS include ${TinyXML_INLCLUDE_DIRS}
26+
INCLUDE_DIRS include ${TinyXML_INLCLUDE_DIRS} ${CATKIN_DEVEL_PREFIX}/include
1627
CATKIN_DEPENDS rosconsole_bridge roscpp
1728
DEPENDS urdfdom_headers urdfdom Boost
1829
)
30+
install(FILES ${generated_compat_header} DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
31+
1932

2033
include_directories(
2134
include

urdf/include/urdf/model.h

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <string>
4141
#include <map>
4242
#include <urdf_model/model.h>
43+
#include <urdf/urdfdom_compatibility.h>
4344
#include <tinyxml.h>
4445
#include <boost/shared_ptr.hpp>
4546
#include <boost/weak_ptr.hpp>

urdf/urdfdom_compatibility.h.in

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*********************************************************************
2+
* Software License Agreement (BSD License)
3+
*
4+
* Copyright (c) 2016, CITEC, Bielefeld University
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions
9+
* are met:
10+
*
11+
* * Redistributions of source code must retain the above copyright
12+
* notice, this list of conditions and the following disclaimer.
13+
* * Redistributions in binary form must reproduce the above
14+
* copyright notice, this list of conditions and the following
15+
* disclaimer in the documentation and/or other materials provided
16+
* with the distribution.
17+
* * Neither the name of the Willow Garage nor the names of its
18+
* contributors may be used to endorse or promote products derived
19+
* from this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
* POSSIBILITY OF SUCH DAMAGE.
33+
*********************************************************************/
34+
35+
/* Robert Haschke */
36+
37+
#ifndef URDF_URDFDOM_COMPATIBILITY_
38+
#define URDF_URDFDOM_COMPATIBILITY_
39+
40+
#if @URDFDOM_DECLARE_TYPES@ // This is needed for urdfdom <= 0.4
41+
42+
#include <boost/shared_ptr.hpp>
43+
#include <boost/weak_ptr.hpp>
44+
45+
#define URDF_TYPEDEF_CLASS_POINTER(Class) \
46+
class Class; \
47+
typedef boost::shared_ptr<Class> Class##SharedPtr; \
48+
typedef boost::shared_ptr<const Class> Class##ConstSharedPtr; \
49+
typedef boost::weak_ptr<Class> Class##WeakPtr
50+
51+
namespace urdf {
52+
URDF_TYPEDEF_CLASS_POINTER(Box);
53+
URDF_TYPEDEF_CLASS_POINTER(Collision);
54+
URDF_TYPEDEF_CLASS_POINTER(Cylinder);
55+
URDF_TYPEDEF_CLASS_POINTER(Geometry);
56+
URDF_TYPEDEF_CLASS_POINTER(Inertial);
57+
58+
URDF_TYPEDEF_CLASS_POINTER(Joint);
59+
URDF_TYPEDEF_CLASS_POINTER(JointCalibration);
60+
URDF_TYPEDEF_CLASS_POINTER(JointDynamics);
61+
URDF_TYPEDEF_CLASS_POINTER(JointLimits);
62+
URDF_TYPEDEF_CLASS_POINTER(JointMimic);
63+
URDF_TYPEDEF_CLASS_POINTER(JointSafety);
64+
65+
URDF_TYPEDEF_CLASS_POINTER(Link);
66+
URDF_TYPEDEF_CLASS_POINTER(Material);
67+
URDF_TYPEDEF_CLASS_POINTER(Mesh);
68+
URDF_TYPEDEF_CLASS_POINTER(Sphere);
69+
URDF_TYPEDEF_CLASS_POINTER(Visual);
70+
71+
URDF_TYPEDEF_CLASS_POINTER(ModelInterface);
72+
}
73+
74+
#undef URDF_TYPEDEF_CLASS_POINTER
75+
76+
#else // urdfdom <= 0.4
77+
78+
typedef std::shared_ptr<ModelInterface> ModelInterfaceSharedPtr;
79+
typedef std::shared_ptr<const ModelInterface> ModelInterfaceConstSharedPtr;
80+
typedef std::weak_ptr<ModelInterface> ModelInterfaceWeakPtr;
81+
82+
#endif // urdfdom > 0.4
83+
84+
#endif // URDF_URDFDOM_COMPATIBILITY_

0 commit comments

Comments
 (0)