|
| 1 | +/* |
| 2 | + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) |
| 3 | + * SPDX-License-Identifier: BSD-3-Clause |
| 4 | + */ |
| 5 | + |
| 6 | +#ifndef YARP_DEV_MULTIPLEANALOGSENSORSREMAPPER_MULTIPLEANALOGSENSORSCLIENTREMAPPER_H |
| 7 | +#define YARP_DEV_MULTIPLEANALOGSENSORSREMAPPER_MULTIPLEANALOGSENSORSCLIENTREMAPPER_H |
| 8 | + |
| 9 | +#include <yarp/dev/PolyDriver.h> |
| 10 | + |
| 11 | +#include "MultipleAnalogSensorsRemapper.h" |
| 12 | + |
| 13 | +/** |
| 14 | + * @ingroup dev_impl_network_clients |
| 15 | + * |
| 16 | + * @brief `MultipleAnalogSensorsClientRemapper` A device that takes a list of sensor, a list of all |
| 17 | + * multiple analog sensors client and expose them as a single device exposing MultipleAnalogSensors |
| 18 | + * interface. |
| 19 | + * |
| 20 | + * \section MultipleAnalogSensorsRemapper |
| 21 | + * |
| 22 | + * Parameters required by this device are: |
| 23 | + * | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | Notes | |
| 24 | + * |:--------------:|:--------------:|:-------:|:--------------:|:-------------:|:-----------: |:-----------------------------------------------------------------:|:-----:| |
| 25 | + * | {sensorTag}Names | - | vector of strings | - | - | Yes | Ordered list of name that must belong of the remapped device. The list also defines the index that the sensor will | | |
| 26 | + * | multipleAnalogSensorsClients | - | vector of strings | - | - | Yes | List of remote prefix used by the MultipleAnalogSensorsClients. | The element of this list are then passed as "remote" parameter to the MultipleAnalogSensorsClient device. | |
| 27 | + * | localPortPrefix | - | string | - | - | Yes | All ports opened by this device will start with this prefix | | |
| 28 | + * | MULTIPLE_ANALOG_SENSORS_CLIENTS_OPTIONS | - | group | - | - | No | Options that will be passed directly to the MultipleAnalogSensorsClient devices | | |
| 29 | + * The sensorTag is a tag identifing the spefici sensor interface, see \ref dev_iface_multiple_analog for a list of possible sensors. |
| 30 | + * The tag of each sensor interface is provided in the doxygen documentation of the specific interface. |
| 31 | + * |
| 32 | + * |
| 33 | + * Configuration file using .ini format. |
| 34 | + * |
| 35 | + * \code{.unparsed} |
| 36 | + * device multipleanalogsensorsclientremapper |
| 37 | + * ThreeAxisGyroscopesNames (l_foot_ft_gyro, r_arm_ft_gyro) |
| 38 | + * SixAxisForceTorqueSensorsNames (r_foot_ft, r_arm_ft) |
| 39 | + * multipleAnalogSensorsClients (/icub/left_foot/imu /icub/right_arm/imu) |
| 40 | + * |
| 41 | + * [MULTIPLE_ANALOG_SENSORS_CLIENTS_OPTIONS] |
| 42 | + * carrier udp |
| 43 | + * timeout 0.2 |
| 44 | + * ... |
| 45 | + * \endcode |
| 46 | + * |
| 47 | + * Configuration of the device from C++ code. |
| 48 | + * \code{.cpp} |
| 49 | + * Property options; |
| 50 | + * options.put("device","multipleanalogsensorsclientremapper"); |
| 51 | + * Bottle threeAxisGyroscopesNames; |
| 52 | + * Bottle & threeAxisGyroscopesList = threeAxisGyroscopesNames.addList(); |
| 53 | + * threeAxisGyroscopesList.addString("l_foot_ft_gyro"); |
| 54 | + * threeAxisGyroscopesList.addString("r_arm_ft_gyro"); |
| 55 | + * options.put("ThreeAxisGyroscopesNames",threeAxisGyroscopesNames.get(0)) |
| 56 | + * |
| 57 | + * Bottle sixAxisForceTorqueSensorsNames; |
| 58 | + * Bottle & sixAxisForceTorqueSensorsList = sixAxisForceTorqueSensorsNames.addList(); |
| 59 | + * sixAxisForceTorqueSensorsList.addString("l_foot_ft_gyro"); |
| 60 | + * sixAxisForceTorqueSensorsList.addString("r_arm_ft_gyro"); |
| 61 | + * options.put("SixAxisForceTorqueSensorsNames",sixAxisForceTorqueSensorsNames.get(0)) |
| 62 | + * |
| 63 | + * Bottle multipleAnalogSensorsClients; |
| 64 | + * Bottle & multipleAnalogSensorsClientsList = multipleAnalogSensorsClients.addList(); |
| 65 | + * multipleAnalogSensorsClientsList.addString("/icub/left_foot/imu"); |
| 66 | + * multipleAnalogSensorsClientsList.addString("/icub/right_arm/imu"); |
| 67 | + * options.put("multipleAnalogSensorsClients",multipleAnalogSensorsClients.get(0)); |
| 68 | + * |
| 69 | + * options.put("localPortPrefix",/test"); |
| 70 | + * |
| 71 | + * Property & multipleAnalogSensorsClientsOpts = options.addGroup("MULTIPLE_ANALOG_SENSORS_CLIENTS_OPTIONS"); |
| 72 | + * multipleAnalogSensorsClientsOpts.put("carrier", "udp"); |
| 73 | + * multipleAnalogSensorsClientsOpts.put("timeout", 0.2); |
| 74 | + * |
| 75 | + * // Actually open the device |
| 76 | + * PolyDriver robotDevice(options); |
| 77 | + * |
| 78 | + * // Use it as you would use any controlboard device |
| 79 | + * // ... |
| 80 | + * \endcode |
| 81 | + * |
| 82 | + */ |
| 83 | + |
| 84 | +class MultipleAnalogSensorsClientRemapper : public MultipleAnalogSensorsRemapper |
| 85 | +{ |
| 86 | +private: |
| 87 | + /** |
| 88 | + * List of MultipleAnalogSensorsClient devices opened by the MultipleAnalogSensorsClientRemapper |
| 89 | + * device. |
| 90 | + */ |
| 91 | + std::vector<yarp::dev::PolyDriver*> m_multipleAnalogSensorsClientsDevices; |
| 92 | + |
| 93 | + |
| 94 | + // Close all opened MultipleAnalogSensorsClients |
| 95 | + void closeAllMultipleAnalogSensorsClients(); |
| 96 | + |
| 97 | +public: |
| 98 | + MultipleAnalogSensorsClientRemapper() = default; |
| 99 | + MultipleAnalogSensorsClientRemapper(const MultipleAnalogSensorsClientRemapper&) = delete; |
| 100 | + MultipleAnalogSensorsClientRemapper(MultipleAnalogSensorsClientRemapper&&) = delete; |
| 101 | + MultipleAnalogSensorsClientRemapper& operator=(const MultipleAnalogSensorsClientRemapper&) = delete; |
| 102 | + MultipleAnalogSensorsClientRemapper& operator=(MultipleAnalogSensorsClientRemapper&&) = delete; |
| 103 | + ~MultipleAnalogSensorsClientRemapper() = default; |
| 104 | + |
| 105 | + /** |
| 106 | + * Open the device driver. |
| 107 | + * @param prop is a Searchable object which contains the parameters. |
| 108 | + * Allowed parameters are described in the class documentation. |
| 109 | + */ |
| 110 | + bool open(yarp::os::Searchable &prop) override; |
| 111 | + |
| 112 | + /** |
| 113 | + * Close the device driver by deallocating all resources and closing ports. |
| 114 | + * @return true if successful or false otherwise. |
| 115 | + */ |
| 116 | + bool close() override; |
| 117 | +}; |
| 118 | + |
| 119 | +#endif |
0 commit comments