Main MRPT website > C++ reference for MRPT 1.5.9
FrameTransformer.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/base/link_pragmas.h>
12 #include <mrpt/system/datetime.h>
14  //#include <mrpt/poses/CPose3DInterpolator.h>
15 #include <mrpt/poses/SE_traits.h>
16 #include <string>
17 #include <map>
18 
19 namespace mrpt {
20 namespace poses {
21 
23  LKUP_GOOD = 0,
27 };
28 
29 
30 /** Virtual base class for interfaces to a [ROS tf2](http://wiki.ros.org/tf2)-like
31 * service capable of "publishing" and "looking-up" relative poses between two "coordinate frames".
32 * Use derived classes for:
33 * - wrapping real ROS tf (TO-DO in [mrpt-bridge](http://wiki.ros.org/mrpt_bridge)), or
34 * - using a pure MRPT standalone TF service with mrpt::poses::FrameTransformer
35 *
36 * Frame IDs are strings.
37 * MRPT modules use the standard ROS [REP 105](http://www.ros.org/reps/rep-0105.html#coordinate-frames)
38 * document regarding common names for frames:
39 * - `base_link`: "the robot"
40 * - `odom`: Origin for odometry
41 * - `map`: Origin for "the map"
42 *
43 * \tparam DIM Can be 2 for SE(2), 2D transformations; or 3 for SE(3), 3D transformations.
44 * \ingroup poses_grp
45 * \sa FrameTransformer, CPose3D
46 */
47 template <int DIM>
49 {
50 public:
51  typedef typename SE_traits<DIM>::pose_t pose_t; //!< This will be mapped to CPose2D (DIM=2) or CPose3D (DIM=3)
52  typedef typename SE_traits<DIM>::lightweight_pose_t lightweight_pose_t; //!< This will be mapped to mrpt::math::TPose2D (DIM=2) or mrpt::math::TPose3D (DIM=3)
53 
55  virtual ~FrameTransformerInterface();
56 
57  /** Publish a time-stampped transform between two frames */
58  virtual void sendTransform(
59  const std::string & parent_frame,
60  const std::string & child_frame,
61  const pose_t & child_wrt_parent,
62  const mrpt::system::TTimeStamp & timestamp = mrpt::system::now()
63  ) = 0;
64 
65  /** Queries the current pose of `target_frame` wrt ("as seen from") `source_frame`.
66  * It tries to return the pose at the given timepoint, unless it is INVALID_TIMESTAMP (default),
67  * which means returning the latest know transformation.
68  */
69  virtual FrameLookUpStatus lookupTransform(
70  const std::string & target_frame,
71  const std::string & source_frame,
72  lightweight_pose_t & child_wrt_parent,
74  const double timeout_secs = .0 //!< Timeout
75  ) = 0;
76 
77 }; // End of class def.
78 
79 /** See docs in FrameTransformerInterface.
80 * This class is an implementation for standalone (non ROS) applications.
81 * \ingroup poses_grp
82 * \sa FrameTransformerInterface
83 */
84 template <int DIM>
86 {
87 public:
89 
92 
93  // See base docs
94  virtual void sendTransform(const std::string & parent_frame,const std::string & child_frame,const typename base_t::pose_t & child_wrt_parent, const mrpt::system::TTimeStamp & timestamp = mrpt::system::now() ) MRPT_OVERRIDE;
95  // See base docs
96  virtual FrameLookUpStatus lookupTransform(const std::string & target_frame, const std::string & source_frame, typename base_t::lightweight_pose_t & child_wrt_parent, const mrpt::system::TTimeStamp query_time = INVALID_TIMESTAMP, const double timeout_secs = .0) MRPT_OVERRIDE;
97 
98  /** \overload */
99  FrameLookUpStatus lookupTransform(
100  const std::string & target_frame,
101  const std::string & source_frame,
102  typename base_t::pose_t & child_wrt_parent,
103  const mrpt::system::TTimeStamp query_time = INVALID_TIMESTAMP,
104  const double timeout_secs = .0 //!< Timeout
105  )
106  {
107  typename base_t::lightweight_pose_t p;
108  FrameLookUpStatus ret = lookupTransform(target_frame, source_frame,p, query_time, timeout_secs);
109  child_wrt_parent = typename base_t::pose_t(p);
110  return ret;
111  }
112 
113 protected:
114  //double m_max_extrapolation_time; //!< for extrapolation in the past or in the future [s]
115  //double m_max_age_pose_cache; //!< Max age of stored poses [s]
116 
118  {
119  // TODO: CPose{2,3}DInterpolator?
122 
123  TF_TreeEdge(const typename base_t::pose_t &pose_, const mrpt::system::TTimeStamp &timestamp_) :
124  pose(pose_),
125  timestamp(timestamp_)
126  {}
127  TF_TreeEdge() : timestamp(INVALID_TIMESTAMP) {}
128  };
129 
130  // map: [parent] -> { [child] -> relPoseChildWRTParent }
131  typedef std::map<std::string, typename mrpt::aligned_containers<std::string, TF_TreeEdge>::map_t> pose_tree_t;
133 };
134 
135 } // ns
136 } // ns
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:30
SE_traits< DIM >::pose_t pose_t
This will be mapped to CPose2D (DIM=2) or CPose3D (DIM=3)
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:70
Virtual base class for interfaces to a ROS tf2-like service capable of "publishing" and "looking-up" ...
STL namespace.
FrameTransformerInterface< DIM > base_t
std::map< std::string, typename mrpt::aligned_containers< std::string, TF_TreeEdge >::map_t > pose_tree_t
GLsizei const GLchar ** string
Definition: glext.h:3919
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
Definition: datetime.h:17
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
See docs in FrameTransformerInterface.
GLfloat GLfloat p
Definition: glext.h:5587
SE_traits< DIM >::lightweight_pose_t lightweight_pose_t
This will be mapped to mrpt::math::TPose2D (DIM=2) or mrpt::math::TPose3D (DIM=3) ...
TF_TreeEdge(const typename base_t::pose_t &pose_, const mrpt::system::TTimeStamp &timestamp_)



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020