YARP
Yet Another Robot Platform
Vector3.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/Vector3" msg definition:
9 // # This represents a vector in free space.
10 // # It is only meant to represent a direction. Therefore, it does not
11 // # make sense to apply a translation to it (e.g., when applying a
12 // # generic rigid transformation to a Vector3, tf2 will only apply the
13 // # rotation). If you want your data to be translatable too, use the
14 // # geometry_msgs/Point message instead.
15 //
16 // float64 x
17 // float64 y
18 // float64 z// Instances of this class can be read and written with YARP ports,
19 // using a ROS-compatible format.
20 
21 #ifndef YARP_ROSMSG_geometry_msgs_Vector3_h
22 #define YARP_ROSMSG_geometry_msgs_Vector3_h
23 
24 #include <yarp/os/Wire.h>
25 #include <yarp/os/Type.h>
26 #include <yarp/os/idl/WireTypes.h>
27 #include <string>
28 #include <vector>
29 
30 namespace yarp {
31 namespace rosmsg {
32 namespace geometry_msgs {
33 
35 {
36 public:
40 
41  Vector3() :
42  x(0.0),
43  y(0.0),
44  z(0.0)
45  {
46  }
47 
48  void clear()
49  {
50  // *** x ***
51  x = 0.0;
52 
53  // *** y ***
54  y = 0.0;
55 
56  // *** z ***
57  z = 0.0;
58  }
59 
60  bool readBare(yarp::os::ConnectionReader& connection) override
61  {
62  // *** x ***
63  x = connection.expectFloat64();
64 
65  // *** y ***
66  y = connection.expectFloat64();
67 
68  // *** z ***
69  z = connection.expectFloat64();
70 
71  return !connection.isError();
72  }
73 
74  bool readBottle(yarp::os::ConnectionReader& connection) override
75  {
76  connection.convertTextMode();
77  yarp::os::idl::WireReader reader(connection);
78  if (!reader.readListHeader(3)) {
79  return false;
80  }
81 
82  // *** x ***
83  x = reader.expectFloat64();
84 
85  // *** y ***
86  y = reader.expectFloat64();
87 
88  // *** z ***
89  z = reader.expectFloat64();
90 
91  return !connection.isError();
92  }
93 
95  bool read(yarp::os::ConnectionReader& connection) override
96  {
97  return (connection.isBareMode() ? readBare(connection)
98  : readBottle(connection));
99  }
100 
101  bool writeBare(yarp::os::ConnectionWriter& connection) const override
102  {
103  // *** x ***
104  connection.appendFloat64(x);
105 
106  // *** y ***
107  connection.appendFloat64(y);
108 
109  // *** z ***
110  connection.appendFloat64(z);
111 
112  return !connection.isError();
113  }
114 
115  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
116  {
117  connection.appendInt32(BOTTLE_TAG_LIST);
118  connection.appendInt32(3);
119 
120  // *** x ***
121  connection.appendInt32(BOTTLE_TAG_FLOAT64);
122  connection.appendFloat64(x);
123 
124  // *** y ***
125  connection.appendInt32(BOTTLE_TAG_FLOAT64);
126  connection.appendFloat64(y);
127 
128  // *** z ***
129  connection.appendInt32(BOTTLE_TAG_FLOAT64);
130  connection.appendFloat64(z);
131 
132  connection.convertTextMode();
133  return !connection.isError();
134  }
135 
137  bool write(yarp::os::ConnectionWriter& connection) const override
138  {
139  return (connection.isBareMode() ? writeBare(connection)
140  : writeBottle(connection));
141  }
142 
143  // This class will serialize ROS style or YARP style depending on protocol.
144  // If you need to force a serialization style, use one of these classes:
147 
148  // The name for this message, ROS will need this
149  static constexpr const char* typeName = "geometry_msgs/Vector3";
150 
151  // The checksum for this message, ROS will need this
152  static constexpr const char* typeChecksum = "4a842b65f413084dc2b10fb484ea7f17";
153 
154  // The source text for this message, ROS will need this
155  static constexpr const char* typeText = "\
156 # This represents a vector in free space. \n\
157 # It is only meant to represent a direction. Therefore, it does not\n\
158 # make sense to apply a translation to it (e.g., when applying a \n\
159 # generic rigid transformation to a Vector3, tf2 will only apply the\n\
160 # rotation). If you want your data to be translatable too, use the\n\
161 # geometry_msgs/Point message instead.\n\
162 \n\
163 float64 x\n\
164 float64 y\n\
165 float64 z\n\
166 ";
167 
168  yarp::os::Type getType() const override
169  {
171  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
172  typ.addProperty("message_definition", yarp::os::Value(typeText));
173  return typ;
174  }
175 };
176 
177 } // namespace geometry_msgs
178 } // namespace rosmsg
179 } // namespace yarp
180 
181 #endif // YARP_ROSMSG_geometry_msgs_Vector3_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
yarp::conf::float64_t y
Definition: Vector3.h:38
yarp::os::idl::BareStyle< yarp::rosmsg::geometry_msgs::Vector3 > rosStyle
Definition: Vector3.h:145
yarp::conf::float64_t z
Definition: Vector3.h:39
static constexpr const char * typeText
Definition: Vector3.h:155
yarp::os::Type getType() const override
Definition: Vector3.h:168
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Vector3.h:95
static constexpr const char * typeChecksum
Definition: Vector3.h:152
static constexpr const char * typeName
Definition: Vector3.h:149
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: Vector3.h:115
yarp::os::idl::BottleStyle< yarp::rosmsg::geometry_msgs::Vector3 > bottleStyle
Definition: Vector3.h:146
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Vector3.h:137
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: Vector3.h:101
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: Vector3.h:60
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: Vector3.h:74
yarp::conf::float64_t x
Definition: Vector3.h:37
double float64_t
Definition: numeric.h:77
The main, catch-all namespace for YARP.
Definition: dirs.h:16