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