MRPT  1.9.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-2018, 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/system/datetime.h>
13 #include <mrpt/poses/SE_traits.h>
14 #include <string>
15 #include <map>
16 
17 namespace mrpt::poses
18 {
20 {
21  LKUP_GOOD = 0,
25 };
26 
27 /** Virtual base class for interfaces to a [ROS
28 * tf2](http://wiki.ros.org/tf2)-like
29 * service capable of "publishing" and "looking-up" relative poses between two
30 * "coordinate frames".
31 * Use derived classes for:
32 * - wrapping real ROS tf (TO-DO in
33 * [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
38 * 105](http://www.ros.org/reps/rep-0105.html#coordinate-frames)
39 * document regarding common names for frames:
40 * - `base_link`: "the robot"
41 * - `odom`: Origin for odometry
42 * - `map`: Origin for "the map"
43 *
44 * \tparam DIM Can be 2 for SE(2), 2D transformations; or 3 for SE(3), 3D
45 * transformations.
46 * \ingroup poses_grp
47 * \sa FrameTransformer, CPose3D
48 */
49 template <int DIM>
51 {
52  public:
53  /** This will be mapped to CPose2D (DIM=2) or CPose3D (DIM=3) */
54  using pose_t = typename SE_traits<DIM>::pose_t;
55  /** This will be mapped to mrpt::math::TPose2D (DIM=2) or
56  * mrpt::math::TPose3D (DIM=3) */
58 
61 
62  /** Publish a time-stampped transform between two frames */
63  virtual void sendTransform(
64  const std::string& parent_frame, const std::string& child_frame,
65  const pose_t& child_wrt_parent,
66  const mrpt::system::TTimeStamp& timestamp = mrpt::system::now()) = 0;
67 
68  /** Queries the current pose of `target_frame` wrt ("as seen from")
69  * `source_frame`.
70  * It tries to return the pose at the given timepoint, unless it is
71  * INVALID_TIMESTAMP (default),
72  * which means returning the latest know transformation.
73  */
75  const std::string& target_frame, const std::string& source_frame,
76  lightweight_pose_t& child_wrt_parent,
78  /** Timeout */
79  const double timeout_secs = .0) = 0;
80 
81 }; // End of class def.
82 
83 /** See docs in FrameTransformerInterface.
84 * This class is an implementation for standalone (non ROS) applications.
85 * \ingroup poses_grp
86 * \sa FrameTransformerInterface
87 */
88 template <int DIM>
90 {
91  public:
93 
96 
97  // See base docs
98  virtual void sendTransform(
99  const std::string& parent_frame, const std::string& child_frame,
100  const typename base_t::pose_t& child_wrt_parent,
101  const mrpt::system::TTimeStamp& timestamp =
102  mrpt::system::now()) override;
103  // See base docs
105  const std::string& target_frame, const std::string& source_frame,
106  typename base_t::lightweight_pose_t& child_wrt_parent,
107  const mrpt::system::TTimeStamp query_time = INVALID_TIMESTAMP,
108  const double timeout_secs = .0) override;
109 
110  /** \overload */
112  const std::string& target_frame, const std::string& source_frame,
113  typename base_t::pose_t& child_wrt_parent,
114  const mrpt::system::TTimeStamp query_time = INVALID_TIMESTAMP,
115  /** Timeout */
116  const double timeout_secs = .0)
117  {
118  typename base_t::lightweight_pose_t p;
120  target_frame, source_frame, p, query_time, timeout_secs);
121  child_wrt_parent = typename base_t::pose_t(p);
122  return ret;
123  }
124 
125  protected:
126  // double m_max_extrapolation_time; //!< for extrapolation in the past or
127  // in the future [s]
128  // double m_max_age_pose_cache; //!< Max age of stored poses [s]
129 
130  struct TF_TreeEdge
131  {
132  // TODO: CPose{2,3}DInterpolator?
135 
137  const typename base_t::pose_t& pose_,
138  const mrpt::system::TTimeStamp& timestamp_)
139  : pose(pose_), timestamp(timestamp_)
140  {
141  }
143  };
144 
145  // map: [parent] -> { [child] -> relPoseChildWRTParent }
146  using pose_tree_t =
150 };
151 
152 }
153 
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) ...
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:87
Virtual base class for interfaces to a ROS tf2-like service capable of "publishing" and "looking-up" ...
std::map< KEY, VALUE, std::less< KEY >, mrpt::aligned_allocator_cpp11< std::pair< const KEY, VALUE > >> aligned_std_map
virtual void sendTransform(const std::string &parent_frame, const std::string &child_frame, const pose_t &child_wrt_parent, const mrpt::system::TTimeStamp &timestamp=mrpt::system::now())=0
Publish a time-stampped transform between two frames.
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) override
Queries the current pose of target_frame wrt ("as seen from") source_frame.
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:40
typename SE_traits< DIM >::pose_t pose_t
This will be mapped to CPose2D (DIM=2) or CPose3D (DIM=3)
GLsizei const GLchar ** string
Definition: glext.h:4101
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
FrameLookUpStatus lookupTransform(const std::string &target_frame, const std::string &source_frame, typename base_t::pose_t &child_wrt_parent, const mrpt::system::TTimeStamp query_time=INVALID_TIMESTAMP, const double timeout_secs=.0)
A helper class for SE(2) and SE(3) geometry-related transformations, on-manifold optimization Jacobia...
Definition: SE_traits.h:27
virtual FrameLookUpStatus lookupTransform(const std::string &target_frame, const std::string &source_frame, lightweight_pose_t &child_wrt_parent, const mrpt::system::TTimeStamp query_time=INVALID_TIMESTAMP, const double timeout_secs=.0)=0
Queries the current pose of target_frame wrt ("as seen from") source_frame.
See docs in FrameTransformerInterface.
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()) override
mrpt::aligned_std_map< std::string, mrpt::aligned_std_map< std::string, TF_TreeEdge > > pose_tree_t
GLfloat GLfloat p
Definition: glext.h:6305
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
Definition: datetime.h:43
TF_TreeEdge(const typename base_t::pose_t &pose_, const mrpt::system::TTimeStamp &timestamp_)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020