YARP
Yet Another Robot Platform
Range.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/Range" msg definition:
12 // # Single range reading from an active ranger that emits energy and reports
13 // # one range reading that is valid along an arc at the distance measured.
14 // # This message is not appropriate for laser scanners. See the LaserScan
15 // # message if you are working with a laser scanner.
16 //
17 // # This message also can represent a fixed-distance (binary) ranger. This
18 // # sensor will have min_range===max_range===distance of detection.
19 // # These sensors follow REP 117 and will output -Inf if the object is detected
20 // # and +Inf if the object is outside of the detection range.
21 //
22 // Header header # timestamp in the header is the time the ranger
23 // # returned the distance reading
24 //
25 // # Radiation type enums
26 // # If you want a value added to this list, send an email to the ros-users list
27 // uint8 ULTRASOUND=0
28 // uint8 INFRARED=1
29 //
30 // uint8 radiation_type # the type of radiation used by the sensor
31 // # (sound, IR, etc) [enum]
32 //
33 // float32 field_of_view # the size of the arc that the distance reading is
34 // # valid for [rad]
35 // # the object causing the range reading may have
36 // # been anywhere within -field_of_view/2 and
37 // # field_of_view/2 at the measured range.
38 // # 0 angle corresponds to the x-axis of the sensor.
39 //
40 // float32 min_range # minimum range value [m]
41 // float32 max_range # maximum range value [m]
42 // # Fixed distance rangers require min_range==max_range
43 //
44 // float32 range # range data [m]
45 // # (Note: values < range_min or > range_max
46 // # should be discarded)
47 // # Fixed distance rangers only output -Inf or +Inf.
48 // # -Inf represents a detection within fixed distance.
49 // # (Detection too close to the sensor to quantify)
50 // # +Inf represents no detection within the fixed distance.
51 // # (Object out of range)// Instances of this class can be read and written with YARP ports,
52 // using a ROS-compatible format.
53 
54 #ifndef YARP_ROSMSG_sensor_msgs_Range_h
55 #define YARP_ROSMSG_sensor_msgs_Range_h
56 
57 #include <yarp/os/Wire.h>
58 #include <yarp/os/Type.h>
59 #include <yarp/os/idl/WireTypes.h>
60 #include <string>
61 #include <vector>
63 
64 namespace yarp {
65 namespace rosmsg {
66 namespace sensor_msgs {
67 
69 {
70 public:
72  static const std::uint8_t ULTRASOUND = 0;
73  static const std::uint8_t INFRARED = 1;
74  std::uint8_t radiation_type;
79 
80  Range() :
81  header(),
82  radiation_type(0),
83  field_of_view(0.0f),
84  min_range(0.0f),
85  max_range(0.0f),
86  range(0.0f)
87  {
88  }
89 
90  void clear()
91  {
92  // *** header ***
93  header.clear();
94 
95  // *** ULTRASOUND ***
96 
97  // *** INFRARED ***
98 
99  // *** radiation_type ***
100  radiation_type = 0;
101 
102  // *** field_of_view ***
103  field_of_view = 0.0f;
104 
105  // *** min_range ***
106  min_range = 0.0f;
107 
108  // *** max_range ***
109  max_range = 0.0f;
110 
111  // *** range ***
112  range = 0.0f;
113  }
114 
115  bool readBare(yarp::os::ConnectionReader& connection) override
116  {
117  // *** header ***
118  if (!header.read(connection)) {
119  return false;
120  }
121 
122  // *** radiation_type ***
123  radiation_type = connection.expectInt8();
124 
125  // *** field_of_view ***
126  field_of_view = connection.expectFloat32();
127 
128  // *** min_range ***
129  min_range = connection.expectFloat32();
130 
131  // *** max_range ***
132  max_range = connection.expectFloat32();
133 
134  // *** range ***
135  range = connection.expectFloat32();
136 
137  return !connection.isError();
138  }
139 
140  bool readBottle(yarp::os::ConnectionReader& connection) override
141  {
142  connection.convertTextMode();
143  yarp::os::idl::WireReader reader(connection);
144  if (!reader.readListHeader(8)) {
145  return false;
146  }
147 
148  // *** header ***
149  if (!header.read(connection)) {
150  return false;
151  }
152 
153  // *** radiation_type ***
154  radiation_type = reader.expectInt8();
155 
156  // *** field_of_view ***
157  field_of_view = reader.expectFloat32();
158 
159  // *** min_range ***
160  min_range = reader.expectFloat32();
161 
162  // *** max_range ***
163  max_range = reader.expectFloat32();
164 
165  // *** range ***
166  range = reader.expectFloat32();
167 
168  return !connection.isError();
169  }
170 
172  bool read(yarp::os::ConnectionReader& connection) override
173  {
174  return (connection.isBareMode() ? readBare(connection)
175  : readBottle(connection));
176  }
177 
178  bool writeBare(yarp::os::ConnectionWriter& connection) const override
179  {
180  // *** header ***
181  if (!header.write(connection)) {
182  return false;
183  }
184 
185  // *** radiation_type ***
186  connection.appendInt8(radiation_type);
187 
188  // *** field_of_view ***
189  connection.appendFloat32(field_of_view);
190 
191  // *** min_range ***
192  connection.appendFloat32(min_range);
193 
194  // *** max_range ***
195  connection.appendFloat32(max_range);
196 
197  // *** range ***
198  connection.appendFloat32(range);
199 
200  return !connection.isError();
201  }
202 
203  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
204  {
205  connection.appendInt32(BOTTLE_TAG_LIST);
206  connection.appendInt32(8);
207 
208  // *** header ***
209  if (!header.write(connection)) {
210  return false;
211  }
212 
213  // *** radiation_type ***
214  connection.appendInt32(BOTTLE_TAG_INT8);
215  connection.appendInt8(radiation_type);
216 
217  // *** field_of_view ***
218  connection.appendInt32(BOTTLE_TAG_FLOAT32);
219  connection.appendFloat32(field_of_view);
220 
221  // *** min_range ***
222  connection.appendInt32(BOTTLE_TAG_FLOAT32);
223  connection.appendFloat32(min_range);
224 
225  // *** max_range ***
226  connection.appendInt32(BOTTLE_TAG_FLOAT32);
227  connection.appendFloat32(max_range);
228 
229  // *** range ***
230  connection.appendInt32(BOTTLE_TAG_FLOAT32);
231  connection.appendFloat32(range);
232 
233  connection.convertTextMode();
234  return !connection.isError();
235  }
236 
238  bool write(yarp::os::ConnectionWriter& connection) const override
239  {
240  return (connection.isBareMode() ? writeBare(connection)
241  : writeBottle(connection));
242  }
243 
244  // This class will serialize ROS style or YARP style depending on protocol.
245  // If you need to force a serialization style, use one of these classes:
248 
249  // The name for this message, ROS will need this
250  static constexpr const char* typeName = "sensor_msgs/Range";
251 
252  // The checksum for this message, ROS will need this
253  static constexpr const char* typeChecksum = "c005c34273dc426c67a020a87bc24148";
254 
255  // The source text for this message, ROS will need this
256  static constexpr const char* typeText = "\
257 # Single range reading from an active ranger that emits energy and reports\n\
258 # one range reading that is valid along an arc at the distance measured. \n\
259 # This message is not appropriate for laser scanners. See the LaserScan\n\
260 # message if you are working with a laser scanner.\n\
261 \n\
262 # This message also can represent a fixed-distance (binary) ranger. This\n\
263 # sensor will have min_range===max_range===distance of detection.\n\
264 # These sensors follow REP 117 and will output -Inf if the object is detected\n\
265 # and +Inf if the object is outside of the detection range.\n\
266 \n\
267 Header header # timestamp in the header is the time the ranger\n\
268  # returned the distance reading\n\
269 \n\
270 # Radiation type enums\n\
271 # If you want a value added to this list, send an email to the ros-users list\n\
272 uint8 ULTRASOUND=0\n\
273 uint8 INFRARED=1\n\
274 \n\
275 uint8 radiation_type # the type of radiation used by the sensor\n\
276  # (sound, IR, etc) [enum]\n\
277 \n\
278 float32 field_of_view # the size of the arc that the distance reading is\n\
279  # valid for [rad]\n\
280  # the object causing the range reading may have\n\
281  # been anywhere within -field_of_view/2 and\n\
282  # field_of_view/2 at the measured range. \n\
283  # 0 angle corresponds to the x-axis of the sensor.\n\
284 \n\
285 float32 min_range # minimum range value [m]\n\
286 float32 max_range # maximum range value [m]\n\
287  # Fixed distance rangers require min_range==max_range\n\
288 \n\
289 float32 range # range data [m]\n\
290  # (Note: values < range_min or > range_max\n\
291  # should be discarded)\n\
292  # Fixed distance rangers only output -Inf or +Inf.\n\
293  # -Inf represents a detection within fixed distance.\n\
294  # (Detection too close to the sensor to quantify)\n\
295  # +Inf represents no detection within the fixed distance.\n\
296  # (Object out of range)\n\
297 ================================================================================\n\
298 MSG: std_msgs/Header\n\
299 # Standard metadata for higher-level stamped data types.\n\
300 # This is generally used to communicate timestamped data \n\
301 # in a particular coordinate frame.\n\
302 # \n\
303 # sequence ID: consecutively increasing ID \n\
304 uint32 seq\n\
305 #Two-integer timestamp that is expressed as:\n\
306 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
307 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
308 # time-handling sugar is provided by the client library\n\
309 time stamp\n\
310 #Frame this data is associated with\n\
311 # 0: no frame\n\
312 # 1: global frame\n\
313 string frame_id\n\
314 ";
315 
316  yarp::os::Type getType() const override
317  {
319  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
320  typ.addProperty("message_definition", yarp::os::Value(typeText));
321  return typ;
322  }
323 };
324 
325 } // namespace sensor_msgs
326 } // namespace rosmsg
327 } // namespace yarp
328 
329 #endif // YARP_ROSMSG_sensor_msgs_Range_h
yarp::rosmsg::sensor_msgs::Range::clear
void clear()
Definition: Range.h:90
yarp::os::ConnectionWriter::appendFloat32
virtual void appendFloat32(yarp::conf::float32_t data)=0
Send a representation of a 32-bit floating point number to the network connection.
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::Range::typeText
static constexpr const char * typeText
Definition: Range.h:256
yarp::rosmsg::sensor_msgs::Range
Definition: Range.h:69
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::rosmsg::sensor_msgs::Range::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::Range > bottleStyle
Definition: Range.h:247
yarp::os::idl::WireReader::expectFloat32
yarp::conf::float32_t expectFloat32()
Definition: WireReader.h:113
yarp::rosmsg::sensor_msgs::Range::header
yarp::rosmsg::std_msgs::Header header
Definition: Range.h:71
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
yarp::rosmsg::sensor_msgs::Range::field_of_view
yarp::conf::float32_t field_of_view
Definition: Range.h:75
Header.h
yarp::os::ConnectionWriter::appendInt8
virtual void appendInt8(std::int8_t data)=0
Send a representation of a 8-bit integer to the network connection.
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
BOTTLE_TAG_INT8
#define BOTTLE_TAG_INT8
Definition: Bottle.h:21
yarp::rosmsg::sensor_msgs::Range::typeName
static constexpr const char * typeName
Definition: Range.h:250
yarp::rosmsg::sensor_msgs::Range::ULTRASOUND
static const std::uint8_t ULTRASOUND
Definition: Range.h:72
yarp::rosmsg::sensor_msgs::Range::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: Range.h:178
yarp::os::ConnectionReader::expectInt8
virtual std::int8_t expectInt8()=0
Read a 8-bit integer from the network connection.
yarp::rosmsg::sensor_msgs::Range::range
yarp::conf::float32_t range
Definition: Range.h:78
yarp::rosmsg::sensor_msgs::Range::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Range.h:238
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
BOTTLE_TAG_FLOAT32
#define BOTTLE_TAG_FLOAT32
Definition: Bottle.h:26
yarp::os::Type::byName
static Type byName(const char *name)
Definition: Type.cpp:174
yarp::rosmsg::sensor_msgs::Range::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: Range.h:203
yarp::os::Type::addProperty
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:137
Type.h
yarp::rosmsg::sensor_msgs::Range::radiation_type
std::uint8_t radiation_type
Definition: Range.h:74
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
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::rosmsg::sensor_msgs::Range::Range
Range()
Definition: Range.h:80
yarp::rosmsg::sensor_msgs::Range::INFRARED
static const std::uint8_t INFRARED
Definition: Range.h:73
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::Range::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::Range > rosStyle
Definition: Range.h:246
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::conf::float32_t
float float32_t
Definition: numeric.h:50
yarp::rosmsg::sensor_msgs::Range::getType
yarp::os::Type getType() const override
Definition: Range.h:316
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::rosmsg::sensor_msgs::Range::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: Range.h:140
yarp::os::idl::BareStyle
Definition: BareStyle.h:22
yarp::rosmsg::sensor_msgs::Range::typeChecksum
static constexpr const char * typeChecksum
Definition: Range.h:253
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::os::ConnectionReader::expectFloat32
virtual yarp::conf::float32_t expectFloat32()=0
Read a 32-bit floating point number from the network connection.
yarp::os::idl::WireReader::expectInt8
std::int8_t expectInt8()
Definition: WireReader.h:87
yarp::rosmsg::sensor_msgs::Range::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: Range.h:115
yarp::rosmsg::sensor_msgs::Range::min_range
yarp::conf::float32_t min_range
Definition: Range.h:76
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
sensor_msgs
Definition: BatteryState.h:22
yarp::rosmsg::sensor_msgs::Range::max_range
yarp::conf::float32_t max_range
Definition: Range.h:77
yarp::rosmsg::std_msgs::Header
Definition: Header.h:45
yarp::rosmsg::sensor_msgs::Range::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Range.h:172
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