YARP
Yet Another Robot Platform
Pose2D.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/Pose2D" msg definition:
9 // # This expresses a position and orientation on a 2D manifold.
10 //
11 // float64 x
12 // float64 y
13 // float64 theta// Instances of this class can be read and written with YARP ports,
14 // using a ROS-compatible format.
15 
16 #ifndef YARP_ROSMSG_geometry_msgs_Pose2D_h
17 #define YARP_ROSMSG_geometry_msgs_Pose2D_h
18 
19 #include <yarp/os/Wire.h>
20 #include <yarp/os/Type.h>
22 #include <string>
23 #include <vector>
24 
25 namespace yarp {
26 namespace rosmsg {
27 namespace geometry_msgs {
28 
30 {
31 public:
35 
36  Pose2D() :
37  x(0.0),
38  y(0.0),
39  theta(0.0)
40  {
41  }
42 
43  void clear()
44  {
45  // *** x ***
46  x = 0.0;
47 
48  // *** y ***
49  y = 0.0;
50 
51  // *** theta ***
52  theta = 0.0;
53  }
54 
55  bool readBare(yarp::os::ConnectionReader& connection) override
56  {
57  // *** x ***
58  x = connection.expectFloat64();
59 
60  // *** y ***
61  y = connection.expectFloat64();
62 
63  // *** theta ***
64  theta = connection.expectFloat64();
65 
66  return !connection.isError();
67  }
68 
69  bool readBottle(yarp::os::ConnectionReader& connection) override
70  {
71  connection.convertTextMode();
72  yarp::os::idl::WireReader reader(connection);
73  if (!reader.readListHeader(3)) {
74  return false;
75  }
76 
77  // *** x ***
78  x = reader.expectFloat64();
79 
80  // *** y ***
81  y = reader.expectFloat64();
82 
83  // *** theta ***
84  theta = reader.expectFloat64();
85 
86  return !connection.isError();
87  }
88 
90  bool read(yarp::os::ConnectionReader& connection) override
91  {
92  return (connection.isBareMode() ? readBare(connection)
93  : readBottle(connection));
94  }
95 
96  bool writeBare(yarp::os::ConnectionWriter& connection) const override
97  {
98  // *** x ***
99  connection.appendFloat64(x);
100 
101  // *** y ***
102  connection.appendFloat64(y);
103 
104  // *** theta ***
105  connection.appendFloat64(theta);
106 
107  return !connection.isError();
108  }
109 
110  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
111  {
112  connection.appendInt32(BOTTLE_TAG_LIST);
113  connection.appendInt32(3);
114 
115  // *** x ***
116  connection.appendInt32(BOTTLE_TAG_FLOAT64);
117  connection.appendFloat64(x);
118 
119  // *** y ***
120  connection.appendInt32(BOTTLE_TAG_FLOAT64);
121  connection.appendFloat64(y);
122 
123  // *** theta ***
124  connection.appendInt32(BOTTLE_TAG_FLOAT64);
125  connection.appendFloat64(theta);
126 
127  connection.convertTextMode();
128  return !connection.isError();
129  }
130 
132  bool write(yarp::os::ConnectionWriter& connection) const override
133  {
134  return (connection.isBareMode() ? writeBare(connection)
135  : writeBottle(connection));
136  }
137 
138  // This class will serialize ROS style or YARP style depending on protocol.
139  // If you need to force a serialization style, use one of these classes:
142 
143  // The name for this message, ROS will need this
144  static constexpr const char* typeName = "geometry_msgs/Pose2D";
145 
146  // The checksum for this message, ROS will need this
147  static constexpr const char* typeChecksum = "938fa65709584ad8e77d238529be13b8";
148 
149  // The source text for this message, ROS will need this
150  static constexpr const char* typeText = "\
151 # This expresses a position and orientation on a 2D manifold.\n\
152 \n\
153 float64 x\n\
154 float64 y\n\
155 float64 theta\n\
156 ";
157 
158  yarp::os::Type getType() const override
159  {
161  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
162  typ.addProperty("message_definition", yarp::os::Value(typeText));
163  return typ;
164  }
165 };
166 
167 } // namespace geometry_msgs
168 } // namespace rosmsg
169 } // namespace yarp
170 
171 #endif // YARP_ROSMSG_geometry_msgs_Pose2D_h
#define BOTTLE_TAG_FLOAT64
Definition: Bottle.h:25
#define BOTTLE_TAG_LIST
Definition: Bottle.h:28
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 bool isError() const =0
virtual yarp::conf::float64_t expectFloat64()=0
Read a 64-bit floating point number 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 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.
virtual void appendFloat64(yarp::conf::float64_t data)=0
Send a representation of a 64-bit floating point number 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::float64_t expectFloat64()
Definition: WireReader.h:113
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Pose2D.h:132
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Pose2D.h:90
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: Pose2D.h:96
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: Pose2D.h:110
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: Pose2D.h:55
static constexpr const char * typeName
Definition: Pose2D.h:144
yarp::conf::float64_t x
Definition: Pose2D.h:32
yarp::conf::float64_t y
Definition: Pose2D.h:33
yarp::conf::float64_t theta
Definition: Pose2D.h:34
yarp::os::idl::BottleStyle< yarp::rosmsg::geometry_msgs::Pose2D > bottleStyle
Definition: Pose2D.h:141
yarp::os::Type getType() const override
Definition: Pose2D.h:158
yarp::os::idl::BareStyle< yarp::rosmsg::geometry_msgs::Pose2D > rosStyle
Definition: Pose2D.h:140
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: Pose2D.h:69
static constexpr const char * typeChecksum
Definition: Pose2D.h:147
static constexpr const char * typeText
Definition: Pose2D.h:150
double float64_t
Definition: numeric.h:77
The main, catch-all namespace for YARP.
Definition: dirs.h:16