YARP
Yet Another Robot Platform
ImageMarker.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 "visualization_msgs/ImageMarker" msg definition:
9 // uint8 CIRCLE=0
10 // uint8 LINE_STRIP=1
11 // uint8 LINE_LIST=2
12 // uint8 POLYGON=3
13 // uint8 POINTS=4
14 //
15 // uint8 ADD=0
16 // uint8 REMOVE=1
17 //
18 // Header header
19 // string ns # namespace, used with id to form a unique id
20 // int32 id # unique id within the namespace
21 // int32 type # CIRCLE/LINE_STRIP/etc.
22 // int32 action # ADD/REMOVE
23 // geometry_msgs/Point position # 2D, in pixel-coords
24 // float32 scale # the diameter for a circle, etc.
25 // std_msgs/ColorRGBA outline_color
26 // uint8 filled # whether to fill in the shape with color
27 // std_msgs/ColorRGBA fill_color # color [0.0-1.0]
28 // duration lifetime # How long the object should last before being automatically deleted. 0 means forever
29 //
30 //
31 // geometry_msgs/Point[] points # used for LINE_STRIP/LINE_LIST/POINTS/etc., 2D in pixel coords
32 // std_msgs/ColorRGBA[] outline_colors # a color for each line, point, etc.// Instances of this class can be read and written with YARP ports,
33 // using a ROS-compatible format.
34 
35 #ifndef YARP_ROSMSG_visualization_msgs_ImageMarker_h
36 #define YARP_ROSMSG_visualization_msgs_ImageMarker_h
37 
38 #include <yarp/os/Wire.h>
39 #include <yarp/os/Type.h>
40 #include <yarp/os/idl/WireTypes.h>
41 #include <string>
42 #include <vector>
47 
48 namespace yarp {
49 namespace rosmsg {
50 namespace visualization_msgs {
51 
53 {
54 public:
55  static const std::uint8_t CIRCLE = 0;
56  static const std::uint8_t LINE_STRIP = 1;
57  static const std::uint8_t LINE_LIST = 2;
58  static const std::uint8_t POLYGON = 3;
59  static const std::uint8_t POINTS = 4;
60  static const std::uint8_t ADD = 0;
61  static const std::uint8_t REMOVE = 1;
63  std::string ns;
64  std::int32_t id;
65  std::int32_t type;
66  std::int32_t action;
70  std::uint8_t filled;
73  std::vector<yarp::rosmsg::geometry_msgs::Point> points;
74  std::vector<yarp::rosmsg::std_msgs::ColorRGBA> outline_colors;
75 
77  header(),
78  ns(""),
79  id(0),
80  type(0),
81  action(0),
82  position(),
83  scale(0.0f),
84  outline_color(),
85  filled(0),
86  fill_color(),
87  lifetime(),
88  points(),
90  {
91  }
92 
93  void clear()
94  {
95  // *** CIRCLE ***
96 
97  // *** LINE_STRIP ***
98 
99  // *** LINE_LIST ***
100 
101  // *** POLYGON ***
102 
103  // *** POINTS ***
104 
105  // *** ADD ***
106 
107  // *** REMOVE ***
108 
109  // *** header ***
110  header.clear();
111 
112  // *** ns ***
113  ns = "";
114 
115  // *** id ***
116  id = 0;
117 
118  // *** type ***
119  type = 0;
120 
121  // *** action ***
122  action = 0;
123 
124  // *** position ***
125  position.clear();
126 
127  // *** scale ***
128  scale = 0.0f;
129 
130  // *** outline_color ***
132 
133  // *** filled ***
134  filled = 0;
135 
136  // *** fill_color ***
137  fill_color.clear();
138 
139  // *** lifetime ***
140  lifetime.clear();
141 
142  // *** points ***
143  points.clear();
144 
145  // *** outline_colors ***
146  outline_colors.clear();
147  }
148 
149  bool readBare(yarp::os::ConnectionReader& connection) override
150  {
151  // *** header ***
152  if (!header.read(connection)) {
153  return false;
154  }
155 
156  // *** ns ***
157  int len = connection.expectInt32();
158  ns.resize(len);
159  if (!connection.expectBlock((char*)ns.c_str(), len)) {
160  return false;
161  }
162 
163  // *** id ***
164  id = connection.expectInt32();
165 
166  // *** type ***
167  type = connection.expectInt32();
168 
169  // *** action ***
170  action = connection.expectInt32();
171 
172  // *** position ***
173  if (!position.read(connection)) {
174  return false;
175  }
176 
177  // *** scale ***
178  scale = connection.expectFloat32();
179 
180  // *** outline_color ***
181  if (!outline_color.read(connection)) {
182  return false;
183  }
184 
185  // *** filled ***
186  filled = connection.expectInt8();
187 
188  // *** fill_color ***
189  if (!fill_color.read(connection)) {
190  return false;
191  }
192 
193  // *** lifetime ***
194  if (!lifetime.read(connection)) {
195  return false;
196  }
197 
198  // *** points ***
199  len = connection.expectInt32();
200  points.resize(len);
201  for (int i=0; i<len; i++) {
202  if (!points[i].read(connection)) {
203  return false;
204  }
205  }
206 
207  // *** outline_colors ***
208  len = connection.expectInt32();
209  outline_colors.resize(len);
210  for (int i=0; i<len; i++) {
211  if (!outline_colors[i].read(connection)) {
212  return false;
213  }
214  }
215 
216  return !connection.isError();
217  }
218 
219  bool readBottle(yarp::os::ConnectionReader& connection) override
220  {
221  connection.convertTextMode();
222  yarp::os::idl::WireReader reader(connection);
223  if (!reader.readListHeader(20)) {
224  return false;
225  }
226 
227  // *** header ***
228  if (!header.read(connection)) {
229  return false;
230  }
231 
232  // *** ns ***
233  if (!reader.readString(ns)) {
234  return false;
235  }
236 
237  // *** id ***
238  id = reader.expectInt32();
239 
240  // *** type ***
241  type = reader.expectInt32();
242 
243  // *** action ***
244  action = reader.expectInt32();
245 
246  // *** position ***
247  if (!position.read(connection)) {
248  return false;
249  }
250 
251  // *** scale ***
252  scale = reader.expectFloat32();
253 
254  // *** outline_color ***
255  if (!outline_color.read(connection)) {
256  return false;
257  }
258 
259  // *** filled ***
260  filled = reader.expectInt8();
261 
262  // *** fill_color ***
263  if (!fill_color.read(connection)) {
264  return false;
265  }
266 
267  // *** lifetime ***
268  if (!lifetime.read(connection)) {
269  return false;
270  }
271 
272  // *** points ***
273  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
274  return false;
275  }
276  int len = connection.expectInt32();
277  points.resize(len);
278  for (int i=0; i<len; i++) {
279  if (!points[i].read(connection)) {
280  return false;
281  }
282  }
283 
284  // *** outline_colors ***
285  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
286  return false;
287  }
288  len = connection.expectInt32();
289  outline_colors.resize(len);
290  for (int i=0; i<len; i++) {
291  if (!outline_colors[i].read(connection)) {
292  return false;
293  }
294  }
295 
296  return !connection.isError();
297  }
298 
300  bool read(yarp::os::ConnectionReader& connection) override
301  {
302  return (connection.isBareMode() ? readBare(connection)
303  : readBottle(connection));
304  }
305 
306  bool writeBare(yarp::os::ConnectionWriter& connection) const override
307  {
308  // *** header ***
309  if (!header.write(connection)) {
310  return false;
311  }
312 
313  // *** ns ***
314  connection.appendInt32(ns.length());
315  connection.appendExternalBlock((char*)ns.c_str(), ns.length());
316 
317  // *** id ***
318  connection.appendInt32(id);
319 
320  // *** type ***
321  connection.appendInt32(type);
322 
323  // *** action ***
324  connection.appendInt32(action);
325 
326  // *** position ***
327  if (!position.write(connection)) {
328  return false;
329  }
330 
331  // *** scale ***
332  connection.appendFloat32(scale);
333 
334  // *** outline_color ***
335  if (!outline_color.write(connection)) {
336  return false;
337  }
338 
339  // *** filled ***
340  connection.appendInt8(filled);
341 
342  // *** fill_color ***
343  if (!fill_color.write(connection)) {
344  return false;
345  }
346 
347  // *** lifetime ***
348  if (!lifetime.write(connection)) {
349  return false;
350  }
351 
352  // *** points ***
353  connection.appendInt32(points.size());
354  for (size_t i=0; i<points.size(); i++) {
355  if (!points[i].write(connection)) {
356  return false;
357  }
358  }
359 
360  // *** outline_colors ***
361  connection.appendInt32(outline_colors.size());
362  for (size_t i=0; i<outline_colors.size(); i++) {
363  if (!outline_colors[i].write(connection)) {
364  return false;
365  }
366  }
367 
368  return !connection.isError();
369  }
370 
371  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
372  {
373  connection.appendInt32(BOTTLE_TAG_LIST);
374  connection.appendInt32(20);
375 
376  // *** header ***
377  if (!header.write(connection)) {
378  return false;
379  }
380 
381  // *** ns ***
382  connection.appendInt32(BOTTLE_TAG_STRING);
383  connection.appendInt32(ns.length());
384  connection.appendExternalBlock((char*)ns.c_str(), ns.length());
385 
386  // *** id ***
387  connection.appendInt32(BOTTLE_TAG_INT32);
388  connection.appendInt32(id);
389 
390  // *** type ***
391  connection.appendInt32(BOTTLE_TAG_INT32);
392  connection.appendInt32(type);
393 
394  // *** action ***
395  connection.appendInt32(BOTTLE_TAG_INT32);
396  connection.appendInt32(action);
397 
398  // *** position ***
399  if (!position.write(connection)) {
400  return false;
401  }
402 
403  // *** scale ***
404  connection.appendInt32(BOTTLE_TAG_FLOAT32);
405  connection.appendFloat32(scale);
406 
407  // *** outline_color ***
408  if (!outline_color.write(connection)) {
409  return false;
410  }
411 
412  // *** filled ***
413  connection.appendInt32(BOTTLE_TAG_INT8);
414  connection.appendInt8(filled);
415 
416  // *** fill_color ***
417  if (!fill_color.write(connection)) {
418  return false;
419  }
420 
421  // *** lifetime ***
422  if (!lifetime.write(connection)) {
423  return false;
424  }
425 
426  // *** points ***
427  connection.appendInt32(BOTTLE_TAG_LIST);
428  connection.appendInt32(points.size());
429  for (size_t i=0; i<points.size(); i++) {
430  if (!points[i].write(connection)) {
431  return false;
432  }
433  }
434 
435  // *** outline_colors ***
436  connection.appendInt32(BOTTLE_TAG_LIST);
437  connection.appendInt32(outline_colors.size());
438  for (size_t i=0; i<outline_colors.size(); i++) {
439  if (!outline_colors[i].write(connection)) {
440  return false;
441  }
442  }
443 
444  connection.convertTextMode();
445  return !connection.isError();
446  }
447 
449  bool write(yarp::os::ConnectionWriter& connection) const override
450  {
451  return (connection.isBareMode() ? writeBare(connection)
452  : writeBottle(connection));
453  }
454 
455  // This class will serialize ROS style or YARP style depending on protocol.
456  // If you need to force a serialization style, use one of these classes:
459 
460  // The name for this message, ROS will need this
461  static constexpr const char* typeName = "visualization_msgs/ImageMarker";
462 
463  // The checksum for this message, ROS will need this
464  static constexpr const char* typeChecksum = "1de93c67ec8858b831025a08fbf1b35c";
465 
466  // The source text for this message, ROS will need this
467  static constexpr const char* typeText = "\
468 uint8 CIRCLE=0\n\
469 uint8 LINE_STRIP=1\n\
470 uint8 LINE_LIST=2\n\
471 uint8 POLYGON=3\n\
472 uint8 POINTS=4\n\
473 \n\
474 uint8 ADD=0\n\
475 uint8 REMOVE=1\n\
476 \n\
477 Header header\n\
478 string ns # namespace, used with id to form a unique id\n\
479 int32 id # unique id within the namespace\n\
480 int32 type # CIRCLE/LINE_STRIP/etc.\n\
481 int32 action # ADD/REMOVE\n\
482 geometry_msgs/Point position # 2D, in pixel-coords\n\
483 float32 scale # the diameter for a circle, etc.\n\
484 std_msgs/ColorRGBA outline_color\n\
485 uint8 filled # whether to fill in the shape with color\n\
486 std_msgs/ColorRGBA fill_color # color [0.0-1.0]\n\
487 duration lifetime # How long the object should last before being automatically deleted. 0 means forever\n\
488 \n\
489 \n\
490 geometry_msgs/Point[] points # used for LINE_STRIP/LINE_LIST/POINTS/etc., 2D in pixel coords\n\
491 std_msgs/ColorRGBA[] outline_colors # a color for each line, point, etc.\n\
492 ================================================================================\n\
493 MSG: std_msgs/Header\n\
494 # Standard metadata for higher-level stamped data types.\n\
495 # This is generally used to communicate timestamped data \n\
496 # in a particular coordinate frame.\n\
497 # \n\
498 # sequence ID: consecutively increasing ID \n\
499 uint32 seq\n\
500 #Two-integer timestamp that is expressed as:\n\
501 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
502 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
503 # time-handling sugar is provided by the client library\n\
504 time stamp\n\
505 #Frame this data is associated with\n\
506 # 0: no frame\n\
507 # 1: global frame\n\
508 string frame_id\n\
509 \n\
510 ================================================================================\n\
511 MSG: geometry_msgs/Point\n\
512 # This contains the position of a point in free space\n\
513 float64 x\n\
514 float64 y\n\
515 float64 z\n\
516 \n\
517 ================================================================================\n\
518 MSG: std_msgs/ColorRGBA\n\
519 float32 r\n\
520 float32 g\n\
521 float32 b\n\
522 float32 a\n\
523 ";
524 
525  yarp::os::Type getType() const override
526  {
528  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
529  typ.addProperty("message_definition", yarp::os::Value(typeText));
530  return typ;
531  }
532 };
533 
534 } // namespace visualization_msgs
535 } // namespace rosmsg
536 } // namespace yarp
537 
538 #endif // YARP_ROSMSG_visualization_msgs_ImageMarker_h
#define BOTTLE_TAG_INT8
Definition: Bottle.h:19
#define BOTTLE_TAG_INT32
Definition: Bottle.h:21
#define BOTTLE_TAG_STRING
Definition: Bottle.h:26
#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 expectBlock(char *data, size_t len)=0
Read a block of data from the 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
virtual std::int8_t expectInt8()=0
Read a 8-bit integer from the network connection.
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 appendInt8(std::int8_t data)=0
Send a representation of a 8-bit integer to the network connection.
virtual void appendFloat32(yarp::conf::float32_t data)=0
Send a representation of a 32-bit floating point number to the network connection.
virtual void appendExternalBlock(const char *data, size_t len)=0
Send a block of data to the network connection, without making a copy.
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:45
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:23
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:30
bool readString(std::string &str, bool *is_vocab=nullptr)
Definition: WireReader.cpp:382
std::int8_t expectInt8()
Definition: WireReader.h:80
std::int32_t expectInt32()
Definition: WireReader.h:92
yarp::conf::float32_t expectFloat32()
Definition: WireReader.h:106
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: TickDuration.h:148
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: TickDuration.h:113
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Point.h:132
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Point.h:90
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: ColorRGBA.h:101
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: ColorRGBA.h:150
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
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: ImageMarker.h:306
static constexpr const char * typeChecksum
Definition: ImageMarker.h:464
std::vector< yarp::rosmsg::std_msgs::ColorRGBA > outline_colors
Definition: ImageMarker.h:74
std::vector< yarp::rosmsg::geometry_msgs::Point > points
Definition: ImageMarker.h:73
yarp::os::idl::BottleStyle< yarp::rosmsg::visualization_msgs::ImageMarker > bottleStyle
Definition: ImageMarker.h:458
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: ImageMarker.h:371
yarp::rosmsg::std_msgs::ColorRGBA outline_color
Definition: ImageMarker.h:69
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: ImageMarker.h:219
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: ImageMarker.h:300
yarp::os::Type getType() const override
Definition: ImageMarker.h:525
static constexpr const char * typeName
Definition: ImageMarker.h:461
yarp::rosmsg::std_msgs::ColorRGBA fill_color
Definition: ImageMarker.h:71
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: ImageMarker.h:449
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: ImageMarker.h:149
yarp::os::idl::BareStyle< yarp::rosmsg::visualization_msgs::ImageMarker > rosStyle
Definition: ImageMarker.h:457
static constexpr const char * typeText
Definition: ImageMarker.h:467
yarp::rosmsg::std_msgs::Header header
Definition: ImageMarker.h:62
yarp::rosmsg::geometry_msgs::Point position
Definition: ImageMarker.h:67
float float32_t
Definition: numeric.h:76
The main, catch-all namespace for YARP.
Definition: dirs.h:16