YARP
Yet Another Robot Platform
Plane.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 "shape_msgs/Plane" msg definition:
9 // # Representation of a plane, using the plane equation ax + by + cz + d = 0
10 //
11 // # a := coef[0]
12 // # b := coef[1]
13 // # c := coef[2]
14 // # d := coef[3]
15 //
16 // float64[4] coef
17 // Instances of this class can be read and written with YARP ports,
18 // using a ROS-compatible format.
19 
20 #ifndef YARP_ROSMSG_shape_msgs_Plane_h
21 #define YARP_ROSMSG_shape_msgs_Plane_h
22 
23 #include <yarp/os/Wire.h>
24 #include <yarp/os/Type.h>
25 #include <yarp/os/idl/WireTypes.h>
26 #include <string>
27 #include <vector>
28 
29 namespace yarp {
30 namespace rosmsg {
31 namespace shape_msgs {
32 
34 {
35 public:
36  std::vector<yarp::conf::float64_t> coef;
37 
38  Plane() :
39  coef()
40  {
41  coef.resize(4, 0.0);
42  }
43 
44  void clear()
45  {
46  // *** coef ***
47  coef.clear();
48  coef.resize(4, 0.0);
49  }
50 
51  bool readBare(yarp::os::ConnectionReader& connection) override
52  {
53  // *** coef ***
54  int len = 4;
55  coef.resize(len);
56  if (len > 0 && !connection.expectBlock((char*)&coef[0], sizeof(yarp::conf::float64_t)*len)) {
57  return false;
58  }
59 
60  return !connection.isError();
61  }
62 
63  bool readBottle(yarp::os::ConnectionReader& connection) override
64  {
65  connection.convertTextMode();
66  yarp::os::idl::WireReader reader(connection);
67  if (!reader.readListHeader(1)) {
68  return false;
69  }
70 
71  // *** coef ***
72  if (connection.expectInt32() != (BOTTLE_TAG_LIST|BOTTLE_TAG_FLOAT64)) {
73  return false;
74  }
75  int len = connection.expectInt32();
76  coef.resize(len);
77  for (int i=0; i<len; i++) {
78  coef[i] = (yarp::conf::float64_t)connection.expectFloat64();
79  }
80 
81  return !connection.isError();
82  }
83 
85  bool read(yarp::os::ConnectionReader& connection) override
86  {
87  return (connection.isBareMode() ? readBare(connection)
88  : readBottle(connection));
89  }
90 
91  bool writeBare(yarp::os::ConnectionWriter& connection) const override
92  {
93  // *** coef ***
94  if (coef.size()>0) {
95  connection.appendExternalBlock((char*)&coef[0], sizeof(yarp::conf::float64_t)*coef.size());
96  }
97 
98  return !connection.isError();
99  }
100 
101  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
102  {
103  connection.appendInt32(BOTTLE_TAG_LIST);
104  connection.appendInt32(1);
105 
106  // *** coef ***
108  connection.appendInt32(coef.size());
109  for (size_t i=0; i<coef.size(); i++) {
110  connection.appendFloat64(coef[i]);
111  }
112 
113  connection.convertTextMode();
114  return !connection.isError();
115  }
116 
118  bool write(yarp::os::ConnectionWriter& connection) const override
119  {
120  return (connection.isBareMode() ? writeBare(connection)
121  : writeBottle(connection));
122  }
123 
124  // This class will serialize ROS style or YARP style depending on protocol.
125  // If you need to force a serialization style, use one of these classes:
128 
129  // The name for this message, ROS will need this
130  static constexpr const char* typeName = "shape_msgs/Plane";
131 
132  // The checksum for this message, ROS will need this
133  static constexpr const char* typeChecksum = "2c1b92ed8f31492f8e73f6a4a44ca796";
134 
135  // The source text for this message, ROS will need this
136  static constexpr const char* typeText = "\
137 # Representation of a plane, using the plane equation ax + by + cz + d = 0\n\
138 \n\
139 # a := coef[0]\n\
140 # b := coef[1]\n\
141 # c := coef[2]\n\
142 # d := coef[3]\n\
143 \n\
144 float64[4] coef\n\
145 ";
146 
147  yarp::os::Type getType() const override
148  {
150  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
151  typ.addProperty("message_definition", yarp::os::Value(typeText));
152  return typ;
153  }
154 };
155 
156 } // namespace shape_msgs
157 } // namespace rosmsg
158 } // namespace yarp
159 
160 #endif // YARP_ROSMSG_shape_msgs_Plane_h
#define BOTTLE_TAG_FLOAT64
Definition: Bottle.h:25
#define BOTTLE_TAG_LIST
Definition: Bottle.h:28
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 bool isError() const =0
virtual yarp::conf::float64_t expectFloat64()=0
Read a 64-bit floating point number 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 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.
virtual void appendFloat64(yarp::conf::float64_t data)=0
Send a representation of a 64-bit floating point number 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:45
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:23
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:30
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: Plane.h:51
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: Plane.h:63
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Plane.h:118
yarp::os::Type getType() const override
Definition: Plane.h:147
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: Plane.h:91
static constexpr const char * typeChecksum
Definition: Plane.h:133
yarp::os::idl::BottleStyle< yarp::rosmsg::shape_msgs::Plane > bottleStyle
Definition: Plane.h:127
static constexpr const char * typeText
Definition: Plane.h:136
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: Plane.h:101
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Plane.h:85
yarp::os::idl::BareStyle< yarp::rosmsg::shape_msgs::Plane > rosStyle
Definition: Plane.h:126
static constexpr const char * typeName
Definition: Plane.h:130
std::vector< yarp::conf::float64_t > coef
Definition: Plane.h:36
double float64_t
Definition: numeric.h:77
The main, catch-all namespace for YARP.
Definition: dirs.h:16