iCub-main
RawValuesPublisherServer.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2024 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef RAWVALUESPUBLISHER_NETWORKSERVER_H
7 #define RAWVALUESPUBLISHER_NETWORKSERVER_H
8 
9 // std includes
10 #include <map>
11 
12 // yarp includes
13 #include <yarp/os/Network.h>
14 #include <yarp/dev/DeviceDriver.h>
15 #include <yarp/os/PeriodicThread.h>
16 #include <yarp/os/Stamp.h>
17 #include <yarp/dev/PolyDriver.h>
18 #include <yarp/dev/IMultipleWrapper.h>
19 #include <yarp/sig/Vector.h>
20 
21 // Interface for the getter of the raw data
22 // It calls the rawValuesDataStruct generated w/ thrift
24 
25 // ParamParser generated classes
27 
28 /*TIPS:
29  * 1. follow Multipleanalog server as example https://github.com/robotology/yarp/blob/bde9cd2b1069d207a77a845935b2c3063c74c58d/src/devices/networkWrappers/multipleanalogsensorsserver/MultipleAnalogSensorsServer.h#L33
30  * 2. as fist MVP implement only Buffered Port and NOT RPC
31  * 3. avoid the config parameters parser
32  * 4. use the thrift file to create the RawValue data struct. As first step it'll contain only one uint32_t value.
33  * See https://github.com/robotology/icub-main/tree/ab93283ba6d654396b92e081d960ace777a9e656/src/tools/depth2kin es example
34  *
35  * */
36 using namespace iCub;
37 
39  public yarp::os::PeriodicThread,
40  public yarp::dev::DeviceDriver,
41  public yarp::dev::IMultipleWrapper,
44 {
45 
46 private:
47  yarp::os::Stamp m_stamp;
48  double m_threadPeriodInS = 0.1;
49  yarp::os::BufferedPort<rawValuesDataVectorsMap> m_streamingRawDataPort; // streams data continuously at each server run
50  yarp::os::Port m_rpcRawDataPort; // public data on client request
51  std::string m_streamingPortName = "";
52  std::string m_rpcPortName = "";
53 
54  std::vector<std::string> m_vectorOfKeys;
55  rawValuesKeyMetadataMap m_mapOfMetadata;
56 
57  // Interface of the wrapped device
58  iCub::debugLibrary::IRawValuesPublisher* m_iRawValuesPublisher{nullptr};
59 
60  bool populateMetadata(rawValuesKeyMetadataMap &metamap);
61 
62 public:
65 
66  /* DevideDriver methods */
67  bool open(yarp::os::Searchable &params) override;
68  bool close() override;
69 
70  /* PeriodThread methods */
71  void threadRelease() override;
72  void run() override;
73 
74  /* IMultipleWrapper methods */
75  bool attachAll(const yarp::dev::PolyDriverList &p) override;
76  bool detachAll() override;
77 
78  /* RawValuesPublisherMetadata */
79  rawValuesKeyMetadataMap getMetadata() override;
80 };
81 
82 #endif
This class is the parameters parser for class RawValuesPublisherServer.
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.