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