ApproximateTimeQueue.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @author Fabian Reister ( fabian dot reister at kit dot edu )
17 * @date 2021
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
22#pragma once
23
24#include <mutex>
25#include <set>
26#include <shared_mutex>
27
28#include <boost/thread/concurrent_queues/sync_queue.hpp>
29
30#include <Eigen/Geometry>
31
33
35
36#include "interfaces.h"
37#include "types.h"
38
40{
42 {
44 Eigen::Isometry3f
45 robotPoseCorrection; // from pose where data was captured to timestamp pose
46 };
47
48 using LaserMessages = std::vector<LaserMessage>;
49
58
59 /**
60 * @brief The ApproximateTimeQueue class.
61 *
62 * Synchronizes incoming data and returns shapshots.
63 *
64 */
66 {
67 public:
68 /**
69 * @brief Construct a new Approximate Time Queue object
70 *
71 * @param dt [µs] time delay to limit processing of messages (inverse of frequency)
72 * @param laserSensorIds the laser sensors that are used
73 * @param messageCallee once messages are available, the data will be made available to the MessageCallee
74 */
76 int64_t dtHistoryLength,
77 const std::set<std::string>& laserSensorIds,
78 MessageCallee& messageCallee,
79 bool useOdometry);
80
82 void insertOdomData(
84
85
86 private:
87 bool allDataAvailable(int64_t timestamp) const;
88
89 void processAvailableData(int64_t timestamp);
90 void processAllAvailableData(int64_t timestamp);
91 void trimUntil(const int64_t& timestamp);
92
93 const int64_t dtEps; // [µs]
94 const int64_t dtHistoryLength; // [µs]
95
96 int64_t lastProcessedTimestamp{0};
97
98 using LaserTimeQueue =
100
103 odomQueue;
104 std::unordered_map<std::string, LaserTimeQueue> laserQueues;
105
106 MessageCallee& messageCallee;
107
108 void serveMessageCallee();
109
110 boost::sync_queue<TimedData> timedDataQueue;
111 armarx::SimpleRunningTask<>::pointer_type messageCalleeTask = nullptr;
112 const bool useOdometry;
113 };
114
115} // namespace armarx::localization_and_mapping::cartographer_adapter
std::string timestamp()
constexpr T dt
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
ApproximateTimeQueue(int64_t dt, int64_t dtHistoryLength, const std::set< std::string > &laserSensorIds, MessageCallee &messageCallee, bool useOdometry)
Construct a new Approximate Time Queue object.
void insertOdomData(armarx::localization_and_mapping::cartographer_adapter::PoseStamped odomPose)
armarx::localization_and_mapping::cartographer_adapter::PoseStamped odomPose