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  // The name for this message, ROS will need this
162  static constexpr const char* typeName = "sensor_msgs/RelativeHumidity";
163 
164  // The checksum for this message, ROS will need this
165  static constexpr const char* typeChecksum = "8730015b05955b7e992ce29a2678d90f";
166 
167  // The source text for this message, ROS will need this
168  static constexpr const char* typeText = "\
169  # Single reading from a relative humidity sensor. Defines the ratio of partial\n\
170  # pressure of water vapor to the saturated vapor pressure at a temperature.\n\
171 \n\
172  Header header # timestamp of the measurement\n\
173  # frame_id is the location of the humidity sensor\n\
174 \n\
175  float64 relative_humidity # Expression of the relative humidity\n\
176  # from 0.0 to 1.0.\n\
177  # 0.0 is no partial pressure of water vapor\n\
178  # 1.0 represents partial pressure of saturation\n\
179 \n\
180  float64 variance # 0 is interpreted as variance unknown\n\
181 ================================================================================\n\
182 MSG: std_msgs/Header\n\
183 # Standard metadata for higher-level stamped data types.\n\
184 # This is generally used to communicate timestamped data \n\
185 # in a particular coordinate frame.\n\
186 # \n\
187 # sequence ID: consecutively increasing ID \n\
188 uint32 seq\n\
189 #Two-integer timestamp that is expressed as:\n\
190 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
191 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
192 # time-handling sugar is provided by the client library\n\
193 time stamp\n\
194 #Frame this data is associated with\n\
195 # 0: no frame\n\
196 # 1: global frame\n\
197 string frame_id\n\
198 ";
199 
200  yarp::os::Type getType() const override
201  {
202  yarp::os::Type typ = yarp::os::Type::byName(typeName, typeName);
203  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
204  typ.addProperty("message_definition", yarp::os::Value(typeText));
205  return typ;
206  }
207 };
208 
209 } // namespace sensor_msgs
210 } // namespace rosmsg
211 } // namespace yarp
212 
213 #endif // YARP_ROSMSG_sensor_msgs_RelativeHumidity_h
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::RelativeHumidity > bottleStyle
yarp::os::Type getType() const override
yarp::conf::float64_t expectFloat64()
Definition: WireReader.h:120
bool writeBare(yarp::os::ConnectionWriter &connection) const override
static Type byName(const char *name)
Definition: Type.cpp:176
static constexpr const char * typeText
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:138
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.
static constexpr const char * typeChecksum
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:33
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
static constexpr const char * typeName
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:46
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:32
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.