YARP
Yet Another Robot Platform
TF2Error.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 "tf2_msgs/TF2Error" msg definition:
12 // uint8 NO_ERROR = 0
13 // uint8 LOOKUP_ERROR = 1
14 // uint8 CONNECTIVITY_ERROR = 2
15 // uint8 EXTRAPOLATION_ERROR = 3
16 // uint8 INVALID_ARGUMENT_ERROR = 4
17 // uint8 TIMEOUT_ERROR = 5
18 // uint8 TRANSFORM_ERROR = 6
19 //
20 // uint8 error
21 // string error_string
22 // Instances of this class can be read and written with YARP ports,
23 // using a ROS-compatible format.
24 
25 #ifndef YARP_ROSMSG_tf2_msgs_TF2Error_h
26 #define YARP_ROSMSG_tf2_msgs_TF2Error_h
27 
28 #include <yarp/os/Wire.h>
29 #include <yarp/os/Type.h>
30 #include <yarp/os/idl/WireTypes.h>
31 #include <string>
32 #include <vector>
33 
34 namespace yarp {
35 namespace rosmsg {
36 namespace tf2_msgs {
37 
39 {
40 public:
41  static const std::uint8_t NO_ERROR = 0;
42  static const std::uint8_t LOOKUP_ERROR = 1;
43  static const std::uint8_t CONNECTIVITY_ERROR = 2;
44  static const std::uint8_t EXTRAPOLATION_ERROR = 3;
45  static const std::uint8_t INVALID_ARGUMENT_ERROR = 4;
46  static const std::uint8_t TIMEOUT_ERROR = 5;
47  static const std::uint8_t TRANSFORM_ERROR = 6;
48  std::uint8_t error;
49  std::string error_string;
50 
52  error(0),
53  error_string("")
54  {
55  }
56 
57  void clear()
58  {
59  // *** NO_ERROR ***
60 
61  // *** LOOKUP_ERROR ***
62 
63  // *** CONNECTIVITY_ERROR ***
64 
65  // *** EXTRAPOLATION_ERROR ***
66 
67  // *** INVALID_ARGUMENT_ERROR ***
68 
69  // *** TIMEOUT_ERROR ***
70 
71  // *** TRANSFORM_ERROR ***
72 
73  // *** error ***
74  error = 0;
75 
76  // *** error_string ***
77  error_string = "";
78  }
79 
80  bool readBare(yarp::os::ConnectionReader& connection) override
81  {
82  // *** error ***
83  error = connection.expectInt8();
84 
85  // *** error_string ***
86  int len = connection.expectInt32();
87  error_string.resize(len);
88  if (!connection.expectBlock((char*)error_string.c_str(), len)) {
89  return false;
90  }
91 
92  return !connection.isError();
93  }
94 
95  bool readBottle(yarp::os::ConnectionReader& connection) override
96  {
97  connection.convertTextMode();
98  yarp::os::idl::WireReader reader(connection);
99  if (!reader.readListHeader(9)) {
100  return false;
101  }
102 
103  // *** error ***
104  error = reader.expectInt8();
105 
106  // *** error_string ***
107  if (!reader.readString(error_string)) {
108  return false;
109  }
110 
111  return !connection.isError();
112  }
113 
115  bool read(yarp::os::ConnectionReader& connection) override
116  {
117  return (connection.isBareMode() ? readBare(connection)
118  : readBottle(connection));
119  }
120 
121  bool writeBare(yarp::os::ConnectionWriter& connection) const override
122  {
123  // *** error ***
124  connection.appendInt8(error);
125 
126  // *** error_string ***
127  connection.appendInt32(error_string.length());
128  connection.appendExternalBlock((char*)error_string.c_str(), error_string.length());
129 
130  return !connection.isError();
131  }
132 
133  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
134  {
135  connection.appendInt32(BOTTLE_TAG_LIST);
136  connection.appendInt32(9);
137 
138  // *** error ***
139  connection.appendInt32(BOTTLE_TAG_INT8);
140  connection.appendInt8(error);
141 
142  // *** error_string ***
143  connection.appendInt32(BOTTLE_TAG_STRING);
144  connection.appendInt32(error_string.length());
145  connection.appendExternalBlock((char*)error_string.c_str(), error_string.length());
146 
147  connection.convertTextMode();
148  return !connection.isError();
149  }
150 
152  bool write(yarp::os::ConnectionWriter& connection) const override
153  {
154  return (connection.isBareMode() ? writeBare(connection)
155  : writeBottle(connection));
156  }
157 
158  // This class will serialize ROS style or YARP style depending on protocol.
159  // If you need to force a serialization style, use one of these classes:
162 
163  // The name for this message, ROS will need this
164  static constexpr const char* typeName = "tf2_msgs/TF2Error";
165 
166  // The checksum for this message, ROS will need this
167  static constexpr const char* typeChecksum = "bc6848fd6fd750c92e38575618a4917d";
168 
169  // The source text for this message, ROS will need this
170  static constexpr const char* typeText = "\
171 uint8 NO_ERROR = 0\n\
172 uint8 LOOKUP_ERROR = 1\n\
173 uint8 CONNECTIVITY_ERROR = 2\n\
174 uint8 EXTRAPOLATION_ERROR = 3\n\
175 uint8 INVALID_ARGUMENT_ERROR = 4\n\
176 uint8 TIMEOUT_ERROR = 5\n\
177 uint8 TRANSFORM_ERROR = 6\n\
178 \n\
179 uint8 error\n\
180 string error_string\n\
181 ";
182 
183  yarp::os::Type getType() const override
184  {
186  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
187  typ.addProperty("message_definition", yarp::os::Value(typeText));
188  return typ;
189  }
190 };
191 
192 } // namespace tf2_msgs
193 } // namespace rosmsg
194 } // namespace yarp
195 
196 #endif // YARP_ROSMSG_tf2_msgs_TF2Error_h
yarp::rosmsg::tf2_msgs::TF2Error::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: TF2Error.h:80
yarp::os::idl::WireReader::readString
bool readString(std::string &str, bool *is_vocab=nullptr)
Definition: WireReader.cpp:339
yarp::rosmsg::tf2_msgs::TF2Error::INVALID_ARGUMENT_ERROR
static const std::uint8_t INVALID_ARGUMENT_ERROR
Definition: TF2Error.h:45
yarp::rosmsg::tf2_msgs::TF2Error::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: TF2Error.h:133
yarp::rosmsg::tf2_msgs::TF2Error::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: TF2Error.h:115
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
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::tf2_msgs::TF2Error::TIMEOUT_ERROR
static const std::uint8_t TIMEOUT_ERROR
Definition: TF2Error.h:46
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::tf2_msgs::TF2Error::getType
yarp::os::Type getType() const override
Definition: TF2Error.h:183
BOTTLE_TAG_INT8
#define BOTTLE_TAG_INT8
Definition: Bottle.h:21
yarp::rosmsg::tf2_msgs::TF2Error::CONNECTIVITY_ERROR
static const std::uint8_t CONNECTIVITY_ERROR
Definition: TF2Error.h:43
yarp::os::ConnectionReader::expectInt8
virtual std::int8_t expectInt8()=0
Read a 8-bit integer from the network connection.
yarp::rosmsg::tf2_msgs::TF2Error::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::tf2_msgs::TF2Error > bottleStyle
Definition: TF2Error.h:161
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
yarp::os::Type::byName
static Type byName(const char *name)
Definition: Type.cpp:174
yarp::rosmsg::tf2_msgs::TF2Error::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: TF2Error.h:95
yarp::os::ConnectionReader::expectInt32
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
yarp::rosmsg::tf2_msgs::TF2Error
Definition: TF2Error.h:39
yarp::rosmsg::tf2_msgs::TF2Error::LOOKUP_ERROR
static const std::uint8_t LOOKUP_ERROR
Definition: TF2Error.h:42
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::rosmsg::tf2_msgs::TF2Error::error
std::uint8_t error
Definition: TF2Error.h:48
yarp::os::ConnectionReader::isError
virtual bool isError() const =0
yarp::rosmsg::tf2_msgs::TF2Error::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::tf2_msgs::TF2Error > rosStyle
Definition: TF2Error.h:160
yarp::rosmsg::tf2_msgs::TF2Error::typeText
static constexpr const char * typeText
Definition: TF2Error.h:170
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::tf2_msgs::TF2Error::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: TF2Error.h:121
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::tf2_msgs::TF2Error::error_string
std::string error_string
Definition: TF2Error.h:49
yarp::rosmsg::tf2_msgs::TF2Error::NO_ERROR
static const std::uint8_t NO_ERROR
Definition: TF2Error.h:41
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.
tf2_msgs
Definition: FrameGraph.h:22
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::rosmsg::tf2_msgs::TF2Error::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: TF2Error.h:152
yarp::rosmsg::tf2_msgs::TF2Error::clear
void clear()
Definition: TF2Error.h:57
yarp::os::idl::BareStyle
Definition: BareStyle.h:22
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::rosmsg::tf2_msgs::TF2Error::typeChecksum
static constexpr const char * typeChecksum
Definition: TF2Error.h:167
yarp::rosmsg::tf2_msgs::TF2Error::typeName
static constexpr const char * typeName
Definition: TF2Error.h:164
yarp::os::idl::WireReader::expectInt8
std::int8_t expectInt8()
Definition: WireReader.h:87
yarp::rosmsg::tf2_msgs::TF2Error::EXTRAPOLATION_ERROR
static const std::uint8_t EXTRAPOLATION_ERROR
Definition: TF2Error.h:44
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::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
yarp::rosmsg::tf2_msgs::TF2Error::TRANSFORM_ERROR
static const std::uint8_t TRANSFORM_ERROR
Definition: TF2Error.h:47
yarp::rosmsg::tf2_msgs::TF2Error::TF2Error
TF2Error()
Definition: TF2Error.h:51
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