YARP
Yet Another Robot Platform
LaserEcho.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/LaserEcho" msg definition:
9// # This message is a submessage of MultiEchoLaserScan and is not intended
10// # to be used separately.
11//
12// float32[] echoes # Multiple values of ranges or intensities.
13// # Each array represents data from the same angle increment.// Instances of this class can be read and written with YARP ports,
14// using a ROS-compatible format.
15
16#ifndef YARP_ROSMSG_sensor_msgs_LaserEcho_h
17#define YARP_ROSMSG_sensor_msgs_LaserEcho_h
18
19#include <yarp/os/Wire.h>
20#include <yarp/os/Type.h>
22#include <string>
23#include <vector>
24
25namespace yarp {
26namespace rosmsg {
27namespace sensor_msgs {
28
30{
31public:
32 std::vector<yarp::conf::float32_t> echoes;
33
34 LaserEcho() :
35 echoes()
36 {
37 }
38
39 void clear()
40 {
41 // *** echoes ***
42 echoes.clear();
43 }
44
45 bool readBare(yarp::os::ConnectionReader& connection) override
46 {
47 // *** echoes ***
48 int len = connection.expectInt32();
49 echoes.resize(len);
50 if (len > 0 && !connection.expectBlock((char*)&echoes[0], sizeof(yarp::conf::float32_t)*len)) {
51 return false;
52 }
53
54 return !connection.isError();
55 }
56
57 bool readBottle(yarp::os::ConnectionReader& connection) override
58 {
59 connection.convertTextMode();
60 yarp::os::idl::WireReader reader(connection);
61 if (!reader.readListHeader(1)) {
62 return false;
63 }
64
65 // *** echoes ***
66 if (connection.expectInt32() != (BOTTLE_TAG_LIST|BOTTLE_TAG_FLOAT32)) {
67 return false;
68 }
69 int len = connection.expectInt32();
70 echoes.resize(len);
71 for (int i=0; i<len; i++) {
72 echoes[i] = (yarp::conf::float32_t)connection.expectFloat32();
73 }
74
75 return !connection.isError();
76 }
77
79 bool read(yarp::os::ConnectionReader& connection) override
80 {
81 return (connection.isBareMode() ? readBare(connection)
82 : readBottle(connection));
83 }
84
85 bool writeBare(yarp::os::ConnectionWriter& connection) const override
86 {
87 // *** echoes ***
88 connection.appendInt32(echoes.size());
89 if (echoes.size()>0) {
90 connection.appendExternalBlock((char*)&echoes[0], sizeof(yarp::conf::float32_t)*echoes.size());
91 }
92
93 return !connection.isError();
94 }
95
96 bool writeBottle(yarp::os::ConnectionWriter& connection) const override
97 {
98 connection.appendInt32(BOTTLE_TAG_LIST);
99 connection.appendInt32(1);
100
101 // *** echoes ***
103 connection.appendInt32(echoes.size());
104 for (size_t i=0; i<echoes.size(); i++) {
105 connection.appendFloat32(echoes[i]);
106 }
107
108 connection.convertTextMode();
109 return !connection.isError();
110 }
111
113 bool write(yarp::os::ConnectionWriter& connection) const override
114 {
115 return (connection.isBareMode() ? writeBare(connection)
116 : writeBottle(connection));
117 }
118
119 // This class will serialize ROS style or YARP style depending on protocol.
120 // If you need to force a serialization style, use one of these classes:
123
124 // The name for this message, ROS will need this
125 static constexpr const char* typeName = "sensor_msgs/LaserEcho";
126
127 // The checksum for this message, ROS will need this
128 static constexpr const char* typeChecksum = "8bc5ae449b200fba4d552b4225586696";
129
130 // The source text for this message, ROS will need this
131 static constexpr const char* typeText = "\
132# This message is a submessage of MultiEchoLaserScan and is not intended\n\
133# to be used separately.\n\
134\n\
135float32[] echoes # Multiple values of ranges or intensities.\n\
136 # Each array represents data from the same angle increment.\n\
137";
138
139 yarp::os::Type getType() const override
140 {
141 yarp::os::Type typ = yarp::os::Type::byName(typeName, typeName);
142 typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
143 typ.addProperty("message_definition", yarp::os::Value(typeText));
144 return typ;
145 }
146};
147
148} // namespace sensor_msgs
149} // namespace rosmsg
150} // namespace yarp
151
152#endif // YARP_ROSMSG_sensor_msgs_LaserEcho_h
#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 expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
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
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 appendFloat32(yarp::conf::float32_t data)=0
Send a representation of a 32-bit floating point number to the network connection.
virtual void appendExternalBlock(const char *data, size_t len)=0
Send a block of data to the network connection, without making a copy.
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
yarp::rosmsg::sensor_msgs::LaserEcho LaserEcho
Definition: LaserEcho.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