YARP
Yet Another Robot Platform
Illuminance.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/Illuminance" msg definition:
9 // # Single photometric illuminance measurement. Light should be assumed to be
10 // # measured along the sensor's x-axis (the area of detection is the y-z plane).
11 // # The illuminance should have a 0 or positive value and be received with
12 // # the sensor's +X axis pointing toward the light source.
13 //
14 // # Photometric illuminance is the measure of the human eye's sensitivity of the
15 // # intensity of light encountering or passing through a surface.
16 //
17 // # All other Photometric and Radiometric measurements should
18 // # not use this message.
19 // # This message cannot represent:
20 // # Luminous intensity (candela/light source output)
21 // # Luminance (nits/light output per area)
22 // # Irradiance (watt/area), etc.
23 //
24 // Header header # timestamp is the time the illuminance was measured
25 // # frame_id is the location and direction of the reading
26 //
27 // float64 illuminance # Measurement of the Photometric Illuminance in Lux.
28 //
29 // float64 variance # 0 is interpreted as variance unknown// Instances of this class can be read and written with YARP ports,
30 // using a ROS-compatible format.
31 
32 #ifndef YARP_ROSMSG_sensor_msgs_Illuminance_h
33 #define YARP_ROSMSG_sensor_msgs_Illuminance_h
34 
35 #include <yarp/os/Wire.h>
36 #include <yarp/os/Type.h>
37 #include <yarp/os/idl/WireTypes.h>
38 #include <string>
39 #include <vector>
41 
42 namespace yarp {
43 namespace rosmsg {
44 namespace sensor_msgs {
45 
47 {
48 public:
52 
54  header(),
55  illuminance(0.0),
56  variance(0.0)
57  {
58  }
59 
60  void clear()
61  {
62  // *** header ***
63  header.clear();
64 
65  // *** illuminance ***
66  illuminance = 0.0;
67 
68  // *** variance ***
69  variance = 0.0;
70  }
71 
72  bool readBare(yarp::os::ConnectionReader& connection) override
73  {
74  // *** header ***
75  if (!header.read(connection)) {
76  return false;
77  }
78 
79  // *** illuminance ***
80  illuminance = connection.expectFloat64();
81 
82  // *** variance ***
83  variance = connection.expectFloat64();
84 
85  return !connection.isError();
86  }
87 
88  bool readBottle(yarp::os::ConnectionReader& connection) override
89  {
90  connection.convertTextMode();
91  yarp::os::idl::WireReader reader(connection);
92  if (!reader.readListHeader(3)) {
93  return false;
94  }
95 
96  // *** header ***
97  if (!header.read(connection)) {
98  return false;
99  }
100 
101  // *** illuminance ***
102  illuminance = reader.expectFloat64();
103 
104  // *** variance ***
105  variance = reader.expectFloat64();
106 
107  return !connection.isError();
108  }
109 
111  bool read(yarp::os::ConnectionReader& connection) override
112  {
113  return (connection.isBareMode() ? readBare(connection)
114  : readBottle(connection));
115  }
116 
117  bool writeBare(yarp::os::ConnectionWriter& connection) const override
118  {
119  // *** header ***
120  if (!header.write(connection)) {
121  return false;
122  }
123 
124  // *** illuminance ***
125  connection.appendFloat64(illuminance);
126 
127  // *** variance ***
128  connection.appendFloat64(variance);
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(3);
137 
138  // *** header ***
139  if (!header.write(connection)) {
140  return false;
141  }
142 
143  // *** illuminance ***
144  connection.appendInt32(BOTTLE_TAG_FLOAT64);
145  connection.appendFloat64(illuminance);
146 
147  // *** variance ***
148  connection.appendInt32(BOTTLE_TAG_FLOAT64);
149  connection.appendFloat64(variance);
150 
151  connection.convertTextMode();
152  return !connection.isError();
153  }
154 
156  bool write(yarp::os::ConnectionWriter& connection) const override
157  {
158  return (connection.isBareMode() ? writeBare(connection)
159  : writeBottle(connection));
160  }
161 
162  // This class will serialize ROS style or YARP style depending on protocol.
163  // If you need to force a serialization style, use one of these classes:
166 
167  // The name for this message, ROS will need this
168  static constexpr const char* typeName = "sensor_msgs/Illuminance";
169 
170  // The checksum for this message, ROS will need this
171  static constexpr const char* typeChecksum = "8cf5febb0952fca9d650c3d11a81a188";
172 
173  // The source text for this message, ROS will need this
174  static constexpr const char* typeText = "\
175  # Single photometric illuminance measurement. Light should be assumed to be\n\
176  # measured along the sensor's x-axis (the area of detection is the y-z plane).\n\
177  # The illuminance should have a 0 or positive value and be received with\n\
178  # the sensor's +X axis pointing toward the light source.\n\
179 \n\
180  # Photometric illuminance is the measure of the human eye's sensitivity of the\n\
181  # intensity of light encountering or passing through a surface.\n\
182 \n\
183  # All other Photometric and Radiometric measurements should\n\
184  # not use this message.\n\
185  # This message cannot represent:\n\
186  # Luminous intensity (candela/light source output)\n\
187  # Luminance (nits/light output per area)\n\
188  # Irradiance (watt/area), etc.\n\
189 \n\
190  Header header # timestamp is the time the illuminance was measured\n\
191  # frame_id is the location and direction of the reading\n\
192 \n\
193  float64 illuminance # Measurement of the Photometric Illuminance in Lux.\n\
194 \n\
195  float64 variance # 0 is interpreted as variance unknown\n\
196 ================================================================================\n\
197 MSG: std_msgs/Header\n\
198 # Standard metadata for higher-level stamped data types.\n\
199 # This is generally used to communicate timestamped data \n\
200 # in a particular coordinate frame.\n\
201 # \n\
202 # sequence ID: consecutively increasing ID \n\
203 uint32 seq\n\
204 #Two-integer timestamp that is expressed as:\n\
205 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
206 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
207 # time-handling sugar is provided by the client library\n\
208 time stamp\n\
209 #Frame this data is associated with\n\
210 # 0: no frame\n\
211 # 1: global frame\n\
212 string frame_id\n\
213 ";
214 
215  yarp::os::Type getType() const override
216  {
218  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
219  typ.addProperty("message_definition", yarp::os::Value(typeText));
220  return typ;
221  }
222 };
223 
224 } // namespace sensor_msgs
225 } // namespace rosmsg
226 } // namespace yarp
227 
228 #endif // YARP_ROSMSG_sensor_msgs_Illuminance_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 isBareMode() const =0
Check if the connection is bare mode.
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 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:45
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:23
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:30
yarp::conf::float64_t expectFloat64()
Definition: WireReader.h:113
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::Illuminance > rosStyle
Definition: Illuminance.h:164
yarp::conf::float64_t illuminance
Definition: Illuminance.h:50
static constexpr const char * typeName
Definition: Illuminance.h:168
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Illuminance.h:111
yarp::os::Type getType() const override
Definition: Illuminance.h:215
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Illuminance.h:156
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: Illuminance.h:72
static constexpr const char * typeText
Definition: Illuminance.h:174
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: Illuminance.h:133
yarp::rosmsg::std_msgs::Header header
Definition: Illuminance.h:49
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::Illuminance > bottleStyle
Definition: Illuminance.h:165
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: Illuminance.h:88
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: Illuminance.h:117
static constexpr const char * typeChecksum
Definition: Illuminance.h:171
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
double float64_t
Definition: numeric.h:77
The main, catch-all namespace for YARP.
Definition: dirs.h:16