YARP
Yet Another Robot Platform
Temperature.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/Temperature" msg definition:
12 // # Single temperature reading.
13 //
14 // Header header # timestamp is the time the temperature was measured
15 // # frame_id is the location of the temperature reading
16 //
17 // float64 temperature # Measurement of the Temperature in Degrees Celsius
18 //
19 // float64 variance # 0 is interpreted as variance unknown// Instances of this class can be read and written with YARP ports,
20 // using a ROS-compatible format.
21 
22 #ifndef YARP_ROSMSG_sensor_msgs_Temperature_h
23 #define YARP_ROSMSG_sensor_msgs_Temperature_h
24 
25 #include <yarp/os/Wire.h>
26 #include <yarp/os/Type.h>
27 #include <yarp/os/idl/WireTypes.h>
28 #include <string>
29 #include <vector>
31 
32 namespace yarp {
33 namespace rosmsg {
34 namespace sensor_msgs {
35 
37 {
38 public:
42 
44  header(),
45  temperature(0.0),
46  variance(0.0)
47  {
48  }
49 
50  void clear()
51  {
52  // *** header ***
53  header.clear();
54 
55  // *** temperature ***
56  temperature = 0.0;
57 
58  // *** variance ***
59  variance = 0.0;
60  }
61 
62  bool readBare(yarp::os::ConnectionReader& connection) override
63  {
64  // *** header ***
65  if (!header.read(connection)) {
66  return false;
67  }
68 
69  // *** temperature ***
70  temperature = connection.expectFloat64();
71 
72  // *** variance ***
73  variance = connection.expectFloat64();
74 
75  return !connection.isError();
76  }
77 
78  bool readBottle(yarp::os::ConnectionReader& connection) override
79  {
80  connection.convertTextMode();
81  yarp::os::idl::WireReader reader(connection);
82  if (!reader.readListHeader(3)) {
83  return false;
84  }
85 
86  // *** header ***
87  if (!header.read(connection)) {
88  return false;
89  }
90 
91  // *** temperature ***
92  temperature = reader.expectFloat64();
93 
94  // *** variance ***
95  variance = reader.expectFloat64();
96 
97  return !connection.isError();
98  }
99 
101  bool read(yarp::os::ConnectionReader& connection) override
102  {
103  return (connection.isBareMode() ? readBare(connection)
104  : readBottle(connection));
105  }
106 
107  bool writeBare(yarp::os::ConnectionWriter& connection) const override
108  {
109  // *** header ***
110  if (!header.write(connection)) {
111  return false;
112  }
113 
114  // *** temperature ***
115  connection.appendFloat64(temperature);
116 
117  // *** variance ***
118  connection.appendFloat64(variance);
119 
120  return !connection.isError();
121  }
122 
123  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
124  {
125  connection.appendInt32(BOTTLE_TAG_LIST);
126  connection.appendInt32(3);
127 
128  // *** header ***
129  if (!header.write(connection)) {
130  return false;
131  }
132 
133  // *** temperature ***
134  connection.appendInt32(BOTTLE_TAG_FLOAT64);
135  connection.appendFloat64(temperature);
136 
137  // *** variance ***
138  connection.appendInt32(BOTTLE_TAG_FLOAT64);
139  connection.appendFloat64(variance);
140 
141  connection.convertTextMode();
142  return !connection.isError();
143  }
144 
146  bool write(yarp::os::ConnectionWriter& connection) const override
147  {
148  return (connection.isBareMode() ? writeBare(connection)
149  : writeBottle(connection));
150  }
151 
152  // This class will serialize ROS style or YARP style depending on protocol.
153  // If you need to force a serialization style, use one of these classes:
156 
157  // The name for this message, ROS will need this
158  static constexpr const char* typeName = "sensor_msgs/Temperature";
159 
160  // The checksum for this message, ROS will need this
161  static constexpr const char* typeChecksum = "ff71b307acdbe7c871a5a6d7ed359100";
162 
163  // The source text for this message, ROS will need this
164  static constexpr const char* typeText = "\
165  # Single temperature reading.\n\
166 \n\
167  Header header # timestamp is the time the temperature was measured\n\
168  # frame_id is the location of the temperature reading\n\
169 \n\
170  float64 temperature # Measurement of the Temperature in Degrees Celsius\n\
171 \n\
172  float64 variance # 0 is interpreted as variance unknown\n\
173 ================================================================================\n\
174 MSG: std_msgs/Header\n\
175 # Standard metadata for higher-level stamped data types.\n\
176 # This is generally used to communicate timestamped data \n\
177 # in a particular coordinate frame.\n\
178 # \n\
179 # sequence ID: consecutively increasing ID \n\
180 uint32 seq\n\
181 #Two-integer timestamp that is expressed as:\n\
182 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
183 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
184 # time-handling sugar is provided by the client library\n\
185 time stamp\n\
186 #Frame this data is associated with\n\
187 # 0: no frame\n\
188 # 1: global frame\n\
189 string frame_id\n\
190 ";
191 
192  yarp::os::Type getType() const override
193  {
194  yarp::os::Type typ = yarp::os::Type::byName(typeName, typeName);
195  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
196  typ.addProperty("message_definition", yarp::os::Value(typeText));
197  return typ;
198  }
199 };
200 
201 } // namespace sensor_msgs
202 } // namespace rosmsg
203 } // namespace yarp
204 
205 #endif // YARP_ROSMSG_sensor_msgs_Temperature_h
static constexpr const char * typeText
Definition: Temperature.h:164
yarp::conf::float64_t expectFloat64()
Definition: WireReader.h:120
static Type byName(const char *name)
Definition: Type.cpp:176
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:138
yarp::os::Type getType() const override
Definition: Temperature.h:192
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: Temperature.h:123
virtual bool isError() const =0
yarp::rosmsg::std_msgs::Header header
Definition: Temperature.h:39
The main, catch-all namespace for YARP.
Definition: numeric.h:47
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary...
virtual bool isBareMode() const =0
Check if the connection is bare mode.
yarp::conf::float64_t temperature
Definition: Temperature.h:40
static constexpr const char * typeChecksum
Definition: Temperature.h:161
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)
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: Temperature.h:107
virtual yarp::conf::float64_t expectFloat64()=0
Read a 64-bit floating point number from the network connection.
virtual bool isError() const =0
static constexpr const char * typeName
Definition: Temperature.h:158
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
An interface for reading from a network connection.
double float64_t
Definition: numeric.h:51
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Temperature.h:101
A single value (typically within a Bottle).
Definition: Value.h:46
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::Temperature > bottleStyle
Definition: Temperature.h:155
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...
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: Temperature.h:78
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: Temperature.h:62
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::Temperature > rosStyle
Definition: Temperature.h:154
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.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Temperature.h:146