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