YARP
Yet Another Robot Platform
MultiDOFJointTrajectory.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 "trajectory_msgs/MultiDOFJointTrajectory" msg definition:
12 // # The header is used to specify the coordinate frame and the reference time for the trajectory durations
13 // Header header
14 //
15 // # A representation of a multi-dof joint trajectory (each point is a transformation)
16 // # Each point along the trajectory will include an array of positions/velocities/accelerations
17 // # that has the same length as the array of joint names, and has the same order of joints as
18 // # the joint names array.
19 //
20 // string[] joint_names
21 // MultiDOFJointTrajectoryPoint[] points
22 // Instances of this class can be read and written with YARP ports,
23 // using a ROS-compatible format.
24 
25 #ifndef YARP_ROSMSG_trajectory_msgs_MultiDOFJointTrajectory_h
26 #define YARP_ROSMSG_trajectory_msgs_MultiDOFJointTrajectory_h
27 
28 #include <yarp/os/Wire.h>
29 #include <yarp/os/Type.h>
30 #include <yarp/os/idl/WireTypes.h>
31 #include <string>
32 #include <vector>
35 
36 namespace yarp {
37 namespace rosmsg {
38 namespace trajectory_msgs {
39 
41 {
42 public:
44  std::vector<std::string> joint_names;
45  std::vector<yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectoryPoint> points;
46 
48  header(),
49  joint_names(),
50  points()
51  {
52  }
53 
54  void clear()
55  {
56  // *** header ***
57  header.clear();
58 
59  // *** joint_names ***
60  joint_names.clear();
61 
62  // *** points ***
63  points.clear();
64  }
65 
66  bool readBare(yarp::os::ConnectionReader& connection) override
67  {
68  // *** header ***
69  if (!header.read(connection)) {
70  return false;
71  }
72 
73  // *** joint_names ***
74  int len = connection.expectInt32();
75  joint_names.resize(len);
76  for (int i=0; i<len; i++) {
77  int len2 = connection.expectInt32();
78  joint_names[i].resize(len2);
79  if (!connection.expectBlock((char*)joint_names[i].c_str(), len2)) {
80  return false;
81  }
82  }
83 
84  // *** points ***
85  len = connection.expectInt32();
86  points.resize(len);
87  for (int i=0; i<len; i++) {
88  if (!points[i].read(connection)) {
89  return false;
90  }
91  }
92 
93  return !connection.isError();
94  }
95 
96  bool readBottle(yarp::os::ConnectionReader& connection) override
97  {
98  connection.convertTextMode();
99  yarp::os::idl::WireReader reader(connection);
100  if (!reader.readListHeader(3)) {
101  return false;
102  }
103 
104  // *** header ***
105  if (!header.read(connection)) {
106  return false;
107  }
108 
109  // *** joint_names ***
110  if (connection.expectInt32() != (BOTTLE_TAG_LIST|BOTTLE_TAG_STRING)) {
111  return false;
112  }
113  int len = connection.expectInt32();
114  joint_names.resize(len);
115  for (int i=0; i<len; i++) {
116  int len2 = connection.expectInt32();
117  joint_names[i].resize(len2);
118  if (!connection.expectBlock((char*)joint_names[i].c_str(), len2)) {
119  return false;
120  }
121  }
122 
123  // *** points ***
124  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
125  return false;
126  }
127  len = connection.expectInt32();
128  points.resize(len);
129  for (int i=0; i<len; i++) {
130  if (!points[i].read(connection)) {
131  return false;
132  }
133  }
134 
135  return !connection.isError();
136  }
137 
139  bool read(yarp::os::ConnectionReader& connection) override
140  {
141  return (connection.isBareMode() ? readBare(connection)
142  : readBottle(connection));
143  }
144 
145  bool writeBare(yarp::os::ConnectionWriter& connection) const override
146  {
147  // *** header ***
148  if (!header.write(connection)) {
149  return false;
150  }
151 
152  // *** joint_names ***
153  connection.appendInt32(joint_names.size());
154  for (size_t i=0; i<joint_names.size(); i++) {
155  connection.appendInt32(joint_names[i].length());
156  connection.appendExternalBlock((char*)joint_names[i].c_str(), joint_names[i].length());
157  }
158 
159  // *** points ***
160  connection.appendInt32(points.size());
161  for (size_t i=0; i<points.size(); i++) {
162  if (!points[i].write(connection)) {
163  return false;
164  }
165  }
166 
167  return !connection.isError();
168  }
169 
170  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
171  {
172  connection.appendInt32(BOTTLE_TAG_LIST);
173  connection.appendInt32(3);
174 
175  // *** header ***
176  if (!header.write(connection)) {
177  return false;
178  }
179 
180  // *** joint_names ***
182  connection.appendInt32(joint_names.size());
183  for (size_t i=0; i<joint_names.size(); i++) {
184  connection.appendInt32(joint_names[i].length());
185  connection.appendExternalBlock((char*)joint_names[i].c_str(), joint_names[i].length());
186  }
187 
188  // *** points ***
189  connection.appendInt32(BOTTLE_TAG_LIST);
190  connection.appendInt32(points.size());
191  for (size_t i=0; i<points.size(); i++) {
192  if (!points[i].write(connection)) {
193  return false;
194  }
195  }
196 
197  connection.convertTextMode();
198  return !connection.isError();
199  }
200 
202  bool write(yarp::os::ConnectionWriter& connection) const override
203  {
204  return (connection.isBareMode() ? writeBare(connection)
205  : writeBottle(connection));
206  }
207 
208  // This class will serialize ROS style or YARP style depending on protocol.
209  // If you need to force a serialization style, use one of these classes:
212 
213  // The name for this message, ROS will need this
214  static constexpr const char* typeName = "trajectory_msgs/MultiDOFJointTrajectory";
215 
216  // The checksum for this message, ROS will need this
217  static constexpr const char* typeChecksum = "ef145a45a5f47b77b7f5cdde4b16c942";
218 
219  // The source text for this message, ROS will need this
220  static constexpr const char* typeText = "\
221 # The header is used to specify the coordinate frame and the reference time for the trajectory durations\n\
222 Header header\n\
223 \n\
224 # A representation of a multi-dof joint trajectory (each point is a transformation)\n\
225 # Each point along the trajectory will include an array of positions/velocities/accelerations\n\
226 # that has the same length as the array of joint names, and has the same order of joints as \n\
227 # the joint names array.\n\
228 \n\
229 string[] joint_names\n\
230 MultiDOFJointTrajectoryPoint[] points\n\
231 \n\
232 ================================================================================\n\
233 MSG: std_msgs/Header\n\
234 # Standard metadata for higher-level stamped data types.\n\
235 # This is generally used to communicate timestamped data \n\
236 # in a particular coordinate frame.\n\
237 # \n\
238 # sequence ID: consecutively increasing ID \n\
239 uint32 seq\n\
240 #Two-integer timestamp that is expressed as:\n\
241 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
242 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
243 # time-handling sugar is provided by the client library\n\
244 time stamp\n\
245 #Frame this data is associated with\n\
246 # 0: no frame\n\
247 # 1: global frame\n\
248 string frame_id\n\
249 \n\
250 ================================================================================\n\
251 MSG: trajectory_msgs/MultiDOFJointTrajectoryPoint\n\
252 # Each multi-dof joint can specify a transform (up to 6 DOF)\n\
253 geometry_msgs/Transform[] transforms\n\
254 \n\
255 # There can be a velocity specified for the origin of the joint \n\
256 geometry_msgs/Twist[] velocities\n\
257 \n\
258 # There can be an acceleration specified for the origin of the joint \n\
259 geometry_msgs/Twist[] accelerations\n\
260 \n\
261 duration time_from_start\n\
262 \n\
263 ================================================================================\n\
264 MSG: geometry_msgs/Transform\n\
265 # This represents the transform between two coordinate frames in free space.\n\
266 \n\
267 Vector3 translation\n\
268 Quaternion rotation\n\
269 \n\
270 ================================================================================\n\
271 MSG: geometry_msgs/Vector3\n\
272 # This represents a vector in free space. \n\
273 # It is only meant to represent a direction. Therefore, it does not\n\
274 # make sense to apply a translation to it (e.g., when applying a \n\
275 # generic rigid transformation to a Vector3, tf2 will only apply the\n\
276 # rotation). If you want your data to be translatable too, use the\n\
277 # geometry_msgs/Point message instead.\n\
278 \n\
279 float64 x\n\
280 float64 y\n\
281 float64 z\n\
282 ================================================================================\n\
283 MSG: geometry_msgs/Quaternion\n\
284 # This represents an orientation in free space in quaternion form.\n\
285 \n\
286 float64 x\n\
287 float64 y\n\
288 float64 z\n\
289 float64 w\n\
290 \n\
291 ================================================================================\n\
292 MSG: geometry_msgs/Twist\n\
293 # This expresses velocity in free space broken into its linear and angular parts.\n\
294 Vector3 linear\n\
295 Vector3 angular\n\
296 ";
297 
298  yarp::os::Type getType() const override
299  {
301  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
302  typ.addProperty("message_definition", yarp::os::Value(typeText));
303  return typ;
304  }
305 };
306 
307 } // namespace trajectory_msgs
308 } // namespace rosmsg
309 } // namespace yarp
310 
311 #endif // YARP_ROSMSG_trajectory_msgs_MultiDOFJointTrajectory_h
yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectory::MultiDOFJointTrajectory
MultiDOFJointTrajectory()
Definition: MultiDOFJointTrajectory.h:47
yarp::rosmsg::std_msgs::Header::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Header.h:115
MultiDOFJointTrajectoryPoint.h
yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectory::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: MultiDOFJointTrajectory.h:170
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectory::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectory > rosStyle
Definition: MultiDOFJointTrajectory.h:210
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
Header.h
yarp::os::ConnectionReader::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
yarp::rosmsg::std_msgs::Header::clear
void clear()
Definition: Header.h:58
BOTTLE_TAG_STRING
#define BOTTLE_TAG_STRING
Definition: Bottle.h:28
Wire.h
yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectory::typeChecksum
static constexpr const char * typeChecksum
Definition: MultiDOFJointTrajectory.h:217
yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectory::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: MultiDOFJointTrajectory.h:96
yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectory::header
yarp::rosmsg::std_msgs::Header header
Definition: MultiDOFJointTrajectory.h:43
yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectory::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: MultiDOFJointTrajectory.h:145
yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectory::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: MultiDOFJointTrajectory.h:66
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectory::joint_names
std::vector< std::string > joint_names
Definition: MultiDOFJointTrajectory.h:44
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::trajectory_msgs::MultiDOFJointTrajectory::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectory > bottleStyle
Definition: MultiDOFJointTrajectory.h:211
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectory::clear
void clear()
Definition: MultiDOFJointTrajectory.h:54
yarp::os::ConnectionReader::isError
virtual bool isError() const =0
yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectory::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: MultiDOFJointTrajectory.h:202
yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectory::getType
yarp::os::Type getType() const override
Definition: MultiDOFJointTrajectory.h:298
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::rosmsg::trajectory_msgs::MultiDOFJointTrajectory::typeText
static constexpr const char * typeText
Definition: MultiDOFJointTrajectory.h:220
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::rosmsg::std_msgs::Header::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Header.h:162
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::rosmsg::trajectory_msgs::MultiDOFJointTrajectory
Definition: MultiDOFJointTrajectory.h:41
yarp::os::idl::BareStyle
Definition: BareStyle.h:22
yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectory::typeName
static constexpr const char * typeName
Definition: MultiDOFJointTrajectory.h:214
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectory::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: MultiDOFJointTrajectory.h:139
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.
trajectory_msgs
Definition: JointTrajectory.h:22
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::trajectory_msgs::MultiDOFJointTrajectory::points
std::vector< yarp::rosmsg::trajectory_msgs::MultiDOFJointTrajectoryPoint > points
Definition: MultiDOFJointTrajectory.h:45
yarp::rosmsg::std_msgs::Header
Definition: Header.h:45
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