YARP
Yet Another Robot Platform
MagneticField.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 "sensor_msgs/MagneticField" msg definition:
9// # Measurement of the Magnetic Field vector at a specific location.
10//
11// # If the covariance of the measurement is known, it should be filled in
12// # (if all you know is the variance of each measurement, e.g. from the datasheet,
13// #just put those along the diagonal)
14// # A covariance matrix of all zeros will be interpreted as "covariance unknown",
15// # and to use the data a covariance will have to be assumed or gotten from some
16// # other source
17//
18//
19// Header header # timestamp is the time the
20// # field was measured
21// # frame_id is the location and orientation
22// # of the field measurement
23//
24// geometry_msgs/Vector3 magnetic_field # x, y, and z components of the
25// # field vector in Tesla
26// # If your sensor does not output 3 axes,
27// # put NaNs in the components not reported.
28//
29// float64[9] magnetic_field_covariance # Row major about x, y, z axes
30// # 0 is interpreted as variance unknown// Instances of this class can be read and written with YARP ports,
31// using a ROS-compatible format.
32
33#ifndef YARP_ROSMSG_sensor_msgs_MagneticField_h
34#define YARP_ROSMSG_sensor_msgs_MagneticField_h
35
36#include <yarp/os/Wire.h>
37#include <yarp/os/Type.h>
39#include <string>
40#include <vector>
43
44namespace yarp {
45namespace rosmsg {
46namespace sensor_msgs {
47
49{
50public:
53 std::vector<yarp::conf::float64_t> magnetic_field_covariance;
54
56 header(),
57 magnetic_field(),
58 magnetic_field_covariance()
59 {
60 magnetic_field_covariance.resize(9, 0.0);
61 }
62
63 void clear()
64 {
65 // *** header ***
66 header.clear();
67
68 // *** magnetic_field ***
69 magnetic_field.clear();
70
71 // *** magnetic_field_covariance ***
72 magnetic_field_covariance.clear();
73 magnetic_field_covariance.resize(9, 0.0);
74 }
75
76 bool readBare(yarp::os::ConnectionReader& connection) override
77 {
78 // *** header ***
79 if (!header.read(connection)) {
80 return false;
81 }
82
83 // *** magnetic_field ***
84 if (!magnetic_field.read(connection)) {
85 return false;
86 }
87
88 // *** magnetic_field_covariance ***
89 int len = 9;
90 magnetic_field_covariance.resize(len);
91 if (len > 0 && !connection.expectBlock((char*)&magnetic_field_covariance[0], sizeof(yarp::conf::float64_t)*len)) {
92 return false;
93 }
94
95 return !connection.isError();
96 }
97
98 bool readBottle(yarp::os::ConnectionReader& connection) override
99 {
100 connection.convertTextMode();
101 yarp::os::idl::WireReader reader(connection);
102 if (!reader.readListHeader(3)) {
103 return false;
104 }
105
106 // *** header ***
107 if (!header.read(connection)) {
108 return false;
109 }
110
111 // *** magnetic_field ***
112 if (!magnetic_field.read(connection)) {
113 return false;
114 }
115
116 // *** magnetic_field_covariance ***
117 if (connection.expectInt32() != (BOTTLE_TAG_LIST|BOTTLE_TAG_FLOAT64)) {
118 return false;
119 }
120 int len = connection.expectInt32();
121 magnetic_field_covariance.resize(len);
122 for (int i=0; i<len; i++) {
123 magnetic_field_covariance[i] = (yarp::conf::float64_t)connection.expectFloat64();
124 }
125
126 return !connection.isError();
127 }
128
130 bool read(yarp::os::ConnectionReader& connection) override
131 {
132 return (connection.isBareMode() ? readBare(connection)
133 : readBottle(connection));
134 }
135
136 bool writeBare(yarp::os::ConnectionWriter& connection) const override
137 {
138 // *** header ***
139 if (!header.write(connection)) {
140 return false;
141 }
142
143 // *** magnetic_field ***
144 if (!magnetic_field.write(connection)) {
145 return false;
146 }
147
148 // *** magnetic_field_covariance ***
149 if (magnetic_field_covariance.size()>0) {
150 connection.appendExternalBlock((char*)&magnetic_field_covariance[0], sizeof(yarp::conf::float64_t)*magnetic_field_covariance.size());
151 }
152
153 return !connection.isError();
154 }
155
156 bool writeBottle(yarp::os::ConnectionWriter& connection) const override
157 {
158 connection.appendInt32(BOTTLE_TAG_LIST);
159 connection.appendInt32(3);
160
161 // *** header ***
162 if (!header.write(connection)) {
163 return false;
164 }
165
166 // *** magnetic_field ***
167 if (!magnetic_field.write(connection)) {
168 return false;
169 }
170
171 // *** magnetic_field_covariance ***
173 connection.appendInt32(magnetic_field_covariance.size());
174 for (size_t i=0; i<magnetic_field_covariance.size(); i++) {
175 connection.appendFloat64(magnetic_field_covariance[i]);
176 }
177
178 connection.convertTextMode();
179 return !connection.isError();
180 }
181
183 bool write(yarp::os::ConnectionWriter& connection) const override
184 {
185 return (connection.isBareMode() ? writeBare(connection)
186 : writeBottle(connection));
187 }
188
189 // This class will serialize ROS style or YARP style depending on protocol.
190 // If you need to force a serialization style, use one of these classes:
193
194 // The name for this message, ROS will need this
195 static constexpr const char* typeName = "sensor_msgs/MagneticField";
196
197 // The checksum for this message, ROS will need this
198 static constexpr const char* typeChecksum = "2f3b0b43eed0c9501de0fa3ff89a45aa";
199
200 // The source text for this message, ROS will need this
201 static constexpr const char* typeText = "\
202 # Measurement of the Magnetic Field vector at a specific location.\n\
203\n\
204 # If the covariance of the measurement is known, it should be filled in\n\
205 # (if all you know is the variance of each measurement, e.g. from the datasheet,\n\
206 #just put those along the diagonal)\n\
207 # A covariance matrix of all zeros will be interpreted as \"covariance unknown\",\n\
208 # and to use the data a covariance will have to be assumed or gotten from some\n\
209 # other source\n\
210\n\
211\n\
212 Header header # timestamp is the time the\n\
213 # field was measured\n\
214 # frame_id is the location and orientation\n\
215 # of the field measurement\n\
216\n\
217 geometry_msgs/Vector3 magnetic_field # x, y, and z components of the\n\
218 # field vector in Tesla\n\
219 # If your sensor does not output 3 axes,\n\
220 # put NaNs in the components not reported.\n\
221\n\
222 float64[9] magnetic_field_covariance # Row major about x, y, z axes\n\
223 # 0 is interpreted as variance unknown\n\
224================================================================================\n\
225MSG: std_msgs/Header\n\
226# Standard metadata for higher-level stamped data types.\n\
227# This is generally used to communicate timestamped data \n\
228# in a particular coordinate frame.\n\
229# \n\
230# sequence ID: consecutively increasing ID \n\
231uint32 seq\n\
232#Two-integer timestamp that is expressed as:\n\
233# * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
234# * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
235# time-handling sugar is provided by the client library\n\
236time stamp\n\
237#Frame this data is associated with\n\
238# 0: no frame\n\
239# 1: global frame\n\
240string frame_id\n\
241\n\
242================================================================================\n\
243MSG: geometry_msgs/Vector3\n\
244# This represents a vector in free space. \n\
245# It is only meant to represent a direction. Therefore, it does not\n\
246# make sense to apply a translation to it (e.g., when applying a \n\
247# generic rigid transformation to a Vector3, tf2 will only apply the\n\
248# rotation). If you want your data to be translatable too, use the\n\
249# geometry_msgs/Point message instead.\n\
250\n\
251float64 x\n\
252float64 y\n\
253float64 z\n\
254";
255
256 yarp::os::Type getType() const override
257 {
258 yarp::os::Type typ = yarp::os::Type::byName(typeName, typeName);
259 typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
260 typ.addProperty("message_definition", yarp::os::Value(typeText));
261 return typ;
262 }
263};
264
265} // namespace sensor_msgs
266} // namespace rosmsg
267} // namespace yarp
268
269#endif // YARP_ROSMSG_sensor_msgs_MagneticField_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 read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Vector3.h:95
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Vector3.h:137
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Header.h:159
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Header.h:112
yarp::rosmsg::sensor_msgs::MagneticField MagneticField
Definition: MagneticField.h:21
double float64_t
Definition: numeric.h:77
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:915
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:1091
The main, catch-all namespace for YARP.
Definition: dirs.h:16