YARP
Yet Another Robot Platform
Path.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 "nav_msgs/Path" msg definition:
9 // #An array of poses that represents a Path for a robot to follow
10 // Header header
11 // geometry_msgs/PoseStamped[] poses
12 // Instances of this class can be read and written with YARP ports,
13 // using a ROS-compatible format.
14 
15 #ifndef YARP_ROSMSG_nav_msgs_Path_h
16 #define YARP_ROSMSG_nav_msgs_Path_h
17 
18 #include <yarp/os/Wire.h>
19 #include <yarp/os/Type.h>
20 #include <yarp/os/idl/WireTypes.h>
21 #include <string>
22 #include <vector>
25 
26 namespace yarp {
27 namespace rosmsg {
28 namespace nav_msgs {
29 
31 {
32 public:
34  std::vector<yarp::rosmsg::geometry_msgs::PoseStamped> poses;
35 
36  Path() :
37  header(),
38  poses()
39  {
40  }
41 
42  void clear()
43  {
44  // *** header ***
45  header.clear();
46 
47  // *** poses ***
48  poses.clear();
49  }
50 
51  bool readBare(yarp::os::ConnectionReader& connection) override
52  {
53  // *** header ***
54  if (!header.read(connection)) {
55  return false;
56  }
57 
58  // *** poses ***
59  int len = connection.expectInt32();
60  poses.resize(len);
61  for (int i=0; i<len; i++) {
62  if (!poses[i].read(connection)) {
63  return false;
64  }
65  }
66 
67  return !connection.isError();
68  }
69 
70  bool readBottle(yarp::os::ConnectionReader& connection) override
71  {
72  connection.convertTextMode();
73  yarp::os::idl::WireReader reader(connection);
74  if (!reader.readListHeader(2)) {
75  return false;
76  }
77 
78  // *** header ***
79  if (!header.read(connection)) {
80  return false;
81  }
82 
83  // *** poses ***
84  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
85  return false;
86  }
87  int len = connection.expectInt32();
88  poses.resize(len);
89  for (int i=0; i<len; i++) {
90  if (!poses[i].read(connection)) {
91  return false;
92  }
93  }
94 
95  return !connection.isError();
96  }
97 
99  bool read(yarp::os::ConnectionReader& connection) override
100  {
101  return (connection.isBareMode() ? readBare(connection)
102  : readBottle(connection));
103  }
104 
105  bool writeBare(yarp::os::ConnectionWriter& connection) const override
106  {
107  // *** header ***
108  if (!header.write(connection)) {
109  return false;
110  }
111 
112  // *** poses ***
113  connection.appendInt32(poses.size());
114  for (size_t i=0; i<poses.size(); i++) {
115  if (!poses[i].write(connection)) {
116  return false;
117  }
118  }
119 
120  return !connection.isError();
121  }
122 
123  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
124  {
125  connection.appendInt32(BOTTLE_TAG_LIST);
126  connection.appendInt32(2);
127 
128  // *** header ***
129  if (!header.write(connection)) {
130  return false;
131  }
132 
133  // *** poses ***
134  connection.appendInt32(BOTTLE_TAG_LIST);
135  connection.appendInt32(poses.size());
136  for (size_t i=0; i<poses.size(); i++) {
137  if (!poses[i].write(connection)) {
138  return false;
139  }
140  }
141 
142  connection.convertTextMode();
143  return !connection.isError();
144  }
145 
147  bool write(yarp::os::ConnectionWriter& connection) const override
148  {
149  return (connection.isBareMode() ? writeBare(connection)
150  : writeBottle(connection));
151  }
152 
153  // This class will serialize ROS style or YARP style depending on protocol.
154  // If you need to force a serialization style, use one of these classes:
157 
158  // The name for this message, ROS will need this
159  static constexpr const char* typeName = "nav_msgs/Path";
160 
161  // The checksum for this message, ROS will need this
162  static constexpr const char* typeChecksum = "6227e2b7e9cce15051f669a5e197bbf7";
163 
164  // The source text for this message, ROS will need this
165  static constexpr const char* typeText = "\
166 #An array of poses that represents a Path for a robot to follow\n\
167 Header header\n\
168 geometry_msgs/PoseStamped[] poses\n\
169 \n\
170 ================================================================================\n\
171 MSG: std_msgs/Header\n\
172 # Standard metadata for higher-level stamped data types.\n\
173 # This is generally used to communicate timestamped data \n\
174 # in a particular coordinate frame.\n\
175 # \n\
176 # sequence ID: consecutively increasing ID \n\
177 uint32 seq\n\
178 #Two-integer timestamp that is expressed as:\n\
179 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
180 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
181 # time-handling sugar is provided by the client library\n\
182 time stamp\n\
183 #Frame this data is associated with\n\
184 # 0: no frame\n\
185 # 1: global frame\n\
186 string frame_id\n\
187 \n\
188 ================================================================================\n\
189 MSG: geometry_msgs/PoseStamped\n\
190 # A Pose with reference coordinate frame and timestamp\n\
191 Header header\n\
192 Pose pose\n\
193 \n\
194 ================================================================================\n\
195 MSG: geometry_msgs/Pose\n\
196 # A representation of pose in free space, composed of position and orientation. \n\
197 Point position\n\
198 Quaternion orientation\n\
199 \n\
200 ================================================================================\n\
201 MSG: geometry_msgs/Point\n\
202 # This contains the position of a point in free space\n\
203 float64 x\n\
204 float64 y\n\
205 float64 z\n\
206 \n\
207 ================================================================================\n\
208 MSG: geometry_msgs/Quaternion\n\
209 # This represents an orientation in free space in quaternion form.\n\
210 \n\
211 float64 x\n\
212 float64 y\n\
213 float64 z\n\
214 float64 w\n\
215 ";
216 
217  yarp::os::Type getType() const override
218  {
220  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
221  typ.addProperty("message_definition", yarp::os::Value(typeText));
222  return typ;
223  }
224 };
225 
226 } // namespace nav_msgs
227 } // namespace rosmsg
228 } // namespace yarp
229 
230 #endif // YARP_ROSMSG_nav_msgs_Path_h
#define BOTTLE_TAG_LIST
Definition: Bottle.h:28
An interface for reading from a 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
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 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: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 read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Path.h:99
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: Path.h:105
yarp::rosmsg::std_msgs::Header header
Definition: Path.h:33
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: Path.h:123
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: Path.h:70
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Path.h:147
std::vector< yarp::rosmsg::geometry_msgs::PoseStamped > poses
Definition: Path.h:34
yarp::os::idl::BareStyle< yarp::rosmsg::nav_msgs::Path > rosStyle
Definition: Path.h:155
static constexpr const char * typeChecksum
Definition: Path.h:162
static constexpr const char * typeName
Definition: Path.h:159
yarp::os::idl::BottleStyle< yarp::rosmsg::nav_msgs::Path > bottleStyle
Definition: Path.h:156
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: Path.h:51
yarp::os::Type getType() const override
Definition: Path.h:217
static constexpr const char * typeText
Definition: Path.h:165
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
The main, catch-all namespace for YARP.
Definition: dirs.h:16