YARP
Yet Another Robot Platform
FrameTransformGetMultiplexer.cpp
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 /*
7  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
8  * SPDX-License-Identifier: BSD-3-Clause
9  */
10 
12 
13 #include <yarp/os/LogComponent.h>
14 #include <yarp/os/LogStream.h>
15 
16 using namespace yarp::sig;
17 using namespace yarp::dev;
18 using namespace yarp::os;
19 
20 YARP_LOG_COMPONENT(FRAMETRANSFORMGETMULTIPLEXER, "yarp.devices.FrameTransformGetMultiplexer")
21 
22 
23 
25 {
27  yCError(FRAMETRANSFORMGETMULTIPLEXER,"Error! YARP Network is not initialized");
28  return false;
29  }
30  return true;
31 }
32 
33 
34 
36 {
37  m_iFrameTransformStorageGetList.clear();
38  return true;
39 }
40 
41 
43 {
45  detachAll();
46  return true;
47 }
48 
49 
51 {
52  for (int i = 0; i < devices2attach.size(); i++)
53  {
54  yarp::dev::PolyDriver* polyDriverLocal = devices2attach[i]->poly;
55  if (polyDriverLocal->isValid())
56  {
57  yarp::dev::IFrameTransformStorageGet* iFrameTransformStorageGet=nullptr;
58  if (polyDriverLocal->view(iFrameTransformStorageGet) && iFrameTransformStorageGet!=nullptr)
59  {
60  m_iFrameTransformStorageGetList.push_back(iFrameTransformStorageGet);
61  }
62  else
63  {
64  yCError(FRAMETRANSFORMGETMULTIPLEXER) << "failed to attach all the devices";
65  return false;
66  }
67  }
68  else
69  {
70  yCError(FRAMETRANSFORMGETMULTIPLEXER) << "polydriver not valid";
71  return false;
72  }
73  }
74  return true;
75 }
76 
77 
78 bool FrameTransformGetMultiplexer::getTransforms(std::vector<yarp::math::FrameTransform>& transforms) const
79 {
80  for (size_t i = 0; i < m_iFrameTransformStorageGetList.size(); i++)
81  {
82  if (m_iFrameTransformStorageGetList[i] != nullptr) {
83  std::vector<yarp::math::FrameTransform> localTransform;
84  m_iFrameTransformStorageGetList[i]->getTransforms(localTransform);
85  transforms.insert(transforms.end(),
86  localTransform.begin(),
87  localTransform.end());
88  }
89  else {
90  yCError(FRAMETRANSFORMGETMULTIPLEXER) << "pointer to interface IFrameTransformStorageGet not valid";
91  return false;
92  }
93  }
94  return true;
95 }
const yarp::os::LogComponent & FRAMETRANSFORMGETMULTIPLEXER()
A multiplexer which collapses the output of many IFrameTransformStorageGet interfaces into one.
bool close() override
Close the DeviceDriver.
bool detachAll() override
Detach the object (you must have first called attach).
bool getTransforms(std::vector< yarp::math::FrameTransform > &transforms) const override
Obtains all frame transforms saved in a storage.
bool attachAll(const yarp::dev::PolyDriverList &devices2attach) override
Attach to a list of objects.
bool view(T *&x)
Get an interface to the device driver.
Definition: DeviceDriver.h:74
A container for a device driver.
Definition: PolyDriver.h:24
bool isValid() const
Check if device is valid.
Definition: PolyDriver.cpp:196
static bool checkNetwork()
Check if the YARP Network is up and running.
Definition: Network.cpp:1377
A base class for nested structures that can be searched.
Definition: Searchable.h:66
#define yCError(component,...)
Definition: LogComponent.h:154
#define yCTrace(component,...)
Definition: LogComponent.h:85
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:77
An interface for the device drivers.
An interface to the operating system, including Port based communication.
Signal processing.
Definition: Image.h:22
The main, catch-all namespace for YARP.
Definition: dirs.h:16