pinocchio  2.4.4
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
types.hpp
1 //
2 // Copyright (c) 2015-2020 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_parsers_urdf_types_hpp__
6 #define __pinocchio_parsers_urdf_types_hpp__
7 
8 #include <urdf_model/model.h>
9 
10 #include <string>
11 #include <exception>
12 #ifdef PINOCCHIO_URDFDOM_USE_STD_SHARED_PTR
13 #include <memory>
14 #define PINOCCHIO_URDF_SHARED_PTR(type) std::shared_ptr<type>
15 #define PINOCCHIO_URDF_WEAK_PTR(type) std::weak_ptr<type>
16 #else
17 #include <boost/shared_ptr.hpp>
18 #define PINOCCHIO_URDF_SHARED_PTR(type) boost::shared_ptr<type>
19 #define PINOCCHIO_URDF_WEAK_PTR(type) boost::weak_ptr<type>
20 #endif
21 
22 #ifndef PINOCCHIO_URDFDOM_TYPEDEF_SHARED_PTR
23 
24 #define PINOCCHIO_URDF_TYPEDEF_CLASS_POINTER(Class) \
25 typedef PINOCCHIO_URDF_SHARED_PTR(Class) Class##SharedPtr; \
26 typedef PINOCCHIO_URDF_SHARED_PTR(const Class) Class##ConstSharedPtr; \
27 typedef PINOCCHIO_URDF_WEAK_PTR(Class) Class##WeakPtr
28 
29 namespace urdf
30 {
31  PINOCCHIO_URDF_TYPEDEF_CLASS_POINTER(Box);
32  PINOCCHIO_URDF_TYPEDEF_CLASS_POINTER(Collision);
33  PINOCCHIO_URDF_TYPEDEF_CLASS_POINTER(Cylinder);
34  PINOCCHIO_URDF_TYPEDEF_CLASS_POINTER(Geometry);
35  PINOCCHIO_URDF_TYPEDEF_CLASS_POINTER(Inertial);
36  PINOCCHIO_URDF_TYPEDEF_CLASS_POINTER(Joint);
37  PINOCCHIO_URDF_TYPEDEF_CLASS_POINTER(Link);
38  PINOCCHIO_URDF_TYPEDEF_CLASS_POINTER(Material);
39  PINOCCHIO_URDF_TYPEDEF_CLASS_POINTER(Mesh);
40  PINOCCHIO_URDF_TYPEDEF_CLASS_POINTER(ModelInterface);
41  PINOCCHIO_URDF_TYPEDEF_CLASS_POINTER(Sphere);
42  PINOCCHIO_URDF_TYPEDEF_CLASS_POINTER(Visual);
43 
44  template<class T, class U>
45  PINOCCHIO_URDF_SHARED_PTR(T) const_pointer_cast(PINOCCHIO_URDF_SHARED_PTR(U) const & r)
46  {
47 #ifdef PINOCCHIO_URDFDOM_USE_STD_SHARED_PTR
48  return std::const_pointer_cast<T>(r);
49 #else
50  return boost::const_pointer_cast<T>(r);
51 #endif
52  }
53 
54  template<class T, class U>
55  PINOCCHIO_URDF_SHARED_PTR(T) dynamic_pointer_cast(PINOCCHIO_URDF_SHARED_PTR(U) const & r)
56  {
57 #ifdef PINOCCHIO_URDFDOM_USE_STD_SHARED_PTR
58  return std::dynamic_pointer_cast<T>(r);
59 #else
60  return boost::dynamic_pointer_cast<T>(r);
61 #endif
62  }
63 
64  template<class T, class U>
65  PINOCCHIO_URDF_SHARED_PTR(T) static_pointer_cast(PINOCCHIO_URDF_SHARED_PTR(U) const & r)
66  {
67 #ifdef PINOCCHIO_URDFDOM_USE_STD_SHARED_PTR
68  return std::static_pointer_cast<T>(r);
69 #else
70  return boost::static_pointer_cast<T>(r);
71 #endif
72  }
73 }
74 
75 #undef PINOCCHIO_URDF_TYPEDEF_CLASS_POINTER
76 
77 #else // PINOCCHIO_URDFDOM_TYPEDEF_SHARED_PTR
78 
79 #include <urdf_world/types.h>
80 
81 #endif // PINOCCHIO_URDFDOM_TYPEDEF_SHARED_PTR
82 
83 #endif // ifndef __pinocchio_parsers_urdf_types_hpp__
Definition: types.hpp:29