YARP
Yet Another Robot Platform
TwistWithCovariance.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 "geometry_msgs/TwistWithCovariance" msg definition:
12 // # This expresses velocity in free space with uncertainty.
13 //
14 // Twist twist
15 //
16 // # Row-major representation of the 6x6 covariance matrix
17 // # The orientation parameters use a fixed-axis representation.
18 // # In order, the parameters are:
19 // # (x, y, z, rotation about X axis, rotation about Y axis, rotation about Z axis)
20 // float64[36] covariance
21 // Instances of this class can be read and written with YARP ports,
22 // using a ROS-compatible format.
23 
24 #ifndef YARP_ROSMSG_geometry_msgs_TwistWithCovariance_h
25 #define YARP_ROSMSG_geometry_msgs_TwistWithCovariance_h
26 
27 #include <yarp/os/Wire.h>
28 #include <yarp/os/Type.h>
29 #include <yarp/os/idl/WireTypes.h>
30 #include <string>
31 #include <vector>
33 
34 namespace yarp {
35 namespace rosmsg {
36 namespace geometry_msgs {
37 
39 {
40 public:
42  std::vector<yarp::conf::float64_t> covariance;
43 
45  twist(),
46  covariance()
47  {
48  covariance.resize(36, 0.0);
49  }
50 
51  void clear()
52  {
53  // *** twist ***
54  twist.clear();
55 
56  // *** covariance ***
57  covariance.clear();
58  covariance.resize(36, 0.0);
59  }
60 
61  bool readBare(yarp::os::ConnectionReader& connection) override
62  {
63  // *** twist ***
64  if (!twist.read(connection)) {
65  return false;
66  }
67 
68  // *** covariance ***
69  int len = 36;
70  covariance.resize(len);
71  if (len > 0 && !connection.expectBlock((char*)&covariance[0], sizeof(yarp::conf::float64_t)*len)) {
72  return false;
73  }
74 
75  return !connection.isError();
76  }
77 
78  bool readBottle(yarp::os::ConnectionReader& connection) override
79  {
80  connection.convertTextMode();
81  yarp::os::idl::WireReader reader(connection);
82  if (!reader.readListHeader(2)) {
83  return false;
84  }
85 
86  // *** twist ***
87  if (!twist.read(connection)) {
88  return false;
89  }
90 
91  // *** covariance ***
92  if (connection.expectInt32() != (BOTTLE_TAG_LIST|BOTTLE_TAG_FLOAT64)) {
93  return false;
94  }
95  int len = connection.expectInt32();
96  covariance.resize(len);
97  for (int i=0; i<len; i++) {
99  }
100 
101  return !connection.isError();
102  }
103 
105  bool read(yarp::os::ConnectionReader& connection) override
106  {
107  return (connection.isBareMode() ? readBare(connection)
108  : readBottle(connection));
109  }
110 
111  bool writeBare(yarp::os::ConnectionWriter& connection) const override
112  {
113  // *** twist ***
114  if (!twist.write(connection)) {
115  return false;
116  }
117 
118  // *** covariance ***
119  if (covariance.size()>0) {
120  connection.appendExternalBlock((char*)&covariance[0], sizeof(yarp::conf::float64_t)*covariance.size());
121  }
122 
123  return !connection.isError();
124  }
125 
126  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
127  {
128  connection.appendInt32(BOTTLE_TAG_LIST);
129  connection.appendInt32(2);
130 
131  // *** twist ***
132  if (!twist.write(connection)) {
133  return false;
134  }
135 
136  // *** covariance ***
138  connection.appendInt32(covariance.size());
139  for (size_t i=0; i<covariance.size(); i++) {
140  connection.appendFloat64(covariance[i]);
141  }
142 
143  connection.convertTextMode();
144  return !connection.isError();
145  }
146 
148  bool write(yarp::os::ConnectionWriter& connection) const override
149  {
150  return (connection.isBareMode() ? writeBare(connection)
151  : writeBottle(connection));
152  }
153 
154  // This class will serialize ROS style or YARP style depending on protocol.
155  // If you need to force a serialization style, use one of these classes:
158 
159  // The name for this message, ROS will need this
160  static constexpr const char* typeName = "geometry_msgs/TwistWithCovariance";
161 
162  // The checksum for this message, ROS will need this
163  static constexpr const char* typeChecksum = "1fe8a28e6890a4cc3ae4c3ca5c7d82e6";
164 
165  // The source text for this message, ROS will need this
166  static constexpr const char* typeText = "\
167 # This expresses velocity in free space with uncertainty.\n\
168 \n\
169 Twist twist\n\
170 \n\
171 # Row-major representation of the 6x6 covariance matrix\n\
172 # The orientation parameters use a fixed-axis representation.\n\
173 # In order, the parameters are:\n\
174 # (x, y, z, rotation about X axis, rotation about Y axis, rotation about Z axis)\n\
175 float64[36] covariance\n\
176 \n\
177 ================================================================================\n\
178 MSG: geometry_msgs/Twist\n\
179 # This expresses velocity in free space broken into its linear and angular parts.\n\
180 Vector3 linear\n\
181 Vector3 angular\n\
182 \n\
183 ================================================================================\n\
184 MSG: geometry_msgs/Vector3\n\
185 # This represents a vector in free space. \n\
186 # It is only meant to represent a direction. Therefore, it does not\n\
187 # make sense to apply a translation to it (e.g., when applying a \n\
188 # generic rigid transformation to a Vector3, tf2 will only apply the\n\
189 # rotation). If you want your data to be translatable too, use the\n\
190 # geometry_msgs/Point message instead.\n\
191 \n\
192 float64 x\n\
193 float64 y\n\
194 float64 z\n\
195 ";
196 
197  yarp::os::Type getType() const override
198  {
200  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
201  typ.addProperty("message_definition", yarp::os::Value(typeText));
202  return typ;
203  }
204 };
205 
206 } // namespace geometry_msgs
207 } // namespace rosmsg
208 } // namespace yarp
209 
210 #endif // YARP_ROSMSG_geometry_msgs_TwistWithCovariance_h
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::rosmsg::geometry_msgs::TwistWithCovariance::twist
yarp::rosmsg::geometry_msgs::Twist twist
Definition: TwistWithCovariance.h:41
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::rosmsg::geometry_msgs::TwistWithCovariance
Definition: TwistWithCovariance.h:39
yarp::os::ConnectionReader::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
Wire.h
geometry_msgs
Definition: Accel.h:22
yarp::rosmsg::geometry_msgs::Twist::clear
void clear()
Definition: Twist.h:44
yarp::rosmsg::geometry_msgs::Twist::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Twist.h:131
yarp::rosmsg::geometry_msgs::TwistWithCovariance::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: TwistWithCovariance.h:61
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::geometry_msgs::TwistWithCovariance::TwistWithCovariance
TwistWithCovariance()
Definition: TwistWithCovariance.h:44
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::os::ConnectionReader::isError
virtual bool isError() const =0
yarp::rosmsg::geometry_msgs::Twist
Definition: Twist.h:33
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::geometry_msgs::TwistWithCovariance::getType
yarp::os::Type getType() const override
Definition: TwistWithCovariance.h:197
yarp::rosmsg::geometry_msgs::TwistWithCovariance::typeChecksum
static constexpr const char * typeChecksum
Definition: TwistWithCovariance.h:163
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::geometry_msgs::TwistWithCovariance::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: TwistWithCovariance.h:105
yarp::rosmsg::geometry_msgs::TwistWithCovariance::typeText
static constexpr const char * typeText
Definition: TwistWithCovariance.h:166
Twist.h
yarp::rosmsg::geometry_msgs::TwistWithCovariance::covariance
std::vector< yarp::conf::float64_t > covariance
Definition: TwistWithCovariance.h:42
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::geometry_msgs::TwistWithCovariance::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: TwistWithCovariance.h:111
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::rosmsg::geometry_msgs::TwistWithCovariance::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::geometry_msgs::TwistWithCovariance > rosStyle
Definition: TwistWithCovariance.h:156
BOTTLE_TAG_FLOAT64
#define BOTTLE_TAG_FLOAT64
Definition: Bottle.h:27
yarp::rosmsg::geometry_msgs::TwistWithCovariance::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: TwistWithCovariance.h:148
yarp::rosmsg::geometry_msgs::TwistWithCovariance::typeName
static constexpr const char * typeName
Definition: TwistWithCovariance.h:160
yarp::rosmsg::geometry_msgs::TwistWithCovariance::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::geometry_msgs::TwistWithCovariance > bottleStyle
Definition: TwistWithCovariance.h:157
yarp::rosmsg::geometry_msgs::TwistWithCovariance::clear
void clear()
Definition: TwistWithCovariance.h:51
yarp::rosmsg::geometry_msgs::TwistWithCovariance::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: TwistWithCovariance.h:126
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::rosmsg::geometry_msgs::Twist::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Twist.h:90
yarp::conf::float64_t
double float64_t
Definition: numeric.h:51
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::geometry_msgs::TwistWithCovariance::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: TwistWithCovariance.h:78
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