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>
18#include <mutex>
19#include <map>
20
21namespace yarp::dev {
22
35{
36 using ContainerType = std::vector<yarp::math::FrameTransform>;
37
38public:
39 struct Iterator
40 {
41 using iterator_category = std::forward_iterator_tag;
42 using difference_type = ContainerType::difference_type;
43 using value_type = ContainerType::value_type;
44 using pointer = ContainerType::iterator;
46
47 //constructor
48 Iterator(ContainerType& data, ContainerType::iterator ptr) :
49 m_data(data),
50 m_ptr(ptr)
51 {
52 while (m_ptr != m_data.end() && !m_ptr->isValid()) {
53 ++m_ptr;
54 }
55 }
56
57 reference operator*() const { return *m_ptr; }
58 pointer operator->() { return m_ptr; }
59
60 // Prefix increment
62 {
63 do {
64 ++m_ptr;
65 } while (m_ptr != m_data.end() && !m_ptr->isValid());
66 return *this;
67 }
68
69 // Postfix increment
70 Iterator operator++(int) { Iterator tmp = *this; ++(*this); return tmp; }
71
72 friend bool operator== (const Iterator& a, const Iterator& b) { return a.m_ptr == b.m_ptr; };
73 friend bool operator!= (const Iterator& a, const Iterator& b) { return a.m_ptr != b.m_ptr; };
74
75 private:
76 ContainerType::iterator m_ptr;
77 ContainerType& m_data;
78 };
79
80public:
82 {
83 return Iterator(m_transforms, m_transforms.begin());
84 }
85
87 {
88 return Iterator(m_transforms, m_transforms.end());
89 }
90
91protected:
92 ContainerType m_transforms;
93 void invalidateTransform(yarp::math::FrameTransform& trf);
94
95public:
96 mutable std::recursive_mutex m_trf_mutex;
97
98public:
99 //non-static transforms older than value (seconds) will be removed by method checkAndRemoveExpired()
100 double m_timeout = 0.2;
101 bool m_verbose_debug = false;
102 std::string m_name;
103
104public:
107
108 //IFrameTransformStorageSet interface
109 yarp::dev::ReturnValue setTransforms(const std::vector<yarp::math::FrameTransform>& transforms) override;
110 yarp::dev::ReturnValue setTransform(const yarp::math::FrameTransform& transform) override;
111
112 //IFrameTransformStorageGet interface
113 yarp::dev::ReturnValue getTransforms(std::vector<yarp::math::FrameTransform>& transforms) const override;
114
115 //IFrameTransformStorageUtils interface
116 yarp::dev::ReturnValue deleteTransform(std::string t1, std::string t2) override;
117 yarp::dev::ReturnValue clearAll() override;
118
119 bool size(size_t& size) const;
120
121public:
122 //other
123 bool checkAndRemoveExpired();
124 bool checkAndRemoveExpired() const;
125};
126
127} // namespace yarp::dev
128
129#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.
Iterator(ContainerType &data, ContainerType::iterator ptr)
#define YARP_dev_API
Definition api.h:18