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