YARP
Yet Another Robot Platform
RelativeHumidity.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 // This is an automatically generated file.
10 
11 // Generated from the following "sensor_msgs/RelativeHumidity" msg definition:
12 // # Single reading from a relative humidity sensor. Defines the ratio of partial
13 // # pressure of water vapor to the saturated vapor pressure at a temperature.
14 //
15 // Header header # timestamp of the measurement
16 // # frame_id is the location of the humidity sensor
17 //
18 // float64 relative_humidity # Expression of the relative humidity
19 // # from 0.0 to 1.0.
20 // # 0.0 is no partial pressure of water vapor
21 // # 1.0 represents partial pressure of saturation
22 //
23 // float64 variance # 0 is interpreted as variance unknown// Instances of this class can be read and written with YARP ports,
24 // using a ROS-compatible format.
25 
26 #ifndef YARP_ROSMSG_sensor_msgs_RelativeHumidity_h
27 #define YARP_ROSMSG_sensor_msgs_RelativeHumidity_h
28 
29 #include <yarp/os/Wire.h>
30 #include <yarp/os/Type.h>
31 #include <yarp/os/idl/WireTypes.h>
32 #include <string>
33 #include <vector>
35 
36 namespace yarp {
37 namespace rosmsg {
38 namespace sensor_msgs {
39 
41 {
42 public:
46 
48  header(),
49  relative_humidity(0.0),
50  variance(0.0)
51  {
52  }
53 
54  void clear()
55  {
56  // *** header ***
57  header.clear();
58 
59  // *** relative_humidity ***
60  relative_humidity = 0.0;
61 
62  // *** variance ***
63  variance = 0.0;
64  }
65 
66  bool readBare(yarp::os::ConnectionReader& connection) override
67  {
68  // *** header ***
69  if (!header.read(connection)) {
70  return false;
71  }
72 
73  // *** relative_humidity ***
74  relative_humidity = connection.expectFloat64();
75 
76  // *** variance ***
77  variance = connection.expectFloat64();
78 
79  return !connection.isError();
80  }
81 
82  bool readBottle(yarp::os::ConnectionReader& connection) override
83  {
84  connection.convertTextMode();
85  yarp::os::idl::WireReader reader(connection);
86  if (!reader.readListHeader(3)) {
87  return false;
88  }
89 
90  // *** header ***
91  if (!header.read(connection)) {
92  return false;
93  }
94 
95  // *** relative_humidity ***
96  relative_humidity = reader.expectFloat64();
97 
98  // *** variance ***
99  variance = reader.expectFloat64();
100 
101  return !connection.isError();
102  }
103 
105  bool read(yarp::os::ConnectionReader& connection) override
106  {
107  return (connection.isBareMode() ? readBare(connection)
108  : readBottle(connection));
109  }
110 
111  bool writeBare(yarp::os::ConnectionWriter& connection) const override
112  {
113  // *** header ***
114  if (!header.write(connection)) {
115  return false;
116  }
117 
118  // *** relative_humidity ***
119  connection.appendFloat64(relative_humidity);
120 
121  // *** variance ***
122  connection.appendFloat64(variance);
123 
124  return !connection.isError();
125  }
126 
127  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
128  {
129  connection.appendInt32(BOTTLE_TAG_LIST);
130  connection.appendInt32(3);
131 
132  // *** header ***
133  if (!header.write(connection)) {
134  return false;
135  }
136 
137  // *** relative_humidity ***
138  connection.appendInt32(BOTTLE_TAG_FLOAT64);
139  connection.appendFloat64(relative_humidity);
140 
141  // *** variance ***
142  connection.appendInt32(BOTTLE_TAG_FLOAT64);
143  connection.appendFloat64(variance);
144 
145  connection.convertTextMode();
146  return !connection.isError();
147  }
148 
150  bool write(yarp::os::ConnectionWriter& connection) const override
151  {
152  return (connection.isBareMode() ? writeBare(connection)
153  : writeBottle(connection));
154  }
155 
156  // This class will serialize ROS style or YARP style depending on protocol.
157  // If you need to force a serialization style, use one of these classes:
160 
161  // Give source text for class, ROS will need this
162  static std::string typeText()
163  {
164  return std::string("\
165  # Single reading from a relative humidity sensor. Defines the ratio of partial\n\
166  # pressure of water vapor to the saturated vapor pressure at a temperature.\n\
167 \n\
168  Header header # timestamp of the measurement\n\
169  # frame_id is the location of the humidity sensor\n\
170 \n\
171  float64 relative_humidity # Expression of the relative humidity\n\
172  # from 0.0 to 1.0.\n\
173  # 0.0 is no partial pressure of water vapor\n\
174  # 1.0 represents partial pressure of saturation\n\
175 \n\
176  float64 variance # 0 is interpreted as variance unknown") + std::string("\n\
177 ================================================================================\n\
178 MSG: std_msgs/Header\n\
180  }
181 
182  std::string getTypeText() const
183  {
185  }
186 
187  // Name the class, ROS will need this
188  yarp::os::Type getType() const override
189  {
190  yarp::os::Type typ = yarp::os::Type::byName("sensor_msgs/RelativeHumidity", "sensor_msgs/RelativeHumidity");
191  typ.addProperty("md5sum", yarp::os::Value("8730015b05955b7e992ce29a2678d90f"));
192  typ.addProperty("message_definition", yarp::os::Value(getTypeText()));
193  return typ;
194  }
195 };
196 
197 } // namespace sensor_msgs
198 } // namespace rosmsg
199 } // namespace yarp
200 
201 #endif // YARP_ROSMSG_sensor_msgs_RelativeHumidity_h
static std::string typeText()
Definition: Header.h:174
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::RelativeHumidity > bottleStyle
yarp::os::Type getType() const override
yarp::conf::float64_t expectFloat64()
Definition: WireReader.h:113
bool writeBare(yarp::os::ConnectionWriter &connection) const override
static Type byName(const char *name)
Definition: Type.cpp:165
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:127
virtual bool isError() const =0
The main, catch-all namespace for YARP.
Definition: numeric.h:47
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary...
yarp::rosmsg::std_msgs::Header header
virtual bool isBareMode() const =0
Check if the connection is bare mode.
An interface for writing to a network connection.
virtual bool write(const yarp::os::idl::WireWriter &writer) const
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
virtual bool read(yarp::os::idl::WireReader &reader)
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::RelativeHumidity > rosStyle
virtual yarp::conf::float64_t expectFloat64()=0
Read a 64-bit floating point number from the network connection.
virtual bool isError() const =0
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Header.h:162
#define BOTTLE_TAG_FLOAT64
Definition: Bottle.h:27
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:30
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
An interface for reading from a network connection.
double float64_t
Definition: numeric.h:51
A single value (typically within a Bottle).
Definition: Value.h:40
bool readBottle(yarp::os::ConnectionReader &connection) override
bool readBare(yarp::os::ConnectionReader &connection) override
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
IDL-friendly connection reader.
Definition: WireReader.h:37
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Header.h:115
virtual void appendFloat64(yarp::conf::float64_t data)=0
Send a representation of a 64-bit floating point number to the network connection.