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