YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FrameTransformContainer.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef YARP_DEV_FRAMETRANSFORM_UTILS_H
7#define YARP_DEV_FRAMETRANSFORM_UTILS_H
8
9
10#include <yarp/os/Network.h>
12#include <yarp/sig/Vector.h>
14#include <yarp/dev/api.h>
15#include <yarp/dev/PolyDriver.h>
17#include <mutex>
18#include <map>
19
20namespace yarp::dev {
21
34{
35 using ContainerType = std::vector<yarp::math::FrameTransform>;
36
37public:
38 struct Iterator
39 {
40 using iterator_category = std::forward_iterator_tag;
41 using difference_type = ContainerType::difference_type;
42 using value_type = ContainerType::value_type;
43 using pointer = ContainerType::iterator;
45
46 //constructor
47 Iterator(ContainerType& data, ContainerType::iterator ptr) :
48 m_data(data),
49 m_ptr(ptr)
50 {
51 while (m_ptr != m_data.end() && !m_ptr->isValid()) {
52 ++m_ptr;
53 }
54 }
55
56 reference operator*() const { return *m_ptr; }
57 pointer operator->() { return m_ptr; }
58
59 // Prefix increment
61 {
62 do {
63 ++m_ptr;
64 } while (m_ptr != m_data.end() && !m_ptr->isValid());
65 return *this;
66 }
67
68 // Postfix increment
69 Iterator operator++(int) { Iterator tmp = *this; ++(*this); return tmp; }
70
71 friend bool operator== (const Iterator& a, const Iterator& b) { return a.m_ptr == b.m_ptr; };
72 friend bool operator!= (const Iterator& a, const Iterator& b) { return a.m_ptr != b.m_ptr; };
73
74 private:
75 ContainerType::iterator m_ptr;
76 ContainerType& m_data;
77 };
78
79public:
81 {
82 return Iterator(m_transforms, m_transforms.begin());
83 }
84
86 {
87 return Iterator(m_transforms, m_transforms.end());
88 }
89
90protected:
91 ContainerType m_transforms;
92 void invalidateTransform(yarp::math::FrameTransform& trf);
93
94public:
95 mutable std::recursive_mutex m_trf_mutex;
96
97public:
98 //non-static transforms older than value (seconds) will be removed by method checkAndRemoveExpired()
99 double m_timeout = 0.2;
100 bool m_verbose_debug = false;
101 std::string m_name;
102
103public:
106
107 //IFrameTransformStorageSet interface
108 bool setTransforms(const std::vector<yarp::math::FrameTransform>& transforms) override;
109 bool setTransform(const yarp::math::FrameTransform& transform) override;
110
111 //IFrameTransformStorageGet interface
112 bool getTransforms(std::vector<yarp::math::FrameTransform>& transforms) const override;
113
114 //IFrameTransformStorageUtils interface
115 bool deleteTransform(std::string t1, std::string t2) override;
116 bool clearAll() override;
117
118 bool size(size_t& size) const;
119
120public:
121 //other
122 bool checkAndRemoveExpired();
123 bool checkAndRemoveExpired() const;
124};
125
126} // namespace yarp::dev
127
128#endif // YARP_DEV_FRAMETRANSFORM_UTILS_H
bool operator==(const struct v4l2_control &left, const struct v4l2_control &right)
Definition CApiMock.h:65
contains the definition of a Vector type
FrameTransformContainer: A class that contains a vector of frame transformations and exposes yarp::de...
For streams capable of holding different kinds of content, check what they actually have.
Definition jointData.cpp:13
Iterator(ContainerType &data, ContainerType::iterator ptr)
#define YARP_dev_API
Definition api.h:18