YARP
Yet Another Robot Platform
Illuminance.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2018 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  // Give source text for class, ROS will need this
171  static std::string typeText()
172  {
173  return std::string("\
174  # Single photometric illuminance measurement. Light should be assumed to be\n\
175  # measured along the sensor's x-axis (the area of detection is the y-z plane).\n\
176  # The illuminance should have a 0 or positive value and be received with\n\
177  # the sensor's +X axis pointing toward the light source.\n\
178 \n\
179  # Photometric illuminance is the measure of the human eye's sensitivity of the\n\
180  # intensity of light encountering or passing through a surface.\n\
181 \n\
182  # All other Photometric and Radiometric measurements should\n\
183  # not use this message.\n\
184  # This message cannot represent:\n\
185  # Luminous intensity (candela/light source output)\n\
186  # Luminance (nits/light output per area)\n\
187  # Irradiance (watt/area), etc.\n\
188 \n\
189  Header header # timestamp is the time the illuminance was measured\n\
190  # frame_id is the location and direction of the reading\n\
191 \n\
192  float64 illuminance # Measurement of the Photometric Illuminance in Lux.\n\
193 \n\
194  float64 variance # 0 is interpreted as variance unknown") + std::string("\n\
195 ================================================================================\n\
196 MSG: std_msgs/Header\n\
198  }
199 
200  std::string getTypeText() const
201  {
203  }
204 
205  // Name the class, ROS will need this
206  yarp::os::Type getType() const override
207  {
208  yarp::os::Type typ = yarp::os::Type::byName("sensor_msgs/Illuminance", "sensor_msgs/Illuminance");
209  typ.addProperty("md5sum", yarp::os::Value("8cf5febb0952fca9d650c3d11a81a188"));
210  typ.addProperty("message_definition", yarp::os::Value(getTypeText()));
211  return typ;
212  }
213 };
214 
215 } // namespace sensor_msgs
216 } // namespace rosmsg
217 } // namespace yarp
218 
219 #endif // YARP_ROSMSG_sensor_msgs_Illuminance_h
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Illuminance.h:159
static std::string typeText()
Definition: Header.h:174
yarp::os::Type getType() const override
Definition: Illuminance.h:206
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::Illuminance > rosStyle
Definition: Illuminance.h:167
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: Illuminance.h:75
yarp::conf::float64_t expectFloat64()
Definition: WireReader.h:113
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: Illuminance.h:136
static Type byName(const char *name)
Definition: Type.cpp:165
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:127
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::Illuminance > bottleStyle
Definition: Illuminance.h:168
virtual bool isError() const =0
The main, catch-all namespace for YARP.
Definition: numeric.h:47
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary...
virtual bool isBareMode() const =0
Check if the connection is bare mode.
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: Illuminance.h:120
An interface for writing to a network connection.
virtual bool write(const yarp::os::idl::WireWriter &writer) const
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
virtual bool read(yarp::os::idl::WireReader &reader)
virtual yarp::conf::float64_t expectFloat64()=0
Read a 64-bit floating point number from the network connection.
virtual bool isError() const =0
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Header.h:162
#define BOTTLE_TAG_FLOAT64
Definition: Bottle.h:27
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:30
yarp::rosmsg::std_msgs::Header header
Definition: Illuminance.h:52
An interface for reading from a network connection.
yarp::conf::float64_t illuminance
Definition: Illuminance.h:53
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Illuminance.h:114
double float64_t
Definition: numeric.h:51
A single value (typically within a Bottle).
Definition: Value.h:40
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...
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: Illuminance.h:91
IDL-friendly connection reader.
Definition: WireReader.h:37
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Header.h:115
virtual void appendFloat64(yarp::conf::float64_t data)=0
Send a representation of a 64-bit floating point number to the network connection.