YARP
Yet Another Robot Platform
InteractiveMarker.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/InteractiveMarker" msg definition:
9 // # Time/frame info.
10 // # If header.time is set to 0, the marker will be retransformed into
11 // # its frame on each timestep. You will receive the pose feedback
12 // # in the same frame.
13 // # Otherwise, you might receive feedback in a different frame.
14 // # For rviz, this will be the current 'fixed frame' set by the user.
15 // Header header
16 //
17 // # Initial pose. Also, defines the pivot point for rotations.
18 // geometry_msgs/Pose pose
19 //
20 // # Identifying string. Must be globally unique in
21 // # the topic that this message is sent through.
22 // string name
23 //
24 // # Short description (< 40 characters).
25 // string description
26 //
27 // # Scale to be used for default controls (default=1).
28 // float32 scale
29 //
30 // # All menu and submenu entries associated with this marker.
31 // MenuEntry[] menu_entries
32 //
33 // # List of controls displayed for this marker.
34 // InteractiveMarkerControl[] controls
35 // Instances of this class can be read and written with YARP ports,
36 // using a ROS-compatible format.
37 
38 #ifndef YARP_ROSMSG_visualization_msgs_InteractiveMarker_h
39 #define YARP_ROSMSG_visualization_msgs_InteractiveMarker_h
40 
41 #include <yarp/os/Wire.h>
42 #include <yarp/os/Type.h>
43 #include <yarp/os/idl/WireTypes.h>
44 #include <string>
45 #include <vector>
50 
51 namespace yarp {
52 namespace rosmsg {
53 namespace visualization_msgs {
54 
56 {
57 public:
60  std::string name;
61  std::string description;
63  std::vector<yarp::rosmsg::visualization_msgs::MenuEntry> menu_entries;
64  std::vector<yarp::rosmsg::visualization_msgs::InteractiveMarkerControl> controls;
65 
67  header(),
68  pose(),
69  name(""),
70  description(""),
71  scale(0.0f),
72  menu_entries(),
73  controls()
74  {
75  }
76 
77  void clear()
78  {
79  // *** header ***
80  header.clear();
81 
82  // *** pose ***
83  pose.clear();
84 
85  // *** name ***
86  name = "";
87 
88  // *** description ***
89  description = "";
90 
91  // *** scale ***
92  scale = 0.0f;
93 
94  // *** menu_entries ***
95  menu_entries.clear();
96 
97  // *** controls ***
98  controls.clear();
99  }
100 
101  bool readBare(yarp::os::ConnectionReader& connection) override
102  {
103  // *** header ***
104  if (!header.read(connection)) {
105  return false;
106  }
107 
108  // *** pose ***
109  if (!pose.read(connection)) {
110  return false;
111  }
112 
113  // *** name ***
114  int len = connection.expectInt32();
115  name.resize(len);
116  if (!connection.expectBlock((char*)name.c_str(), len)) {
117  return false;
118  }
119 
120  // *** description ***
121  len = connection.expectInt32();
122  description.resize(len);
123  if (!connection.expectBlock((char*)description.c_str(), len)) {
124  return false;
125  }
126 
127  // *** scale ***
128  scale = connection.expectFloat32();
129 
130  // *** menu_entries ***
131  len = connection.expectInt32();
132  menu_entries.resize(len);
133  for (int i=0; i<len; i++) {
134  if (!menu_entries[i].read(connection)) {
135  return false;
136  }
137  }
138 
139  // *** controls ***
140  len = connection.expectInt32();
141  controls.resize(len);
142  for (int i=0; i<len; i++) {
143  if (!controls[i].read(connection)) {
144  return false;
145  }
146  }
147 
148  return !connection.isError();
149  }
150 
151  bool readBottle(yarp::os::ConnectionReader& connection) override
152  {
153  connection.convertTextMode();
154  yarp::os::idl::WireReader reader(connection);
155  if (!reader.readListHeader(7)) {
156  return false;
157  }
158 
159  // *** header ***
160  if (!header.read(connection)) {
161  return false;
162  }
163 
164  // *** pose ***
165  if (!pose.read(connection)) {
166  return false;
167  }
168 
169  // *** name ***
170  if (!reader.readString(name)) {
171  return false;
172  }
173 
174  // *** description ***
175  if (!reader.readString(description)) {
176  return false;
177  }
178 
179  // *** scale ***
180  scale = reader.expectFloat32();
181 
182  // *** menu_entries ***
183  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
184  return false;
185  }
186  int len = connection.expectInt32();
187  menu_entries.resize(len);
188  for (int i=0; i<len; i++) {
189  if (!menu_entries[i].read(connection)) {
190  return false;
191  }
192  }
193 
194  // *** controls ***
195  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
196  return false;
197  }
198  len = connection.expectInt32();
199  controls.resize(len);
200  for (int i=0; i<len; i++) {
201  if (!controls[i].read(connection)) {
202  return false;
203  }
204  }
205 
206  return !connection.isError();
207  }
208 
210  bool read(yarp::os::ConnectionReader& connection) override
211  {
212  return (connection.isBareMode() ? readBare(connection)
213  : readBottle(connection));
214  }
215 
216  bool writeBare(yarp::os::ConnectionWriter& connection) const override
217  {
218  // *** header ***
219  if (!header.write(connection)) {
220  return false;
221  }
222 
223  // *** pose ***
224  if (!pose.write(connection)) {
225  return false;
226  }
227 
228  // *** name ***
229  connection.appendInt32(name.length());
230  connection.appendExternalBlock((char*)name.c_str(), name.length());
231 
232  // *** description ***
233  connection.appendInt32(description.length());
234  connection.appendExternalBlock((char*)description.c_str(), description.length());
235 
236  // *** scale ***
237  connection.appendFloat32(scale);
238 
239  // *** menu_entries ***
240  connection.appendInt32(menu_entries.size());
241  for (size_t i=0; i<menu_entries.size(); i++) {
242  if (!menu_entries[i].write(connection)) {
243  return false;
244  }
245  }
246 
247  // *** controls ***
248  connection.appendInt32(controls.size());
249  for (size_t i=0; i<controls.size(); i++) {
250  if (!controls[i].write(connection)) {
251  return false;
252  }
253  }
254 
255  return !connection.isError();
256  }
257 
258  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
259  {
260  connection.appendInt32(BOTTLE_TAG_LIST);
261  connection.appendInt32(7);
262 
263  // *** header ***
264  if (!header.write(connection)) {
265  return false;
266  }
267 
268  // *** pose ***
269  if (!pose.write(connection)) {
270  return false;
271  }
272 
273  // *** name ***
274  connection.appendInt32(BOTTLE_TAG_STRING);
275  connection.appendInt32(name.length());
276  connection.appendExternalBlock((char*)name.c_str(), name.length());
277 
278  // *** description ***
279  connection.appendInt32(BOTTLE_TAG_STRING);
280  connection.appendInt32(description.length());
281  connection.appendExternalBlock((char*)description.c_str(), description.length());
282 
283  // *** scale ***
284  connection.appendInt32(BOTTLE_TAG_FLOAT32);
285  connection.appendFloat32(scale);
286 
287  // *** menu_entries ***
288  connection.appendInt32(BOTTLE_TAG_LIST);
289  connection.appendInt32(menu_entries.size());
290  for (size_t i=0; i<menu_entries.size(); i++) {
291  if (!menu_entries[i].write(connection)) {
292  return false;
293  }
294  }
295 
296  // *** controls ***
297  connection.appendInt32(BOTTLE_TAG_LIST);
298  connection.appendInt32(controls.size());
299  for (size_t i=0; i<controls.size(); i++) {
300  if (!controls[i].write(connection)) {
301  return false;
302  }
303  }
304 
305  connection.convertTextMode();
306  return !connection.isError();
307  }
308 
310  bool write(yarp::os::ConnectionWriter& connection) const override
311  {
312  return (connection.isBareMode() ? writeBare(connection)
313  : writeBottle(connection));
314  }
315 
316  // This class will serialize ROS style or YARP style depending on protocol.
317  // If you need to force a serialization style, use one of these classes:
320 
321  // The name for this message, ROS will need this
322  static constexpr const char* typeName = "visualization_msgs/InteractiveMarker";
323 
324  // The checksum for this message, ROS will need this
325  static constexpr const char* typeChecksum = "dd86d22909d5a3364b384492e35c10af";
326 
327  // The source text for this message, ROS will need this
328  static constexpr const char* typeText = "\
329 # Time/frame info.\n\
330 # If header.time is set to 0, the marker will be retransformed into\n\
331 # its frame on each timestep. You will receive the pose feedback\n\
332 # in the same frame.\n\
333 # Otherwise, you might receive feedback in a different frame.\n\
334 # For rviz, this will be the current 'fixed frame' set by the user.\n\
335 Header header\n\
336 \n\
337 # Initial pose. Also, defines the pivot point for rotations.\n\
338 geometry_msgs/Pose pose\n\
339 \n\
340 # Identifying string. Must be globally unique in\n\
341 # the topic that this message is sent through.\n\
342 string name\n\
343 \n\
344 # Short description (< 40 characters).\n\
345 string description\n\
346 \n\
347 # Scale to be used for default controls (default=1).\n\
348 float32 scale\n\
349 \n\
350 # All menu and submenu entries associated with this marker.\n\
351 MenuEntry[] menu_entries\n\
352 \n\
353 # List of controls displayed for this marker.\n\
354 InteractiveMarkerControl[] controls\n\
355 \n\
356 ================================================================================\n\
357 MSG: std_msgs/Header\n\
358 # Standard metadata for higher-level stamped data types.\n\
359 # This is generally used to communicate timestamped data \n\
360 # in a particular coordinate frame.\n\
361 # \n\
362 # sequence ID: consecutively increasing ID \n\
363 uint32 seq\n\
364 #Two-integer timestamp that is expressed as:\n\
365 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
366 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
367 # time-handling sugar is provided by the client library\n\
368 time stamp\n\
369 #Frame this data is associated with\n\
370 # 0: no frame\n\
371 # 1: global frame\n\
372 string frame_id\n\
373 \n\
374 ================================================================================\n\
375 MSG: geometry_msgs/Pose\n\
376 # A representation of pose in free space, composed of position and orientation. \n\
377 Point position\n\
378 Quaternion orientation\n\
379 \n\
380 ================================================================================\n\
381 MSG: geometry_msgs/Point\n\
382 # This contains the position of a point in free space\n\
383 float64 x\n\
384 float64 y\n\
385 float64 z\n\
386 \n\
387 ================================================================================\n\
388 MSG: geometry_msgs/Quaternion\n\
389 # This represents an orientation in free space in quaternion form.\n\
390 \n\
391 float64 x\n\
392 float64 y\n\
393 float64 z\n\
394 float64 w\n\
395 \n\
396 ================================================================================\n\
397 MSG: visualization_msgs/MenuEntry\n\
398 # MenuEntry message.\n\
399 \n\
400 # Each InteractiveMarker message has an array of MenuEntry messages.\n\
401 # A collection of MenuEntries together describe a\n\
402 # menu/submenu/subsubmenu/etc tree, though they are stored in a flat\n\
403 # array. The tree structure is represented by giving each menu entry\n\
404 # an ID number and a \"parent_id\" field. Top-level entries are the\n\
405 # ones with parent_id = 0. Menu entries are ordered within their\n\
406 # level the same way they are ordered in the containing array. Parent\n\
407 # entries must appear before their children.\n\
408 \n\
409 # Example:\n\
410 # - id = 3\n\
411 # parent_id = 0\n\
412 # title = \"fun\"\n\
413 # - id = 2\n\
414 # parent_id = 0\n\
415 # title = \"robot\"\n\
416 # - id = 4\n\
417 # parent_id = 2\n\
418 # title = \"pr2\"\n\
419 # - id = 5\n\
420 # parent_id = 2\n\
421 # title = \"turtle\"\n\
422 #\n\
423 # Gives a menu tree like this:\n\
424 # - fun\n\
425 # - robot\n\
426 # - pr2\n\
427 # - turtle\n\
428 \n\
429 # ID is a number for each menu entry. Must be unique within the\n\
430 # control, and should never be 0.\n\
431 uint32 id\n\
432 \n\
433 # ID of the parent of this menu entry, if it is a submenu. If this\n\
434 # menu entry is a top-level entry, set parent_id to 0.\n\
435 uint32 parent_id\n\
436 \n\
437 # menu / entry title\n\
438 string title\n\
439 \n\
440 # Arguments to command indicated by command_type (below)\n\
441 string command\n\
442 \n\
443 # Command_type stores the type of response desired when this menu\n\
444 # entry is clicked.\n\
445 # FEEDBACK: send an InteractiveMarkerFeedback message with menu_entry_id set to this entry's id.\n\
446 # ROSRUN: execute \"rosrun\" with arguments given in the command field (above).\n\
447 # ROSLAUNCH: execute \"roslaunch\" with arguments given in the command field (above).\n\
448 uint8 FEEDBACK=0\n\
449 uint8 ROSRUN=1\n\
450 uint8 ROSLAUNCH=2\n\
451 uint8 command_type\n\
452 \n\
453 ================================================================================\n\
454 MSG: visualization_msgs/InteractiveMarkerControl\n\
455 # Represents a control that is to be displayed together with an interactive marker\n\
456 \n\
457 # Identifying string for this control.\n\
458 # You need to assign a unique value to this to receive feedback from the GUI\n\
459 # on what actions the user performs on this control (e.g. a button click).\n\
460 string name\n\
461 \n\
462 \n\
463 # Defines the local coordinate frame (relative to the pose of the parent\n\
464 # interactive marker) in which is being rotated and translated.\n\
465 # Default: Identity\n\
466 geometry_msgs/Quaternion orientation\n\
467 \n\
468 \n\
469 # Orientation mode: controls how orientation changes.\n\
470 # INHERIT: Follow orientation of interactive marker\n\
471 # FIXED: Keep orientation fixed at initial state\n\
472 # VIEW_FACING: Align y-z plane with screen (x: forward, y:left, z:up).\n\
473 uint8 INHERIT = 0 \n\
474 uint8 FIXED = 1\n\
475 uint8 VIEW_FACING = 2\n\
476 \n\
477 uint8 orientation_mode\n\
478 \n\
479 # Interaction mode for this control\n\
480 # \n\
481 # NONE: This control is only meant for visualization; no context menu.\n\
482 # MENU: Like NONE, but right-click menu is active.\n\
483 # BUTTON: Element can be left-clicked.\n\
484 # MOVE_AXIS: Translate along local x-axis.\n\
485 # MOVE_PLANE: Translate in local y-z plane.\n\
486 # ROTATE_AXIS: Rotate around local x-axis.\n\
487 # MOVE_ROTATE: Combines MOVE_PLANE and ROTATE_AXIS.\n\
488 uint8 NONE = 0 \n\
489 uint8 MENU = 1\n\
490 uint8 BUTTON = 2\n\
491 uint8 MOVE_AXIS = 3 \n\
492 uint8 MOVE_PLANE = 4\n\
493 uint8 ROTATE_AXIS = 5\n\
494 uint8 MOVE_ROTATE = 6\n\
495 # \"3D\" interaction modes work with the mouse+SHIFT+CTRL or with 3D cursors.\n\
496 # MOVE_3D: Translate freely in 3D space.\n\
497 # ROTATE_3D: Rotate freely in 3D space about the origin of parent frame.\n\
498 # MOVE_ROTATE_3D: Full 6-DOF freedom of translation and rotation about the cursor origin.\n\
499 uint8 MOVE_3D = 7\n\
500 uint8 ROTATE_3D = 8\n\
501 uint8 MOVE_ROTATE_3D = 9\n\
502 \n\
503 uint8 interaction_mode\n\
504 \n\
505 \n\
506 # If true, the contained markers will also be visible\n\
507 # when the gui is not in interactive mode.\n\
508 bool always_visible\n\
509 \n\
510 \n\
511 # Markers to be displayed as custom visual representation.\n\
512 # Leave this empty to use the default control handles.\n\
513 #\n\
514 # Note: \n\
515 # - The markers can be defined in an arbitrary coordinate frame,\n\
516 # but will be transformed into the local frame of the interactive marker.\n\
517 # - If the header of a marker is empty, its pose will be interpreted as \n\
518 # relative to the pose of the parent interactive marker.\n\
519 Marker[] markers\n\
520 \n\
521 \n\
522 # In VIEW_FACING mode, set this to true if you don't want the markers\n\
523 # to be aligned with the camera view point. The markers will show up\n\
524 # as in INHERIT mode.\n\
525 bool independent_marker_orientation\n\
526 \n\
527 \n\
528 # Short description (< 40 characters) of what this control does,\n\
529 # e.g. \"Move the robot\". \n\
530 # Default: A generic description based on the interaction mode\n\
531 string description\n\
532 \n\
533 ================================================================================\n\
534 MSG: visualization_msgs/Marker\n\
535 # See http://www.ros.org/wiki/rviz/DisplayTypes/Marker and http://www.ros.org/wiki/rviz/Tutorials/Markers%3A%20Basic%20Shapes for more information on using this message with rviz\n\
536 \n\
537 uint8 ARROW=0\n\
538 uint8 CUBE=1\n\
539 uint8 SPHERE=2\n\
540 uint8 CYLINDER=3\n\
541 uint8 LINE_STRIP=4\n\
542 uint8 LINE_LIST=5\n\
543 uint8 CUBE_LIST=6\n\
544 uint8 SPHERE_LIST=7\n\
545 uint8 POINTS=8\n\
546 uint8 TEXT_VIEW_FACING=9\n\
547 uint8 MESH_RESOURCE=10\n\
548 uint8 TRIANGLE_LIST=11\n\
549 \n\
550 uint8 ADD=0\n\
551 uint8 MODIFY=0\n\
552 uint8 DELETE=2\n\
553 uint8 DELETEALL=3\n\
554 \n\
555 Header header # header for time/frame information\n\
556 string ns # Namespace to place this object in... used in conjunction with id to create a unique name for the object\n\
557 int32 id # object ID useful in conjunction with the namespace for manipulating and deleting the object later\n\
558 int32 type # Type of object\n\
559 int32 action # 0 add/modify an object, 1 (deprecated), 2 deletes an object, 3 deletes all objects\n\
560 geometry_msgs/Pose pose # Pose of the object\n\
561 geometry_msgs/Vector3 scale # Scale of the object 1,1,1 means default (usually 1 meter square)\n\
562 std_msgs/ColorRGBA color # Color [0.0-1.0]\n\
563 duration lifetime # How long the object should last before being automatically deleted. 0 means forever\n\
564 bool frame_locked # If this marker should be frame-locked, i.e. retransformed into its frame every timestep\n\
565 \n\
566 #Only used if the type specified has some use for them (eg. POINTS, LINE_STRIP, ...)\n\
567 geometry_msgs/Point[] points\n\
568 #Only used if the type specified has some use for them (eg. POINTS, LINE_STRIP, ...)\n\
569 #number of colors must either be 0 or equal to the number of points\n\
570 #NOTE: alpha is not yet used\n\
571 std_msgs/ColorRGBA[] colors\n\
572 \n\
573 # NOTE: only used for text markers\n\
574 string text\n\
575 \n\
576 # NOTE: only used for MESH_RESOURCE markers\n\
577 string mesh_resource\n\
578 bool mesh_use_embedded_materials\n\
579 \n\
580 ================================================================================\n\
581 MSG: geometry_msgs/Vector3\n\
582 # This represents a vector in free space. \n\
583 # It is only meant to represent a direction. Therefore, it does not\n\
584 # make sense to apply a translation to it (e.g., when applying a \n\
585 # generic rigid transformation to a Vector3, tf2 will only apply the\n\
586 # rotation). If you want your data to be translatable too, use the\n\
587 # geometry_msgs/Point message instead.\n\
588 \n\
589 float64 x\n\
590 float64 y\n\
591 float64 z\n\
592 ================================================================================\n\
593 MSG: std_msgs/ColorRGBA\n\
594 float32 r\n\
595 float32 g\n\
596 float32 b\n\
597 float32 a\n\
598 ";
599 
600  yarp::os::Type getType() const override
601  {
603  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
604  typ.addProperty("message_definition", yarp::os::Value(typeText));
605  return typ;
606  }
607 };
608 
609 } // namespace visualization_msgs
610 } // namespace rosmsg
611 } // namespace yarp
612 
613 #endif // YARP_ROSMSG_visualization_msgs_InteractiveMarker_h
#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
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 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
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: Pose.h:129
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Pose.h:88
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
yarp::os::idl::BareStyle< yarp::rosmsg::visualization_msgs::InteractiveMarker > rosStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::visualization_msgs::InteractiveMarker > bottleStyle
bool readBottle(yarp::os::ConnectionReader &connection) override
bool writeBare(yarp::os::ConnectionWriter &connection) const override
std::vector< yarp::rosmsg::visualization_msgs::MenuEntry > menu_entries
bool readBare(yarp::os::ConnectionReader &connection) override
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
std::vector< yarp::rosmsg::visualization_msgs::InteractiveMarkerControl > controls
float float32_t
Definition: numeric.h:76
The main, catch-all namespace for YARP.
Definition: dirs.h:16