YARP
Yet Another Robot Platform
PointField.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 "sensor_msgs/PointField" msg definition:
12 // # This message holds the description of one point entry in the
13 // # PointCloud2 message format.
14 // uint8 INT8 = 1
15 // uint8 UINT8 = 2
16 // uint8 INT16 = 3
17 // uint8 UINT16 = 4
18 // uint8 INT32 = 5
19 // uint8 UINT32 = 6
20 // uint8 FLOAT32 = 7
21 // uint8 FLOAT64 = 8
22 //
23 // string name # Name of field
24 // uint32 offset # Offset from start of point struct
25 // uint8 datatype # Datatype enumeration, see above
26 // uint32 count # How many elements in the field
27 // Instances of this class can be read and written with YARP ports,
28 // using a ROS-compatible format.
29 
30 #ifndef YARP_ROSMSG_sensor_msgs_PointField_h
31 #define YARP_ROSMSG_sensor_msgs_PointField_h
32 
33 #include <yarp/os/Wire.h>
34 #include <yarp/os/Type.h>
35 #include <yarp/os/idl/WireTypes.h>
36 #include <string>
37 #include <vector>
38 
39 namespace yarp {
40 namespace rosmsg {
41 namespace sensor_msgs {
42 
44 {
45 public:
46  static const std::uint8_t INT8 = 1;
47  static const std::uint8_t UINT8 = 2;
48  static const std::uint8_t INT16 = 3;
49  static const std::uint8_t UINT16 = 4;
50  static const std::uint8_t INT32 = 5;
51  static const std::uint8_t UINT32 = 6;
52  static const std::uint8_t FLOAT32 = 7;
53  static const std::uint8_t FLOAT64 = 8;
54  std::string name;
55  std::uint32_t offset;
56  std::uint8_t datatype;
57  std::uint32_t count;
58 
60  name(""),
61  offset(0),
62  datatype(0),
63  count(0)
64  {
65  }
66 
67  void clear()
68  {
69  // *** INT8 ***
70 
71  // *** UINT8 ***
72 
73  // *** INT16 ***
74 
75  // *** UINT16 ***
76 
77  // *** INT32 ***
78 
79  // *** UINT32 ***
80 
81  // *** FLOAT32 ***
82 
83  // *** FLOAT64 ***
84 
85  // *** name ***
86  name = "";
87 
88  // *** offset ***
89  offset = 0;
90 
91  // *** datatype ***
92  datatype = 0;
93 
94  // *** count ***
95  count = 0;
96  }
97 
98  bool readBare(yarp::os::ConnectionReader& connection) override
99  {
100  // *** name ***
101  int len = connection.expectInt32();
102  name.resize(len);
103  if (!connection.expectBlock((char*)name.c_str(), len)) {
104  return false;
105  }
106 
107  // *** offset ***
108  offset = connection.expectInt32();
109 
110  // *** datatype ***
111  datatype = connection.expectInt8();
112 
113  // *** count ***
114  count = connection.expectInt32();
115 
116  return !connection.isError();
117  }
118 
119  bool readBottle(yarp::os::ConnectionReader& connection) override
120  {
121  connection.convertTextMode();
122  yarp::os::idl::WireReader reader(connection);
123  if (!reader.readListHeader(12)) {
124  return false;
125  }
126 
127  // *** name ***
128  if (!reader.readString(name)) {
129  return false;
130  }
131 
132  // *** offset ***
133  offset = reader.expectInt32();
134 
135  // *** datatype ***
136  datatype = reader.expectInt8();
137 
138  // *** count ***
139  count = reader.expectInt32();
140 
141  return !connection.isError();
142  }
143 
145  bool read(yarp::os::ConnectionReader& connection) override
146  {
147  return (connection.isBareMode() ? readBare(connection)
148  : readBottle(connection));
149  }
150 
151  bool writeBare(yarp::os::ConnectionWriter& connection) const override
152  {
153  // *** name ***
154  connection.appendInt32(name.length());
155  connection.appendExternalBlock((char*)name.c_str(), name.length());
156 
157  // *** offset ***
158  connection.appendInt32(offset);
159 
160  // *** datatype ***
161  connection.appendInt8(datatype);
162 
163  // *** count ***
164  connection.appendInt32(count);
165 
166  return !connection.isError();
167  }
168 
169  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
170  {
171  connection.appendInt32(BOTTLE_TAG_LIST);
172  connection.appendInt32(12);
173 
174  // *** name ***
175  connection.appendInt32(BOTTLE_TAG_STRING);
176  connection.appendInt32(name.length());
177  connection.appendExternalBlock((char*)name.c_str(), name.length());
178 
179  // *** offset ***
180  connection.appendInt32(BOTTLE_TAG_INT32);
181  connection.appendInt32(offset);
182 
183  // *** datatype ***
184  connection.appendInt32(BOTTLE_TAG_INT8);
185  connection.appendInt8(datatype);
186 
187  // *** count ***
188  connection.appendInt32(BOTTLE_TAG_INT32);
189  connection.appendInt32(count);
190 
191  connection.convertTextMode();
192  return !connection.isError();
193  }
194 
196  bool write(yarp::os::ConnectionWriter& connection) const override
197  {
198  return (connection.isBareMode() ? writeBare(connection)
199  : writeBottle(connection));
200  }
201 
202  // This class will serialize ROS style or YARP style depending on protocol.
203  // If you need to force a serialization style, use one of these classes:
206 
207  // The name for this message, ROS will need this
208  static constexpr const char* typeName = "sensor_msgs/PointField";
209 
210  // The checksum for this message, ROS will need this
211  static constexpr const char* typeChecksum = "268eacb2962780ceac86cbd17e328150";
212 
213  // The source text for this message, ROS will need this
214  static constexpr const char* typeText = "\
215 # This message holds the description of one point entry in the\n\
216 # PointCloud2 message format.\n\
217 uint8 INT8 = 1\n\
218 uint8 UINT8 = 2\n\
219 uint8 INT16 = 3\n\
220 uint8 UINT16 = 4\n\
221 uint8 INT32 = 5\n\
222 uint8 UINT32 = 6\n\
223 uint8 FLOAT32 = 7\n\
224 uint8 FLOAT64 = 8\n\
225 \n\
226 string name # Name of field\n\
227 uint32 offset # Offset from start of point struct\n\
228 uint8 datatype # Datatype enumeration, see above\n\
229 uint32 count # How many elements in the field\n\
230 ";
231 
232  yarp::os::Type getType() const override
233  {
235  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
236  typ.addProperty("message_definition", yarp::os::Value(typeText));
237  return typ;
238  }
239 };
240 
241 } // namespace sensor_msgs
242 } // namespace rosmsg
243 } // namespace yarp
244 
245 #endif // YARP_ROSMSG_sensor_msgs_PointField_h
yarp::rosmsg::sensor_msgs::PointField::FLOAT32
static const std::uint8_t FLOAT32
Definition: PointField.h:52
yarp::rosmsg::sensor_msgs::PointField::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: PointField.h:119
yarp::os::idl::WireReader::readString
bool readString(std::string &str, bool *is_vocab=nullptr)
Definition: WireReader.cpp:339
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::rosmsg::sensor_msgs::PointField::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: PointField.h:151
yarp::os::idl::BottleStyle
Definition: BottleStyle.h:22
yarp::os::Type
Definition: Type.h:24
yarp::rosmsg::sensor_msgs::PointField::INT8
static const std::uint8_t INT8
Definition: PointField.h:46
yarp::os::idl::WirePortable::read
virtual bool read(yarp::os::idl::WireReader &reader)
Definition: WirePortable.cpp:14
yarp::rosmsg::sensor_msgs::PointField::PointField
PointField()
Definition: PointField.h:59
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.
BOTTLE_TAG_STRING
#define BOTTLE_TAG_STRING
Definition: Bottle.h:28
Wire.h
yarp::rosmsg::sensor_msgs::PointField::name
std::string name
Definition: PointField.h:54
yarp::rosmsg::sensor_msgs::PointField::FLOAT64
static const std::uint8_t FLOAT64
Definition: PointField.h:53
yarp::rosmsg::sensor_msgs::PointField::getType
yarp::os::Type getType() const override
Definition: PointField.h:232
yarp::rosmsg::sensor_msgs::PointField::UINT32
static const std::uint8_t UINT32
Definition: PointField.h:51
BOTTLE_TAG_INT8
#define BOTTLE_TAG_INT8
Definition: Bottle.h:21
yarp::os::ConnectionReader::expectInt8
virtual std::int8_t expectInt8()=0
Read a 8-bit integer from the network connection.
BOTTLE_TAG_INT32
#define BOTTLE_TAG_INT32
Definition: Bottle.h:23
yarp::rosmsg::sensor_msgs::PointField
Definition: PointField.h:44
yarp::rosmsg::sensor_msgs::PointField::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: PointField.h:145
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
yarp::rosmsg::sensor_msgs::PointField::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: PointField.h:169
yarp::os::Type::byName
static Type byName(const char *name)
Definition: Type.cpp:174
yarp::rosmsg::sensor_msgs::PointField::clear
void clear()
Definition: PointField.h:67
yarp::os::ConnectionReader::expectInt32
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
yarp::os::Type::addProperty
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:137
Type.h
yarp::rosmsg::sensor_msgs::PointField::UINT8
static const std::uint8_t UINT8
Definition: PointField.h:47
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::rosmsg::sensor_msgs::PointField::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::PointField > rosStyle
Definition: PointField.h:204
yarp::os::ConnectionReader::isError
virtual bool isError() const =0
yarp::rosmsg::sensor_msgs::PointField::UINT16
static const std::uint8_t UINT16
Definition: PointField.h:49
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::sensor_msgs::PointField::offset
std::uint32_t offset
Definition: PointField.h:55
yarp::rosmsg::sensor_msgs::PointField::typeText
static constexpr const char * typeText
Definition: PointField.h:214
yarp::rosmsg::sensor_msgs::PointField::INT32
static const std::uint8_t INT32
Definition: PointField.h:50
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::rosmsg::sensor_msgs::PointField::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::PointField > bottleStyle
Definition: PointField.h:205
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::rosmsg::sensor_msgs::PointField::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: PointField.h:98
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
yarp::rosmsg::sensor_msgs::PointField::typeChecksum
static constexpr const char * typeChecksum
Definition: PointField.h:211
yarp::os::idl::WireReader::expectInt32
std::int32_t expectInt32()
Definition: WireReader.h:99
yarp::rosmsg::sensor_msgs::PointField::datatype
std::uint8_t datatype
Definition: PointField.h:56
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::os::idl::WireReader::expectInt8
std::int8_t expectInt8()
Definition: WireReader.h:87
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::os::ConnectionReader::expectBlock
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
yarp::rosmsg::sensor_msgs::PointField::INT16
static const std::uint8_t INT16
Definition: PointField.h:48
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
sensor_msgs
Definition: BatteryState.h:22
yarp::rosmsg::sensor_msgs::PointField::count
std::uint32_t count
Definition: PointField.h:57
yarp::rosmsg::sensor_msgs::PointField::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: PointField.h:196
yarp::rosmsg::sensor_msgs::PointField::typeName
static constexpr const char * typeName
Definition: PointField.h:208
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