YARP
Yet Another Robot Platform
Quaternion.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 "geometry_msgs/Quaternion" msg definition:
12 // # This represents an orientation in free space in quaternion form.
13 //
14 // float64 x
15 // float64 y
16 // float64 z
17 // float64 w
18 // 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_Quaternion_h
22 #define YARP_ROSMSG_geometry_msgs_Quaternion_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:
41 
43  x(0.0),
44  y(0.0),
45  z(0.0),
46  w(0.0)
47  {
48  }
49 
50  void clear()
51  {
52  // *** x ***
53  x = 0.0;
54 
55  // *** y ***
56  y = 0.0;
57 
58  // *** z ***
59  z = 0.0;
60 
61  // *** w ***
62  w = 0.0;
63  }
64 
65  bool readBare(yarp::os::ConnectionReader& connection) override
66  {
67  // *** x ***
68  x = connection.expectFloat64();
69 
70  // *** y ***
71  y = connection.expectFloat64();
72 
73  // *** z ***
74  z = connection.expectFloat64();
75 
76  // *** w ***
77  w = connection.expectFloat64();
78 
79  return !connection.isError();
80  }
81 
82  bool readBottle(yarp::os::ConnectionReader& connection) override
83  {
84  connection.convertTextMode();
85  yarp::os::idl::WireReader reader(connection);
86  if (!reader.readListHeader(4)) {
87  return false;
88  }
89 
90  // *** x ***
91  x = reader.expectFloat64();
92 
93  // *** y ***
94  y = reader.expectFloat64();
95 
96  // *** z ***
97  z = reader.expectFloat64();
98 
99  // *** w ***
100  w = reader.expectFloat64();
101 
102  return !connection.isError();
103  }
104 
106  bool read(yarp::os::ConnectionReader& connection) override
107  {
108  return (connection.isBareMode() ? readBare(connection)
109  : readBottle(connection));
110  }
111 
112  bool writeBare(yarp::os::ConnectionWriter& connection) const override
113  {
114  // *** x ***
115  connection.appendFloat64(x);
116 
117  // *** y ***
118  connection.appendFloat64(y);
119 
120  // *** z ***
121  connection.appendFloat64(z);
122 
123  // *** w ***
124  connection.appendFloat64(w);
125 
126  return !connection.isError();
127  }
128 
129  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
130  {
131  connection.appendInt32(BOTTLE_TAG_LIST);
132  connection.appendInt32(4);
133 
134  // *** x ***
135  connection.appendInt32(BOTTLE_TAG_FLOAT64);
136  connection.appendFloat64(x);
137 
138  // *** y ***
139  connection.appendInt32(BOTTLE_TAG_FLOAT64);
140  connection.appendFloat64(y);
141 
142  // *** z ***
143  connection.appendInt32(BOTTLE_TAG_FLOAT64);
144  connection.appendFloat64(z);
145 
146  // *** w ***
147  connection.appendInt32(BOTTLE_TAG_FLOAT64);
148  connection.appendFloat64(w);
149 
150  connection.convertTextMode();
151  return !connection.isError();
152  }
153 
155  bool write(yarp::os::ConnectionWriter& connection) const override
156  {
157  return (connection.isBareMode() ? writeBare(connection)
158  : writeBottle(connection));
159  }
160 
161  // This class will serialize ROS style or YARP style depending on protocol.
162  // If you need to force a serialization style, use one of these classes:
165 
166  // The name for this message, ROS will need this
167  static constexpr const char* typeName = "geometry_msgs/Quaternion";
168 
169  // The checksum for this message, ROS will need this
170  static constexpr const char* typeChecksum = "a779879fadf0160734f906b8c19c7004";
171 
172  // The source text for this message, ROS will need this
173  static constexpr const char* typeText = "\
174 # This represents an orientation in free space in quaternion form.\n\
175 \n\
176 float64 x\n\
177 float64 y\n\
178 float64 z\n\
179 float64 w\n\
180 ";
181 
182  yarp::os::Type getType() const override
183  {
185  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
186  typ.addProperty("message_definition", yarp::os::Value(typeText));
187  return typ;
188  }
189 };
190 
191 } // namespace geometry_msgs
192 } // namespace rosmsg
193 } // namespace yarp
194 
195 #endif // YARP_ROSMSG_geometry_msgs_Quaternion_h
yarp::rosmsg::geometry_msgs::Quaternion::y
yarp::conf::float64_t y
Definition: Quaternion.h:38
yarp::rosmsg::geometry_msgs::Quaternion::getType
yarp::os::Type getType() const override
Definition: Quaternion.h:182
yarp::os::idl::WireReader::expectFloat64
yarp::conf::float64_t expectFloat64()
Definition: WireReader.h:120
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
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::geometry_msgs::Quaternion::typeText
static constexpr const char * typeText
Definition: Quaternion.h:173
yarp::os::ConnectionReader::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
Wire.h
geometry_msgs
Definition: Accel.h:22
yarp::rosmsg::geometry_msgs::Quaternion::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Quaternion.h:106
yarp::rosmsg::geometry_msgs::Quaternion::x
yarp::conf::float64_t x
Definition: Quaternion.h:37
yarp::rosmsg::geometry_msgs::Quaternion::Quaternion
Quaternion()
Definition: Quaternion.h:42
yarp::rosmsg::geometry_msgs::Quaternion
Definition: Quaternion.h:35
yarp::rosmsg::geometry_msgs::Quaternion::typeName
static constexpr const char * typeName
Definition: Quaternion.h:167
yarp::rosmsg::geometry_msgs::Quaternion::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: Quaternion.h:65
yarp::rosmsg::geometry_msgs::Quaternion::typeChecksum
static constexpr const char * typeChecksum
Definition: Quaternion.h:170
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::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::rosmsg::geometry_msgs::Quaternion::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::geometry_msgs::Quaternion > bottleStyle
Definition: Quaternion.h:164
yarp::rosmsg::geometry_msgs::Quaternion::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Quaternion.h:155
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::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::geometry_msgs::Quaternion::w
yarp::conf::float64_t w
Definition: Quaternion.h:40
yarp::rosmsg::geometry_msgs::Quaternion::clear
void clear()
Definition: Quaternion.h:50
yarp::rosmsg::geometry_msgs::Quaternion::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: Quaternion.h:112
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::rosmsg::geometry_msgs::Quaternion::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::geometry_msgs::Quaternion > rosStyle
Definition: Quaternion.h:163
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::geometry_msgs::Quaternion::z
yarp::conf::float64_t z
Definition: Quaternion.h:39
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::conf::float64_t
double float64_t
Definition: numeric.h:51
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
yarp::rosmsg::geometry_msgs::Quaternion::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: Quaternion.h:129
yarp::rosmsg::geometry_msgs::Quaternion::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: Quaternion.h:82
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