YARP
Yet Another Robot Platform
JointTrajectory.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 "trajectory_msgs/JointTrajectory" msg definition:
9 // Header header
10 // string[] joint_names
11 // JointTrajectoryPoint[] points// Instances of this class can be read and written with YARP ports,
12 // using a ROS-compatible format.
13 
14 #ifndef YARP_ROSMSG_trajectory_msgs_JointTrajectory_h
15 #define YARP_ROSMSG_trajectory_msgs_JointTrajectory_h
16 
17 #include <yarp/os/Wire.h>
18 #include <yarp/os/Type.h>
20 #include <string>
21 #include <vector>
24 
25 namespace yarp {
26 namespace rosmsg {
27 namespace trajectory_msgs {
28 
30 {
31 public:
33  std::vector<std::string> joint_names;
34  std::vector<yarp::rosmsg::trajectory_msgs::JointTrajectoryPoint> points;
35 
37  header(),
38  joint_names(),
39  points()
40  {
41  }
42 
43  void clear()
44  {
45  // *** header ***
46  header.clear();
47 
48  // *** joint_names ***
49  joint_names.clear();
50 
51  // *** points ***
52  points.clear();
53  }
54 
55  bool readBare(yarp::os::ConnectionReader& connection) override
56  {
57  // *** header ***
58  if (!header.read(connection)) {
59  return false;
60  }
61 
62  // *** joint_names ***
63  int len = connection.expectInt32();
64  joint_names.resize(len);
65  for (int i=0; i<len; i++) {
66  int len2 = connection.expectInt32();
67  joint_names[i].resize(len2);
68  if (!connection.expectBlock((char*)joint_names[i].c_str(), len2)) {
69  return false;
70  }
71  }
72 
73  // *** points ***
74  len = connection.expectInt32();
75  points.resize(len);
76  for (int i=0; i<len; i++) {
77  if (!points[i].read(connection)) {
78  return false;
79  }
80  }
81 
82  return !connection.isError();
83  }
84 
85  bool readBottle(yarp::os::ConnectionReader& connection) override
86  {
87  connection.convertTextMode();
88  yarp::os::idl::WireReader reader(connection);
89  if (!reader.readListHeader(3)) {
90  return false;
91  }
92 
93  // *** header ***
94  if (!header.read(connection)) {
95  return false;
96  }
97 
98  // *** joint_names ***
99  if (connection.expectInt32() != (BOTTLE_TAG_LIST|BOTTLE_TAG_STRING)) {
100  return false;
101  }
102  int len = connection.expectInt32();
103  joint_names.resize(len);
104  for (int i=0; i<len; i++) {
105  int len2 = connection.expectInt32();
106  joint_names[i].resize(len2);
107  if (!connection.expectBlock((char*)joint_names[i].c_str(), len2)) {
108  return false;
109  }
110  }
111 
112  // *** points ***
113  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
114  return false;
115  }
116  len = connection.expectInt32();
117  points.resize(len);
118  for (int i=0; i<len; i++) {
119  if (!points[i].read(connection)) {
120  return false;
121  }
122  }
123 
124  return !connection.isError();
125  }
126 
128  bool read(yarp::os::ConnectionReader& connection) override
129  {
130  return (connection.isBareMode() ? readBare(connection)
131  : readBottle(connection));
132  }
133 
134  bool writeBare(yarp::os::ConnectionWriter& connection) const override
135  {
136  // *** header ***
137  if (!header.write(connection)) {
138  return false;
139  }
140 
141  // *** joint_names ***
142  connection.appendInt32(joint_names.size());
143  for (size_t i=0; i<joint_names.size(); i++) {
144  connection.appendInt32(joint_names[i].length());
145  connection.appendExternalBlock((char*)joint_names[i].c_str(), joint_names[i].length());
146  }
147 
148  // *** points ***
149  connection.appendInt32(points.size());
150  for (size_t i=0; i<points.size(); i++) {
151  if (!points[i].write(connection)) {
152  return false;
153  }
154  }
155 
156  return !connection.isError();
157  }
158 
159  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
160  {
161  connection.appendInt32(BOTTLE_TAG_LIST);
162  connection.appendInt32(3);
163 
164  // *** header ***
165  if (!header.write(connection)) {
166  return false;
167  }
168 
169  // *** joint_names ***
171  connection.appendInt32(joint_names.size());
172  for (size_t i=0; i<joint_names.size(); i++) {
173  connection.appendInt32(joint_names[i].length());
174  connection.appendExternalBlock((char*)joint_names[i].c_str(), joint_names[i].length());
175  }
176 
177  // *** points ***
178  connection.appendInt32(BOTTLE_TAG_LIST);
179  connection.appendInt32(points.size());
180  for (size_t i=0; i<points.size(); i++) {
181  if (!points[i].write(connection)) {
182  return false;
183  }
184  }
185 
186  connection.convertTextMode();
187  return !connection.isError();
188  }
189 
191  bool write(yarp::os::ConnectionWriter& connection) const override
192  {
193  return (connection.isBareMode() ? writeBare(connection)
194  : writeBottle(connection));
195  }
196 
197  // This class will serialize ROS style or YARP style depending on protocol.
198  // If you need to force a serialization style, use one of these classes:
201 
202  // The name for this message, ROS will need this
203  static constexpr const char* typeName = "trajectory_msgs/JointTrajectory";
204 
205  // The checksum for this message, ROS will need this
206  static constexpr const char* typeChecksum = "65b4f94a94d1ed67169da35a02f33d3f";
207 
208  // The source text for this message, ROS will need this
209  static constexpr const char* typeText = "\
210 Header header\n\
211 string[] joint_names\n\
212 JointTrajectoryPoint[] points\n\
213 ================================================================================\n\
214 MSG: std_msgs/Header\n\
215 # Standard metadata for higher-level stamped data types.\n\
216 # This is generally used to communicate timestamped data \n\
217 # in a particular coordinate frame.\n\
218 # \n\
219 # sequence ID: consecutively increasing ID \n\
220 uint32 seq\n\
221 #Two-integer timestamp that is expressed as:\n\
222 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
223 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
224 # time-handling sugar is provided by the client library\n\
225 time stamp\n\
226 #Frame this data is associated with\n\
227 # 0: no frame\n\
228 # 1: global frame\n\
229 string frame_id\n\
230 \n\
231 ================================================================================\n\
232 MSG: trajectory_msgs/JointTrajectoryPoint\n\
233 # Each trajectory point specifies either positions[, velocities[, accelerations]]\n\
234 # or positions[, effort] for the trajectory to be executed.\n\
235 # All specified values are in the same order as the joint names in JointTrajectory.msg\n\
236 \n\
237 float64[] positions\n\
238 float64[] velocities\n\
239 float64[] accelerations\n\
240 float64[] effort\n\
241 duration time_from_start\n\
242 ";
243 
244  yarp::os::Type getType() const override
245  {
247  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
248  typ.addProperty("message_definition", yarp::os::Value(typeText));
249  return typ;
250  }
251 };
252 
253 } // namespace trajectory_msgs
254 } // namespace rosmsg
255 } // namespace yarp
256 
257 #endif // YARP_ROSMSG_trajectory_msgs_JointTrajectory_h
#define BOTTLE_TAG_STRING
Definition: Bottle.h:26
#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
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.
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 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
std::vector< yarp::rosmsg::trajectory_msgs::JointTrajectoryPoint > points
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
bool writeBare(yarp::os::ConnectionWriter &connection) const override
bool readBottle(yarp::os::ConnectionReader &connection) override
bool readBare(yarp::os::ConnectionReader &connection) override
yarp::os::idl::BottleStyle< yarp::rosmsg::trajectory_msgs::JointTrajectory > bottleStyle
static constexpr const char * typeChecksum
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
yarp::os::idl::BareStyle< yarp::rosmsg::trajectory_msgs::JointTrajectory > rosStyle
yarp::os::Type getType() const override
The main, catch-all namespace for YARP.
Definition: dirs.h:16