YARP
Yet Another Robot Platform
Point32.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 "geometry_msgs/Point32" msg definition:
9 // # This contains the position of a point in free space(with 32 bits of precision).
10 // # It is recommeded to use Point wherever possible instead of Point32.
11 // #
12 // # This recommendation is to promote interoperability.
13 // #
14 // # This message is designed to take up less space when sending
15 // # lots of points at once, as in the case of a PointCloud.
16 //
17 // float32 x
18 // float32 y
19 // float32 z// Instances of this class can be read and written with YARP ports,
20 // using a ROS-compatible format.
21 
22 #ifndef YARP_ROSMSG_geometry_msgs_Point32_h
23 #define YARP_ROSMSG_geometry_msgs_Point32_h
24 
25 #include <yarp/os/Wire.h>
26 #include <yarp/os/Type.h>
27 #include <yarp/os/idl/WireTypes.h>
28 #include <string>
29 #include <vector>
30 
31 namespace yarp {
32 namespace rosmsg {
33 namespace geometry_msgs {
34 
36 {
37 public:
41 
42  Point32() :
43  x(0.0f),
44  y(0.0f),
45  z(0.0f)
46  {
47  }
48 
49  void clear()
50  {
51  // *** x ***
52  x = 0.0f;
53 
54  // *** y ***
55  y = 0.0f;
56 
57  // *** z ***
58  z = 0.0f;
59  }
60 
61  bool readBare(yarp::os::ConnectionReader& connection) override
62  {
63  // *** x ***
64  x = connection.expectFloat32();
65 
66  // *** y ***
67  y = connection.expectFloat32();
68 
69  // *** z ***
70  z = connection.expectFloat32();
71 
72  return !connection.isError();
73  }
74 
75  bool readBottle(yarp::os::ConnectionReader& connection) override
76  {
77  connection.convertTextMode();
78  yarp::os::idl::WireReader reader(connection);
79  if (!reader.readListHeader(3)) {
80  return false;
81  }
82 
83  // *** x ***
84  x = reader.expectFloat32();
85 
86  // *** y ***
87  y = reader.expectFloat32();
88 
89  // *** z ***
90  z = reader.expectFloat32();
91 
92  return !connection.isError();
93  }
94 
96  bool read(yarp::os::ConnectionReader& connection) override
97  {
98  return (connection.isBareMode() ? readBare(connection)
99  : readBottle(connection));
100  }
101 
102  bool writeBare(yarp::os::ConnectionWriter& connection) const override
103  {
104  // *** x ***
105  connection.appendFloat32(x);
106 
107  // *** y ***
108  connection.appendFloat32(y);
109 
110  // *** z ***
111  connection.appendFloat32(z);
112 
113  return !connection.isError();
114  }
115 
116  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
117  {
118  connection.appendInt32(BOTTLE_TAG_LIST);
119  connection.appendInt32(3);
120 
121  // *** x ***
122  connection.appendInt32(BOTTLE_TAG_FLOAT32);
123  connection.appendFloat32(x);
124 
125  // *** y ***
126  connection.appendInt32(BOTTLE_TAG_FLOAT32);
127  connection.appendFloat32(y);
128 
129  // *** z ***
130  connection.appendInt32(BOTTLE_TAG_FLOAT32);
131  connection.appendFloat32(z);
132 
133  connection.convertTextMode();
134  return !connection.isError();
135  }
136 
138  bool write(yarp::os::ConnectionWriter& connection) const override
139  {
140  return (connection.isBareMode() ? writeBare(connection)
141  : writeBottle(connection));
142  }
143 
144  // This class will serialize ROS style or YARP style depending on protocol.
145  // If you need to force a serialization style, use one of these classes:
148 
149  // The name for this message, ROS will need this
150  static constexpr const char* typeName = "geometry_msgs/Point32";
151 
152  // The checksum for this message, ROS will need this
153  static constexpr const char* typeChecksum = "cc153912f1453b708d221682bc23d9ac";
154 
155  // The source text for this message, ROS will need this
156  static constexpr const char* typeText = "\
157 # This contains the position of a point in free space(with 32 bits of precision).\n\
158 # It is recommeded to use Point wherever possible instead of Point32. \n\
159 # \n\
160 # This recommendation is to promote interoperability. \n\
161 #\n\
162 # This message is designed to take up less space when sending\n\
163 # lots of points at once, as in the case of a PointCloud. \n\
164 \n\
165 float32 x\n\
166 float32 y\n\
167 float32 z\n\
168 ";
169 
170  yarp::os::Type getType() const override
171  {
173  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
174  typ.addProperty("message_definition", yarp::os::Value(typeText));
175  return typ;
176  }
177 };
178 
179 } // namespace geometry_msgs
180 } // namespace rosmsg
181 } // namespace yarp
182 
183 #endif // YARP_ROSMSG_geometry_msgs_Point32_h
#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 isBareMode() const =0
Check if the connection is bare mode.
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 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
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: Point32.h:138
yarp::conf::float32_t x
Definition: Point32.h:38
yarp::os::Type getType() const override
Definition: Point32.h:170
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: Point32.h:61
yarp::os::idl::BottleStyle< yarp::rosmsg::geometry_msgs::Point32 > bottleStyle
Definition: Point32.h:147
yarp::os::idl::BareStyle< yarp::rosmsg::geometry_msgs::Point32 > rosStyle
Definition: Point32.h:146
static constexpr const char * typeName
Definition: Point32.h:150
yarp::conf::float32_t z
Definition: Point32.h:40
static constexpr const char * typeChecksum
Definition: Point32.h:153
static constexpr const char * typeText
Definition: Point32.h:156
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: Point32.h:116
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: Point32.h:102
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Point32.h:96
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: Point32.h:75
yarp::conf::float32_t y
Definition: Point32.h:39
float float32_t
Definition: numeric.h:76
The main, catch-all namespace for YARP.
Definition: dirs.h:16