YARP
Yet Another Robot Platform
PoseWithCovariance.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/PoseWithCovariance" msg definition:
9// # This represents a pose in free space with uncertainty.
10//
11// Pose pose
12//
13// # Row-major representation of the 6x6 covariance matrix
14// # The orientation parameters use a fixed-axis representation.
15// # In order, the parameters are:
16// # (x, y, z, rotation about X axis, rotation about Y axis, rotation about Z axis)
17// float64[36] covariance
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_PoseWithCovariance_h
22#define YARP_ROSMSG_geometry_msgs_PoseWithCovariance_h
23
24#include <yarp/os/Wire.h>
25#include <yarp/os/Type.h>
27#include <string>
28#include <vector>
30
31namespace yarp {
32namespace rosmsg {
33namespace geometry_msgs {
34
36{
37public:
39 std::vector<yarp::conf::float64_t> covariance;
40
42 pose(),
44 {
45 covariance.resize(36, 0.0);
46 }
47
48 void clear()
49 {
50 // *** pose ***
51 pose.clear();
52
53 // *** covariance ***
54 covariance.clear();
55 covariance.resize(36, 0.0);
56 }
57
58 bool readBare(yarp::os::ConnectionReader& connection) override
59 {
60 // *** pose ***
61 if (!pose.read(connection)) {
62 return false;
63 }
64
65 // *** covariance ***
66 int len = 36;
67 covariance.resize(len);
68 if (len > 0 && !connection.expectBlock((char*)&covariance[0], sizeof(yarp::conf::float64_t)*len)) {
69 return false;
70 }
71
72 return !connection.isError();
73 }
74
75 bool readBottle(yarp::os::ConnectionReader& connection) override
76 {
77 connection.convertTextMode();
78 yarp::os::idl::WireReader reader(connection);
79 if (!reader.readListHeader(2)) {
80 return false;
81 }
82
83 // *** pose ***
84 if (!pose.read(connection)) {
85 return false;
86 }
87
88 // *** covariance ***
89 if (connection.expectInt32() != (BOTTLE_TAG_LIST|BOTTLE_TAG_FLOAT64)) {
90 return false;
91 }
92 int len = connection.expectInt32();
93 covariance.resize(len);
94 for (int i=0; i<len; i++) {
96 }
97
98 return !connection.isError();
99 }
100
102 bool read(yarp::os::ConnectionReader& connection) override
103 {
104 return (connection.isBareMode() ? readBare(connection)
105 : readBottle(connection));
106 }
107
108 bool writeBare(yarp::os::ConnectionWriter& connection) const override
109 {
110 // *** pose ***
111 if (!pose.write(connection)) {
112 return false;
113 }
114
115 // *** covariance ***
116 if (covariance.size()>0) {
117 connection.appendExternalBlock((char*)&covariance[0], sizeof(yarp::conf::float64_t)*covariance.size());
118 }
119
120 return !connection.isError();
121 }
122
123 bool writeBottle(yarp::os::ConnectionWriter& connection) const override
124 {
125 connection.appendInt32(BOTTLE_TAG_LIST);
126 connection.appendInt32(2);
127
128 // *** pose ***
129 if (!pose.write(connection)) {
130 return false;
131 }
132
133 // *** covariance ***
135 connection.appendInt32(covariance.size());
136 for (size_t i=0; i<covariance.size(); i++) {
137 connection.appendFloat64(covariance[i]);
138 }
139
140 connection.convertTextMode();
141 return !connection.isError();
142 }
143
145 bool write(yarp::os::ConnectionWriter& connection) const override
146 {
147 return (connection.isBareMode() ? writeBare(connection)
148 : writeBottle(connection));
149 }
150
151 // This class will serialize ROS style or YARP style depending on protocol.
152 // If you need to force a serialization style, use one of these classes:
155
156 // The name for this message, ROS will need this
157 static constexpr const char* typeName = "geometry_msgs/PoseWithCovariance";
158
159 // The checksum for this message, ROS will need this
160 static constexpr const char* typeChecksum = "c23e848cf1b7533a8d7c259073a97e6f";
161
162 // The source text for this message, ROS will need this
163 static constexpr const char* typeText = "\
164# This represents a pose in free space with uncertainty.\n\
165\n\
166Pose pose\n\
167\n\
168# Row-major representation of the 6x6 covariance matrix\n\
169# The orientation parameters use a fixed-axis representation.\n\
170# In order, the parameters are:\n\
171# (x, y, z, rotation about X axis, rotation about Y axis, rotation about Z axis)\n\
172float64[36] covariance\n\
173\n\
174================================================================================\n\
175MSG: geometry_msgs/Pose\n\
176# A representation of pose in free space, composed of position and orientation. \n\
177Point position\n\
178Quaternion orientation\n\
179\n\
180================================================================================\n\
181MSG: geometry_msgs/Point\n\
182# This contains the position of a point in free space\n\
183float64 x\n\
184float64 y\n\
185float64 z\n\
186\n\
187================================================================================\n\
188MSG: geometry_msgs/Quaternion\n\
189# This represents an orientation in free space in quaternion form.\n\
190\n\
191float64 x\n\
192float64 y\n\
193float64 z\n\
194float64 w\n\
195";
196
197 yarp::os::Type getType() const override
198 {
201 typ.addProperty("message_definition", yarp::os::Value(typeText));
202 return typ;
203 }
204};
205
206} // namespace geometry_msgs
207} // namespace rosmsg
208} // namespace yarp
209
210#endif // YARP_ROSMSG_geometry_msgs_PoseWithCovariance_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 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 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 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.
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: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 write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
bool writeBare(yarp::os::ConnectionWriter &connection) const override
bool readBottle(yarp::os::ConnectionReader &connection) override
bool readBare(yarp::os::ConnectionReader &connection) override
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
yarp::os::idl::BottleStyle< yarp::rosmsg::geometry_msgs::PoseWithCovariance > bottleStyle
std::vector< yarp::conf::float64_t > covariance
yarp::os::idl::BareStyle< yarp::rosmsg::geometry_msgs::PoseWithCovariance > rosStyle
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Pose.h:129
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Pose.h:88
double float64_t
Definition: numeric.h:77
The main, catch-all namespace for YARP.
Definition: dirs.h:16