YARP
Yet Another Robot Platform
GridCells.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 "nav_msgs/GridCells" msg definition:
12 // #an array of cells in a 2D grid
13 // Header header
14 // float32 cell_width
15 // float32 cell_height
16 // geometry_msgs/Point[] cells
17 // Instances of this class can be read and written with YARP ports,
18 // using a ROS-compatible format.
19 
20 #ifndef YARP_ROSMSG_nav_msgs_GridCells_h
21 #define YARP_ROSMSG_nav_msgs_GridCells_h
22 
23 #include <yarp/os/Wire.h>
24 #include <yarp/os/Type.h>
25 #include <yarp/os/idl/WireTypes.h>
26 #include <string>
27 #include <vector>
30 
31 namespace yarp {
32 namespace rosmsg {
33 namespace nav_msgs {
34 
36 {
37 public:
41  std::vector<yarp::rosmsg::geometry_msgs::Point> cells;
42 
44  header(),
45  cell_width(0.0f),
46  cell_height(0.0f),
47  cells()
48  {
49  }
50 
51  void clear()
52  {
53  // *** header ***
54  header.clear();
55 
56  // *** cell_width ***
57  cell_width = 0.0f;
58 
59  // *** cell_height ***
60  cell_height = 0.0f;
61 
62  // *** cells ***
63  cells.clear();
64  }
65 
66  bool readBare(yarp::os::ConnectionReader& connection) override
67  {
68  // *** header ***
69  if (!header.read(connection)) {
70  return false;
71  }
72 
73  // *** cell_width ***
74  cell_width = connection.expectFloat32();
75 
76  // *** cell_height ***
77  cell_height = connection.expectFloat32();
78 
79  // *** cells ***
80  int len = connection.expectInt32();
81  cells.resize(len);
82  for (int i=0; i<len; i++) {
83  if (!cells[i].read(connection)) {
84  return false;
85  }
86  }
87 
88  return !connection.isError();
89  }
90 
91  bool readBottle(yarp::os::ConnectionReader& connection) override
92  {
93  connection.convertTextMode();
94  yarp::os::idl::WireReader reader(connection);
95  if (!reader.readListHeader(4)) {
96  return false;
97  }
98 
99  // *** header ***
100  if (!header.read(connection)) {
101  return false;
102  }
103 
104  // *** cell_width ***
105  cell_width = reader.expectFloat32();
106 
107  // *** cell_height ***
108  cell_height = reader.expectFloat32();
109 
110  // *** cells ***
111  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
112  return false;
113  }
114  int len = connection.expectInt32();
115  cells.resize(len);
116  for (int i=0; i<len; i++) {
117  if (!cells[i].read(connection)) {
118  return false;
119  }
120  }
121 
122  return !connection.isError();
123  }
124 
126  bool read(yarp::os::ConnectionReader& connection) override
127  {
128  return (connection.isBareMode() ? readBare(connection)
129  : readBottle(connection));
130  }
131 
132  bool writeBare(yarp::os::ConnectionWriter& connection) const override
133  {
134  // *** header ***
135  if (!header.write(connection)) {
136  return false;
137  }
138 
139  // *** cell_width ***
140  connection.appendFloat32(cell_width);
141 
142  // *** cell_height ***
143  connection.appendFloat32(cell_height);
144 
145  // *** cells ***
146  connection.appendInt32(cells.size());
147  for (size_t i=0; i<cells.size(); i++) {
148  if (!cells[i].write(connection)) {
149  return false;
150  }
151  }
152 
153  return !connection.isError();
154  }
155 
156  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
157  {
158  connection.appendInt32(BOTTLE_TAG_LIST);
159  connection.appendInt32(4);
160 
161  // *** header ***
162  if (!header.write(connection)) {
163  return false;
164  }
165 
166  // *** cell_width ***
167  connection.appendInt32(BOTTLE_TAG_FLOAT32);
168  connection.appendFloat32(cell_width);
169 
170  // *** cell_height ***
171  connection.appendInt32(BOTTLE_TAG_FLOAT32);
172  connection.appendFloat32(cell_height);
173 
174  // *** cells ***
175  connection.appendInt32(BOTTLE_TAG_LIST);
176  connection.appendInt32(cells.size());
177  for (size_t i=0; i<cells.size(); i++) {
178  if (!cells[i].write(connection)) {
179  return false;
180  }
181  }
182 
183  connection.convertTextMode();
184  return !connection.isError();
185  }
186 
188  bool write(yarp::os::ConnectionWriter& connection) const override
189  {
190  return (connection.isBareMode() ? writeBare(connection)
191  : writeBottle(connection));
192  }
193 
194  // This class will serialize ROS style or YARP style depending on protocol.
195  // If you need to force a serialization style, use one of these classes:
198 
199  // The name for this message, ROS will need this
200  static constexpr const char* typeName = "nav_msgs/GridCells";
201 
202  // The checksum for this message, ROS will need this
203  static constexpr const char* typeChecksum = "b9e4f5df6d28e272ebde00a3994830f5";
204 
205  // The source text for this message, ROS will need this
206  static constexpr const char* typeText = "\
207 #an array of cells in a 2D grid\n\
208 Header header\n\
209 float32 cell_width\n\
210 float32 cell_height\n\
211 geometry_msgs/Point[] cells\n\
212 \n\
213 ================================================================================\n\
214 MSG: std_msgs/Header\n\
215 # Standard metadata for higher-level stamped data types.\n\
216 # This is generally used to communicate timestamped data \n\
217 # in a particular coordinate frame.\n\
218 # \n\
219 # sequence ID: consecutively increasing ID \n\
220 uint32 seq\n\
221 #Two-integer timestamp that is expressed as:\n\
222 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
223 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
224 # time-handling sugar is provided by the client library\n\
225 time stamp\n\
226 #Frame this data is associated with\n\
227 # 0: no frame\n\
228 # 1: global frame\n\
229 string frame_id\n\
230 \n\
231 ================================================================================\n\
232 MSG: geometry_msgs/Point\n\
233 # This contains the position of a point in free space\n\
234 float64 x\n\
235 float64 y\n\
236 float64 z\n\
237 ";
238 
239  yarp::os::Type getType() const override
240  {
242  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
243  typ.addProperty("message_definition", yarp::os::Value(typeText));
244  return typ;
245  }
246 };
247 
248 } // namespace nav_msgs
249 } // namespace rosmsg
250 } // namespace yarp
251 
252 #endif // YARP_ROSMSG_nav_msgs_GridCells_h
yarp::rosmsg::nav_msgs::GridCells::typeName
static constexpr const char * typeName
Definition: GridCells.h:200
yarp::os::ConnectionWriter::appendFloat32
virtual void appendFloat32(yarp::conf::float32_t data)=0
Send a representation of a 32-bit floating point number to the network connection.
yarp::rosmsg::nav_msgs::GridCells
Definition: GridCells.h:36
yarp::rosmsg::nav_msgs::GridCells::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: GridCells.h:66
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::nav_msgs::GridCells::GridCells
GridCells()
Definition: GridCells.h:43
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::os::idl::WireReader::expectFloat32
yarp::conf::float32_t expectFloat32()
Definition: WireReader.h:113
yarp::rosmsg::nav_msgs::GridCells::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: GridCells.h:188
yarp::rosmsg::nav_msgs::GridCells::cell_width
yarp::conf::float32_t cell_width
Definition: GridCells.h:39
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
Point.h
yarp::rosmsg::nav_msgs::GridCells::cell_height
yarp::conf::float32_t cell_height
Definition: GridCells.h:40
yarp::rosmsg::nav_msgs::GridCells::header
yarp::rosmsg::std_msgs::Header header
Definition: GridCells.h:38
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
yarp::rosmsg::nav_msgs::GridCells::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::nav_msgs::GridCells > bottleStyle
Definition: GridCells.h:197
yarp::rosmsg::nav_msgs::GridCells::getType
yarp::os::Type getType() const override
Definition: GridCells.h:239
BOTTLE_TAG_FLOAT32
#define BOTTLE_TAG_FLOAT32
Definition: Bottle.h:26
yarp::os::Type::byName
static Type byName(const char *name)
Definition: Type.cpp:174
yarp::os::ConnectionReader::expectInt32
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
yarp::os::Type::addProperty
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:137
Type.h
yarp::rosmsg::nav_msgs::GridCells::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: GridCells.h:91
yarp::rosmsg::nav_msgs::GridCells::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: GridCells.h:156
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::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::os::idl::WirePortable
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:26
yarp::os::ConnectionWriter::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
yarp::rosmsg::nav_msgs::GridCells::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::nav_msgs::GridCells > rosStyle
Definition: GridCells.h:196
yarp::rosmsg::nav_msgs::GridCells::cells
std::vector< yarp::rosmsg::geometry_msgs::Point > cells
Definition: GridCells.h:41
yarp::rosmsg::nav_msgs::GridCells::typeText
static constexpr const char * typeText
Definition: GridCells.h:206
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::conf::float32_t
float float32_t
Definition: numeric.h:50
yarp::os::ConnectionWriter::appendInt32
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
nav_msgs
Definition: GetMap.h:22
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::nav_msgs::GridCells::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: GridCells.h:132
yarp::rosmsg::nav_msgs::GridCells::typeChecksum
static constexpr const char * typeChecksum
Definition: GridCells.h:203
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::rosmsg::nav_msgs::GridCells::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: GridCells.h:126
yarp::os::ConnectionReader::expectFloat32
virtual yarp::conf::float32_t expectFloat32()=0
Read a 32-bit floating point number from the network connection.
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
yarp::rosmsg::nav_msgs::GridCells::clear
void clear()
Definition: GridCells.h:51
yarp::rosmsg::std_msgs::Header
Definition: Header.h:45
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