YARP
Yet Another Robot Platform
FluidPressure.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/FluidPressure" msg definition:
12 // # Single pressure reading. This message is appropriate for measuring the
13 // # pressure inside of a fluid (air, water, etc). This also includes
14 // # atmospheric or barometric pressure.
15 //
16 // # This message is not appropriate for force/pressure contact sensors.
17 //
18 // Header header # timestamp of the measurement
19 // # frame_id is the location of the pressure sensor
20 //
21 // float64 fluid_pressure # Absolute pressure reading in Pascals.
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_FluidPressure_h
27 #define YARP_ROSMSG_sensor_msgs_FluidPressure_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  fluid_pressure(0.0),
50  variance(0.0)
51  {
52  }
53 
54  void clear()
55  {
56  // *** header ***
57  header.clear();
58 
59  // *** fluid_pressure ***
60  fluid_pressure = 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  // *** fluid_pressure ***
74  fluid_pressure = 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  // *** fluid_pressure ***
96  fluid_pressure = 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  // *** fluid_pressure ***
119  connection.appendFloat64(fluid_pressure);
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  // *** fluid_pressure ***
138  connection.appendInt32(BOTTLE_TAG_FLOAT64);
139  connection.appendFloat64(fluid_pressure);
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/FluidPressure";
163 
164  // The checksum for this message, ROS will need this
165  static constexpr const char* typeChecksum = "804dc5cea1c5306d6a2eb80b9833befe";
166 
167  // The source text for this message, ROS will need this
168  static constexpr const char* typeText = "\
169  # Single pressure reading. This message is appropriate for measuring the\n\
170  # pressure inside of a fluid (air, water, etc). This also includes\n\
171  # atmospheric or barometric pressure.\n\
172 \n\
173  # This message is not appropriate for force/pressure contact sensors.\n\
174 \n\
175  Header header # timestamp of the measurement\n\
176  # frame_id is the location of the pressure sensor\n\
177 \n\
178  float64 fluid_pressure # Absolute pressure reading in Pascals.\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_FluidPressure_h
static constexpr const char * typeName
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::FluidPressure > rosStyle
yarp::conf::float64_t expectFloat64()
Definition: WireReader.h:113
static Type byName(const char *name)
Definition: Type.cpp:179
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:141
static constexpr const char * typeChecksum
virtual bool isError() const =0
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::rosmsg::std_msgs::Header header
Definition: FluidPressure.h:43
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.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
virtual bool read(yarp::os::idl::WireReader &reader)
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
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: FluidPressure.h:66
#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
static constexpr const char * typeText
An interface for reading from a network connection.
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::FluidPressure > bottleStyle
double float64_t
Definition: numeric.h:51
A single value (typically within a Bottle).
Definition: Value.h:40
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
yarp::os::Type getType() const override
bool writeBare(yarp::os::ConnectionWriter &connection) const 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
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: FluidPressure.h:82
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
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.