YARP
Yet Another Robot Platform
SolidPrimitive.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 "shape_msgs/SolidPrimitive" msg definition:
12 // # Define box, sphere, cylinder, cone
13 // # All shapes are defined to have their bounding boxes centered around 0,0,0.
14 //
15 // uint8 BOX=1
16 // uint8 SPHERE=2
17 // uint8 CYLINDER=3
18 // uint8 CONE=4
19 //
20 // # The type of the shape
21 // uint8 type
22 //
23 //
24 // # The dimensions of the shape
25 // float64[] dimensions
26 //
27 // # The meaning of the shape dimensions: each constant defines the index in the 'dimensions' array
28 //
29 // # For the BOX type, the X, Y, and Z dimensions are the length of the corresponding
30 // # sides of the box.
31 // uint8 BOX_X=0
32 // uint8 BOX_Y=1
33 // uint8 BOX_Z=2
34 //
35 //
36 // # For the SPHERE type, only one component is used, and it gives the radius of
37 // # the sphere.
38 // uint8 SPHERE_RADIUS=0
39 //
40 //
41 // # For the CYLINDER and CONE types, the center line is oriented along
42 // # the Z axis. Therefore the CYLINDER_HEIGHT (CONE_HEIGHT) component
43 // # of dimensions gives the height of the cylinder (cone). The
44 // # CYLINDER_RADIUS (CONE_RADIUS) component of dimensions gives the
45 // # radius of the base of the cylinder (cone). Cone and cylinder
46 // # primitives are defined to be circular. The tip of the cone is
47 // # pointing up, along +Z axis.
48 //
49 // uint8 CYLINDER_HEIGHT=0
50 // uint8 CYLINDER_RADIUS=1
51 //
52 // uint8 CONE_HEIGHT=0
53 // uint8 CONE_RADIUS=1
54 // Instances of this class can be read and written with YARP ports,
55 // using a ROS-compatible format.
56 
57 #ifndef YARP_ROSMSG_shape_msgs_SolidPrimitive_h
58 #define YARP_ROSMSG_shape_msgs_SolidPrimitive_h
59 
60 #include <yarp/os/Wire.h>
61 #include <yarp/os/Type.h>
62 #include <yarp/os/idl/WireTypes.h>
63 #include <string>
64 #include <vector>
65 
66 namespace yarp {
67 namespace rosmsg {
68 namespace shape_msgs {
69 
71 {
72 public:
73  static const std::uint8_t BOX = 1;
74  static const std::uint8_t SPHERE = 2;
75  static const std::uint8_t CYLINDER = 3;
76  static const std::uint8_t CONE = 4;
77  std::uint8_t type;
78  std::vector<yarp::conf::float64_t> dimensions;
79  static const std::uint8_t BOX_X = 0;
80  static const std::uint8_t BOX_Y = 1;
81  static const std::uint8_t BOX_Z = 2;
82  static const std::uint8_t SPHERE_RADIUS = 0;
83  static const std::uint8_t CYLINDER_HEIGHT = 0;
84  static const std::uint8_t CYLINDER_RADIUS = 1;
85  static const std::uint8_t CONE_HEIGHT = 0;
86  static const std::uint8_t CONE_RADIUS = 1;
87 
89  type(0),
90  dimensions()
91  {
92  }
93 
94  void clear()
95  {
96  // *** BOX ***
97 
98  // *** SPHERE ***
99 
100  // *** CYLINDER ***
101 
102  // *** CONE ***
103 
104  // *** type ***
105  type = 0;
106 
107  // *** dimensions ***
108  dimensions.clear();
109 
110  // *** BOX_X ***
111 
112  // *** BOX_Y ***
113 
114  // *** BOX_Z ***
115 
116  // *** SPHERE_RADIUS ***
117 
118  // *** CYLINDER_HEIGHT ***
119 
120  // *** CYLINDER_RADIUS ***
121 
122  // *** CONE_HEIGHT ***
123 
124  // *** CONE_RADIUS ***
125  }
126 
127  bool readBare(yarp::os::ConnectionReader& connection) override
128  {
129  // *** type ***
130  type = connection.expectInt8();
131 
132  // *** dimensions ***
133  int len = connection.expectInt32();
134  dimensions.resize(len);
135  if (len > 0 && !connection.expectBlock((char*)&dimensions[0], sizeof(yarp::conf::float64_t)*len)) {
136  return false;
137  }
138 
139  return !connection.isError();
140  }
141 
142  bool readBottle(yarp::os::ConnectionReader& connection) override
143  {
144  connection.convertTextMode();
145  yarp::os::idl::WireReader reader(connection);
146  if (!reader.readListHeader(14)) {
147  return false;
148  }
149 
150  // *** type ***
151  type = reader.expectInt8();
152 
153  // *** dimensions ***
154  if (connection.expectInt32() != (BOTTLE_TAG_LIST|BOTTLE_TAG_FLOAT64)) {
155  return false;
156  }
157  int len = connection.expectInt32();
158  dimensions.resize(len);
159  for (int i=0; i<len; i++) {
161  }
162 
163  return !connection.isError();
164  }
165 
167  bool read(yarp::os::ConnectionReader& connection) override
168  {
169  return (connection.isBareMode() ? readBare(connection)
170  : readBottle(connection));
171  }
172 
173  bool writeBare(yarp::os::ConnectionWriter& connection) const override
174  {
175  // *** type ***
176  connection.appendInt8(type);
177 
178  // *** dimensions ***
179  connection.appendInt32(dimensions.size());
180  if (dimensions.size()>0) {
181  connection.appendExternalBlock((char*)&dimensions[0], sizeof(yarp::conf::float64_t)*dimensions.size());
182  }
183 
184  return !connection.isError();
185  }
186 
187  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
188  {
189  connection.appendInt32(BOTTLE_TAG_LIST);
190  connection.appendInt32(14);
191 
192  // *** type ***
193  connection.appendInt32(BOTTLE_TAG_INT8);
194  connection.appendInt8(type);
195 
196  // *** dimensions ***
198  connection.appendInt32(dimensions.size());
199  for (size_t i=0; i<dimensions.size(); i++) {
200  connection.appendFloat64(dimensions[i]);
201  }
202 
203  connection.convertTextMode();
204  return !connection.isError();
205  }
206 
208  bool write(yarp::os::ConnectionWriter& connection) const override
209  {
210  return (connection.isBareMode() ? writeBare(connection)
211  : writeBottle(connection));
212  }
213 
214  // This class will serialize ROS style or YARP style depending on protocol.
215  // If you need to force a serialization style, use one of these classes:
218 
219  // The name for this message, ROS will need this
220  static constexpr const char* typeName = "shape_msgs/SolidPrimitive";
221 
222  // The checksum for this message, ROS will need this
223  static constexpr const char* typeChecksum = "d8f8cbc74c5ff283fca29569ccefb45d";
224 
225  // The source text for this message, ROS will need this
226  static constexpr const char* typeText = "\
227 # Define box, sphere, cylinder, cone \n\
228 # All shapes are defined to have their bounding boxes centered around 0,0,0.\n\
229 \n\
230 uint8 BOX=1\n\
231 uint8 SPHERE=2\n\
232 uint8 CYLINDER=3\n\
233 uint8 CONE=4\n\
234 \n\
235 # The type of the shape\n\
236 uint8 type\n\
237 \n\
238 \n\
239 # The dimensions of the shape\n\
240 float64[] dimensions\n\
241 \n\
242 # The meaning of the shape dimensions: each constant defines the index in the 'dimensions' array\n\
243 \n\
244 # For the BOX type, the X, Y, and Z dimensions are the length of the corresponding\n\
245 # sides of the box.\n\
246 uint8 BOX_X=0\n\
247 uint8 BOX_Y=1\n\
248 uint8 BOX_Z=2\n\
249 \n\
250 \n\
251 # For the SPHERE type, only one component is used, and it gives the radius of\n\
252 # the sphere.\n\
253 uint8 SPHERE_RADIUS=0\n\
254 \n\
255 \n\
256 # For the CYLINDER and CONE types, the center line is oriented along\n\
257 # the Z axis. Therefore the CYLINDER_HEIGHT (CONE_HEIGHT) component\n\
258 # of dimensions gives the height of the cylinder (cone). The\n\
259 # CYLINDER_RADIUS (CONE_RADIUS) component of dimensions gives the\n\
260 # radius of the base of the cylinder (cone). Cone and cylinder\n\
261 # primitives are defined to be circular. The tip of the cone is\n\
262 # pointing up, along +Z axis.\n\
263 \n\
264 uint8 CYLINDER_HEIGHT=0\n\
265 uint8 CYLINDER_RADIUS=1\n\
266 \n\
267 uint8 CONE_HEIGHT=0\n\
268 uint8 CONE_RADIUS=1\n\
269 ";
270 
271  yarp::os::Type getType() const override
272  {
274  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
275  typ.addProperty("message_definition", yarp::os::Value(typeText));
276  return typ;
277  }
278 };
279 
280 } // namespace shape_msgs
281 } // namespace rosmsg
282 } // namespace yarp
283 
284 #endif // YARP_ROSMSG_shape_msgs_SolidPrimitive_h
yarp::rosmsg::shape_msgs::SolidPrimitive::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: SolidPrimitive.h:142
yarp::rosmsg::shape_msgs::SolidPrimitive::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: SolidPrimitive.h:173
yarp::rosmsg::shape_msgs::SolidPrimitive::clear
void clear()
Definition: SolidPrimitive.h:94
yarp::rosmsg::shape_msgs::SolidPrimitive::typeName
static constexpr const char * typeName
Definition: SolidPrimitive.h:220
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::rosmsg::shape_msgs::SolidPrimitive
Definition: SolidPrimitive.h:71
yarp::os::ConnectionWriter::appendFloat64
virtual void appendFloat64(yarp::conf::float64_t data)=0
Send a representation of a 64-bit floating point number to the network connection.
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
yarp::rosmsg::shape_msgs::SolidPrimitive::SPHERE_RADIUS
static const std::uint8_t SPHERE_RADIUS
Definition: SolidPrimitive.h:82
yarp::rosmsg::shape_msgs::SolidPrimitive::SolidPrimitive
SolidPrimitive()
Definition: SolidPrimitive.h:88
yarp::rosmsg::shape_msgs::SolidPrimitive::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: SolidPrimitive.h:167
yarp::os::ConnectionWriter::appendInt8
virtual void appendInt8(std::int8_t data)=0
Send a representation of a 8-bit integer to the network connection.
yarp::os::ConnectionReader::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
yarp::rosmsg::shape_msgs::SolidPrimitive::BOX_Y
static const std::uint8_t BOX_Y
Definition: SolidPrimitive.h:80
Wire.h
yarp::rosmsg::shape_msgs::SolidPrimitive::dimensions
std::vector< yarp::conf::float64_t > dimensions
Definition: SolidPrimitive.h:78
yarp::rosmsg::shape_msgs::SolidPrimitive::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::shape_msgs::SolidPrimitive > bottleStyle
Definition: SolidPrimitive.h:217
BOTTLE_TAG_INT8
#define BOTTLE_TAG_INT8
Definition: Bottle.h:21
yarp::rosmsg::shape_msgs::SolidPrimitive::BOX
static const std::uint8_t BOX
Definition: SolidPrimitive.h:73
yarp::os::ConnectionReader::expectInt8
virtual std::int8_t expectInt8()=0
Read a 8-bit integer from the network connection.
yarp::rosmsg::shape_msgs::SolidPrimitive::getType
yarp::os::Type getType() const override
Definition: SolidPrimitive.h:271
yarp::rosmsg::shape_msgs::SolidPrimitive::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: SolidPrimitive.h:127
yarp::rosmsg::shape_msgs::SolidPrimitive::CONE
static const std::uint8_t CONE
Definition: SolidPrimitive.h:76
yarp::os::ConnectionReader::expectFloat64
virtual yarp::conf::float64_t expectFloat64()=0
Read a 64-bit floating point number from the network connection.
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
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::rosmsg::shape_msgs::SolidPrimitive::SPHERE
static const std::uint8_t SPHERE
Definition: SolidPrimitive.h:74
yarp::os::Type::addProperty
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:137
Type.h
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::rosmsg::shape_msgs::SolidPrimitive::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::shape_msgs::SolidPrimitive > rosStyle
Definition: SolidPrimitive.h:216
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::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::os::ConnectionWriter::appendInt32
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
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
BOTTLE_TAG_FLOAT64
#define BOTTLE_TAG_FLOAT64
Definition: Bottle.h:27
yarp::rosmsg::shape_msgs::SolidPrimitive::CYLINDER_RADIUS
static const std::uint8_t CYLINDER_RADIUS
Definition: SolidPrimitive.h:84
yarp::rosmsg::shape_msgs::SolidPrimitive::BOX_X
static const std::uint8_t BOX_X
Definition: SolidPrimitive.h:79
yarp::rosmsg::shape_msgs::SolidPrimitive::CONE_RADIUS
static const std::uint8_t CONE_RADIUS
Definition: SolidPrimitive.h:86
yarp::rosmsg::shape_msgs::SolidPrimitive::CYLINDER_HEIGHT
static const std::uint8_t CYLINDER_HEIGHT
Definition: SolidPrimitive.h:83
yarp::rosmsg::shape_msgs::SolidPrimitive::CONE_HEIGHT
static const std::uint8_t CONE_HEIGHT
Definition: SolidPrimitive.h:85
yarp::rosmsg::shape_msgs::SolidPrimitive::BOX_Z
static const std::uint8_t BOX_Z
Definition: SolidPrimitive.h:81
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::rosmsg::shape_msgs::SolidPrimitive::typeChecksum
static constexpr const char * typeChecksum
Definition: SolidPrimitive.h:223
yarp::rosmsg::shape_msgs::SolidPrimitive::CYLINDER
static const std::uint8_t CYLINDER
Definition: SolidPrimitive.h:75
yarp::rosmsg::shape_msgs::SolidPrimitive::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: SolidPrimitive.h:208
yarp::rosmsg::shape_msgs::SolidPrimitive::type
std::uint8_t type
Definition: SolidPrimitive.h:77
yarp::os::idl::WireReader::expectInt8
std::int8_t expectInt8()
Definition: WireReader.h:87
yarp::conf::float64_t
double float64_t
Definition: numeric.h:51
yarp::os::ConnectionWriter::appendExternalBlock
virtual void appendExternalBlock(const char *data, size_t len)=0
Send a block of data to the network connection, without making a copy.
yarp::rosmsg::shape_msgs::SolidPrimitive::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: SolidPrimitive.h:187
yarp::os::ConnectionReader::expectBlock
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
yarp::rosmsg::shape_msgs::SolidPrimitive::typeText
static constexpr const char * typeText
Definition: SolidPrimitive.h:226
shape_msgs
Definition: Mesh.h:22
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