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