YARP
Yet Another Robot Platform
LaserScan2D.cpp
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 // Autogenerated by Thrift Compiler (0.14.1-yarped)
7 //
8 // This is an automatically generated file.
9 // It could get re-generated if the ALLOW_IDL_GENERATION flag is on.
10 
11 #include <yarp/dev/LaserScan2D.h>
12 
13 namespace yarp::dev {
14 
15 // Constructor with field values
16 LaserScan2D::LaserScan2D(const double angle_min,
17  const double angle_max,
18  const double range_min,
19  const double range_max,
20  const yarp::sig::Vector& scans,
21  const std::int32_t status) :
22  WirePortable(),
23  angle_min(angle_min),
24  angle_max(angle_max),
25  range_min(range_min),
26  range_max(range_max),
27  scans(scans),
28  status(status)
29 {
30 }
31 
32 // Read structure on a Wire
34 {
35  if (!read_angle_min(reader)) {
36  return false;
37  }
38  if (!read_angle_max(reader)) {
39  return false;
40  }
41  if (!read_range_min(reader)) {
42  return false;
43  }
44  if (!read_range_max(reader)) {
45  return false;
46  }
47  if (!nested_read_scans(reader)) {
48  return false;
49  }
50  if (!read_status(reader)) {
51  return false;
52  }
53  return !reader.isError();
54 }
55 
56 // Read structure on a Connection
58 {
59  yarp::os::idl::WireReader reader(connection);
60  if (!reader.readListHeader(6)) {
61  return false;
62  }
63  return read(reader);
64 }
65 
66 // Write structure on a Wire
68 {
69  if (!write_angle_min(writer)) {
70  return false;
71  }
72  if (!write_angle_max(writer)) {
73  return false;
74  }
75  if (!write_range_min(writer)) {
76  return false;
77  }
78  if (!write_range_max(writer)) {
79  return false;
80  }
81  if (!nested_write_scans(writer)) {
82  return false;
83  }
84  if (!write_status(writer)) {
85  return false;
86  }
87  return !writer.isError();
88 }
89 
90 // Write structure on a Connection
92 {
93  yarp::os::idl::WireWriter writer(connection);
94  if (!writer.writeListHeader(6)) {
95  return false;
96  }
97  return write(writer);
98 }
99 
100 // Convert to a printable string
101 std::string LaserScan2D::toString() const
102 {
104  b.read(*this);
105  return b.toString();
106 }
107 
108 // read angle_min field
109 bool LaserScan2D::read_angle_min(yarp::os::idl::WireReader& reader)
110 {
111  if (reader.noMore()) {
112  reader.fail();
113  return false;
114  }
115  if (!reader.readFloat64(angle_min)) {
116  reader.fail();
117  return false;
118  }
119  return true;
120 }
121 
122 // write angle_min field
123 bool LaserScan2D::write_angle_min(const yarp::os::idl::WireWriter& writer) const
124 {
125  if (!writer.writeFloat64(angle_min)) {
126  return false;
127  }
128  return true;
129 }
130 
131 // read (nested) angle_min field
132 bool LaserScan2D::nested_read_angle_min(yarp::os::idl::WireReader& reader)
133 {
134  if (reader.noMore()) {
135  reader.fail();
136  return false;
137  }
138  if (!reader.readFloat64(angle_min)) {
139  reader.fail();
140  return false;
141  }
142  return true;
143 }
144 
145 // write (nested) angle_min field
146 bool LaserScan2D::nested_write_angle_min(const yarp::os::idl::WireWriter& writer) const
147 {
148  if (!writer.writeFloat64(angle_min)) {
149  return false;
150  }
151  return true;
152 }
153 
154 // read angle_max field
155 bool LaserScan2D::read_angle_max(yarp::os::idl::WireReader& reader)
156 {
157  if (reader.noMore()) {
158  reader.fail();
159  return false;
160  }
161  if (!reader.readFloat64(angle_max)) {
162  reader.fail();
163  return false;
164  }
165  return true;
166 }
167 
168 // write angle_max field
169 bool LaserScan2D::write_angle_max(const yarp::os::idl::WireWriter& writer) const
170 {
171  if (!writer.writeFloat64(angle_max)) {
172  return false;
173  }
174  return true;
175 }
176 
177 // read (nested) angle_max field
178 bool LaserScan2D::nested_read_angle_max(yarp::os::idl::WireReader& reader)
179 {
180  if (reader.noMore()) {
181  reader.fail();
182  return false;
183  }
184  if (!reader.readFloat64(angle_max)) {
185  reader.fail();
186  return false;
187  }
188  return true;
189 }
190 
191 // write (nested) angle_max field
192 bool LaserScan2D::nested_write_angle_max(const yarp::os::idl::WireWriter& writer) const
193 {
194  if (!writer.writeFloat64(angle_max)) {
195  return false;
196  }
197  return true;
198 }
199 
200 // read range_min field
201 bool LaserScan2D::read_range_min(yarp::os::idl::WireReader& reader)
202 {
203  if (reader.noMore()) {
204  reader.fail();
205  return false;
206  }
207  if (!reader.readFloat64(range_min)) {
208  reader.fail();
209  return false;
210  }
211  return true;
212 }
213 
214 // write range_min field
215 bool LaserScan2D::write_range_min(const yarp::os::idl::WireWriter& writer) const
216 {
217  if (!writer.writeFloat64(range_min)) {
218  return false;
219  }
220  return true;
221 }
222 
223 // read (nested) range_min field
224 bool LaserScan2D::nested_read_range_min(yarp::os::idl::WireReader& reader)
225 {
226  if (reader.noMore()) {
227  reader.fail();
228  return false;
229  }
230  if (!reader.readFloat64(range_min)) {
231  reader.fail();
232  return false;
233  }
234  return true;
235 }
236 
237 // write (nested) range_min field
238 bool LaserScan2D::nested_write_range_min(const yarp::os::idl::WireWriter& writer) const
239 {
240  if (!writer.writeFloat64(range_min)) {
241  return false;
242  }
243  return true;
244 }
245 
246 // read range_max field
247 bool LaserScan2D::read_range_max(yarp::os::idl::WireReader& reader)
248 {
249  if (reader.noMore()) {
250  reader.fail();
251  return false;
252  }
253  if (!reader.readFloat64(range_max)) {
254  reader.fail();
255  return false;
256  }
257  return true;
258 }
259 
260 // write range_max field
261 bool LaserScan2D::write_range_max(const yarp::os::idl::WireWriter& writer) const
262 {
263  if (!writer.writeFloat64(range_max)) {
264  return false;
265  }
266  return true;
267 }
268 
269 // read (nested) range_max field
270 bool LaserScan2D::nested_read_range_max(yarp::os::idl::WireReader& reader)
271 {
272  if (reader.noMore()) {
273  reader.fail();
274  return false;
275  }
276  if (!reader.readFloat64(range_max)) {
277  reader.fail();
278  return false;
279  }
280  return true;
281 }
282 
283 // write (nested) range_max field
284 bool LaserScan2D::nested_write_range_max(const yarp::os::idl::WireWriter& writer) const
285 {
286  if (!writer.writeFloat64(range_max)) {
287  return false;
288  }
289  return true;
290 }
291 
292 // read scans field
293 bool LaserScan2D::read_scans(yarp::os::idl::WireReader& reader)
294 {
295  if (reader.noMore()) {
296  reader.fail();
297  return false;
298  }
299  if (!reader.read(scans)) {
300  reader.fail();
301  return false;
302  }
303  return true;
304 }
305 
306 // write scans field
307 bool LaserScan2D::write_scans(const yarp::os::idl::WireWriter& writer) const
308 {
309  if (!writer.write(scans)) {
310  return false;
311  }
312  return true;
313 }
314 
315 // read (nested) scans field
316 bool LaserScan2D::nested_read_scans(yarp::os::idl::WireReader& reader)
317 {
318  if (reader.noMore()) {
319  reader.fail();
320  return false;
321  }
322  if (!reader.readNested(scans)) {
323  reader.fail();
324  return false;
325  }
326  return true;
327 }
328 
329 // write (nested) scans field
330 bool LaserScan2D::nested_write_scans(const yarp::os::idl::WireWriter& writer) const
331 {
332  if (!writer.writeNested(scans)) {
333  return false;
334  }
335  return true;
336 }
337 
338 // read status field
339 bool LaserScan2D::read_status(yarp::os::idl::WireReader& reader)
340 {
341  if (reader.noMore()) {
342  reader.fail();
343  return false;
344  }
345  if (!reader.readI32(status)) {
346  reader.fail();
347  return false;
348  }
349  return true;
350 }
351 
352 // write status field
353 bool LaserScan2D::write_status(const yarp::os::idl::WireWriter& writer) const
354 {
355  if (!writer.writeI32(status)) {
356  return false;
357  }
358  return true;
359 }
360 
361 // read (nested) status field
362 bool LaserScan2D::nested_read_status(yarp::os::idl::WireReader& reader)
363 {
364  if (reader.noMore()) {
365  reader.fail();
366  return false;
367  }
368  if (!reader.readI32(status)) {
369  reader.fail();
370  return false;
371  }
372  return true;
373 }
374 
375 // write (nested) status field
376 bool LaserScan2D::nested_write_status(const yarp::os::idl::WireWriter& writer) const
377 {
378  if (!writer.writeI32(status)) {
379  return false;
380  }
381  return true;
382 }
383 
384 } // namespace yarp::dev
yarp::sig::Vector scans
the scan data, measured in [m].
Definition: LaserScan2D.h:46
std::int32_t status
Definition: LaserScan2D.h:47
double angle_min
first angle of the scan [deg]
Definition: LaserScan2D.h:30
bool write(const yarp::os::idl::WireWriter &writer) const override
Definition: LaserScan2D.cpp:67
double angle_max
last angle of the scan [deg]
Definition: LaserScan2D.h:34
double range_min
the minimum distance of the scan [m]
Definition: LaserScan2D.h:38
bool read(yarp::os::idl::WireReader &reader) override
Definition: LaserScan2D.cpp:33
double range_max
the maximum distance of the scan [m]
Definition: LaserScan2D.h:42
std::string toString() const
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
Definition: Bottle.cpp:240
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition: Bottle.cpp:211
An interface for reading from a network connection.
An interface for writing to a network connection.
IDL-friendly connection reader.
Definition: WireReader.h:27
bool readNested(WirePortable &obj)
Definition: WireReader.cpp:82
bool readI32(std::int32_t &x)
Definition: WireReader.cpp:169
bool read(WirePortable &obj)
Definition: WireReader.cpp:72
bool readFloat64(yarp::conf::float64_t &x)
Definition: WireReader.cpp:271
IDL-friendly connection writer.
Definition: WireWriter.h:28
bool writeI32(std::int32_t x) const
Definition: WireWriter.cpp:91
bool write(const WirePortable &obj) const
Definition: WireWriter.cpp:50
bool writeListHeader(int len) const
Definition: WireWriter.cpp:204
bool writeFloat64(yarp::conf::float64_t x) const
Definition: WireWriter.cpp:112
bool writeNested(const WirePortable &obj) const
Definition: WireWriter.cpp:60
For streams capable of holding different kinds of content, check what they actually have.