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