YARP
Yet Another Robot Platform
FluidPressure.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 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  {
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
yarp::rosmsg::std_msgs::Header::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Header.h:115
yarp::rosmsg::sensor_msgs::FluidPressure::FluidPressure
FluidPressure()
Definition: FluidPressure.h:47
yarp::os::idl::WireReader::expectFloat64
yarp::conf::float64_t expectFloat64()
Definition: WireReader.h:120
yarp::rosmsg::sensor_msgs::FluidPressure::fluid_pressure
yarp::conf::float64_t fluid_pressure
Definition: FluidPressure.h:44
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::os::ConnectionWriter::appendFloat64
virtual void appendFloat64(yarp::conf::float64_t data)=0
Send a representation of a 64-bit floating point number to the network connection.
yarp::os::idl::BottleStyle
Definition: BottleStyle.h:22
yarp::os::Type
Definition: Type.h:24
yarp::os::idl::WirePortable::read
virtual bool read(yarp::os::idl::WireReader &reader)
Definition: WirePortable.cpp:14
Header.h
yarp::os::ConnectionReader::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
yarp::rosmsg::std_msgs::Header::clear
void clear()
Definition: Header.h:58
Wire.h
yarp::rosmsg::sensor_msgs::FluidPressure::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::FluidPressure > rosStyle
Definition: FluidPressure.h:158
yarp::rosmsg::sensor_msgs::FluidPressure::variance
yarp::conf::float64_t variance
Definition: FluidPressure.h:45
yarp::rosmsg::sensor_msgs::FluidPressure::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: FluidPressure.h:66
yarp::rosmsg::sensor_msgs::FluidPressure::typeName
static constexpr const char * typeName
Definition: FluidPressure.h:162
yarp::os::ConnectionReader::expectFloat64
virtual yarp::conf::float64_t expectFloat64()=0
Read a 64-bit floating point number from the network connection.
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
yarp::os::Type::byName
static Type byName(const char *name)
Definition: Type.cpp:174
yarp::os::Type::addProperty
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:137
Type.h
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::os::ConnectionReader::isError
virtual bool isError() const =0
yarp::rosmsg::sensor_msgs::FluidPressure::getType
yarp::os::Type getType() const override
Definition: FluidPressure.h:200
yarp::rosmsg::sensor_msgs::FluidPressure::clear
void clear()
Definition: FluidPressure.h:54
yarp::os::ConnectionReader::convertTextMode
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
yarp::rosmsg::sensor_msgs::FluidPressure::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: FluidPressure.h:111
yarp::rosmsg::sensor_msgs::FluidPressure::typeChecksum
static constexpr const char * typeChecksum
Definition: FluidPressure.h:165
yarp::os::idl::WirePortable
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:26
yarp::rosmsg::sensor_msgs::FluidPressure::header
yarp::rosmsg::std_msgs::Header header
Definition: FluidPressure.h:43
yarp::os::ConnectionWriter::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
yarp::rosmsg::std_msgs::Header::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Header.h:162
yarp::os::ConnectionWriter::convertTextMode
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
yarp::rosmsg::sensor_msgs::FluidPressure::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: FluidPressure.h:82
yarp::os::ConnectionWriter::appendInt32
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
yarp::os::idl::WireReader
IDL-friendly connection reader.
Definition: WireReader.h:33
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:40
yarp::os::idl::BareStyle
Definition: BareStyle.h:22
yarp::rosmsg::sensor_msgs::FluidPressure::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: FluidPressure.h:127
BOTTLE_TAG_FLOAT64
#define BOTTLE_TAG_FLOAT64
Definition: Bottle.h:27
yarp::rosmsg::sensor_msgs::FluidPressure::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: FluidPressure.h:105
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::conf::float64_t
double float64_t
Definition: numeric.h:51
yarp::rosmsg::sensor_msgs::FluidPressure
Definition: FluidPressure.h:41
yarp::rosmsg::sensor_msgs::FluidPressure::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::FluidPressure > bottleStyle
Definition: FluidPressure.h:159
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
yarp::rosmsg::sensor_msgs::FluidPressure::typeText
static constexpr const char * typeText
Definition: FluidPressure.h:168
sensor_msgs
Definition: BatteryState.h:22
yarp::rosmsg::std_msgs::Header
Definition: Header.h:45
yarp::rosmsg::sensor_msgs::FluidPressure::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: FluidPressure.h:150
yarp::os::idl::WireReader::readListHeader
bool readListHeader()
Definition: WireReader.cpp:470
yarp::os::idl::WirePortable::write
virtual bool write(const yarp::os::idl::WireWriter &writer) const
Definition: WirePortable.cpp:20