YARP
Yet Another Robot Platform
JoyFeedbackArray.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 "sensor_msgs/JoyFeedbackArray" msg definition:
12 // # This message publishes values for multiple feedback at once.
13 // JoyFeedback[] array// Instances of this class can be read and written with YARP ports,
14 // using a ROS-compatible format.
15 
16 #ifndef YARP_ROSMSG_sensor_msgs_JoyFeedbackArray_h
17 #define YARP_ROSMSG_sensor_msgs_JoyFeedbackArray_h
18 
19 #include <yarp/os/Wire.h>
20 #include <yarp/os/Type.h>
21 #include <yarp/os/idl/WireTypes.h>
22 #include <string>
23 #include <vector>
25 
26 namespace yarp {
27 namespace rosmsg {
28 namespace sensor_msgs {
29 
31 {
32 public:
33  std::vector<yarp::rosmsg::sensor_msgs::JoyFeedback> array;
34 
36  array()
37  {
38  }
39 
40  void clear()
41  {
42  // *** array ***
43  array.clear();
44  }
45 
46  bool readBare(yarp::os::ConnectionReader& connection) override
47  {
48  // *** array ***
49  int len = connection.expectInt32();
50  array.resize(len);
51  for (int i=0; i<len; i++) {
52  if (!array[i].read(connection)) {
53  return false;
54  }
55  }
56 
57  return !connection.isError();
58  }
59 
60  bool readBottle(yarp::os::ConnectionReader& connection) override
61  {
62  connection.convertTextMode();
63  yarp::os::idl::WireReader reader(connection);
64  if (!reader.readListHeader(1)) {
65  return false;
66  }
67 
68  // *** array ***
69  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
70  return false;
71  }
72  int len = connection.expectInt32();
73  array.resize(len);
74  for (int i=0; i<len; i++) {
75  if (!array[i].read(connection)) {
76  return false;
77  }
78  }
79 
80  return !connection.isError();
81  }
82 
84  bool read(yarp::os::ConnectionReader& connection) override
85  {
86  return (connection.isBareMode() ? readBare(connection)
87  : readBottle(connection));
88  }
89 
90  bool writeBare(yarp::os::ConnectionWriter& connection) const override
91  {
92  // *** array ***
93  connection.appendInt32(array.size());
94  for (size_t i=0; i<array.size(); i++) {
95  if (!array[i].write(connection)) {
96  return false;
97  }
98  }
99 
100  return !connection.isError();
101  }
102 
103  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
104  {
105  connection.appendInt32(BOTTLE_TAG_LIST);
106  connection.appendInt32(1);
107 
108  // *** array ***
109  connection.appendInt32(BOTTLE_TAG_LIST);
110  connection.appendInt32(array.size());
111  for (size_t i=0; i<array.size(); i++) {
112  if (!array[i].write(connection)) {
113  return false;
114  }
115  }
116 
117  connection.convertTextMode();
118  return !connection.isError();
119  }
120 
122  bool write(yarp::os::ConnectionWriter& connection) const override
123  {
124  return (connection.isBareMode() ? writeBare(connection)
125  : writeBottle(connection));
126  }
127 
128  // This class will serialize ROS style or YARP style depending on protocol.
129  // If you need to force a serialization style, use one of these classes:
132 
133  // The name for this message, ROS will need this
134  static constexpr const char* typeName = "sensor_msgs/JoyFeedbackArray";
135 
136  // The checksum for this message, ROS will need this
137  static constexpr const char* typeChecksum = "cde5730a895b1fc4dee6f91b754b213d";
138 
139  // The source text for this message, ROS will need this
140  static constexpr const char* typeText = "\
141 # This message publishes values for multiple feedback at once. \n\
142 JoyFeedback[] array\n\
143 ================================================================================\n\
144 MSG: sensor_msgs/JoyFeedback\n\
145 # Declare of the type of feedback\n\
146 uint8 TYPE_LED = 0\n\
147 uint8 TYPE_RUMBLE = 1\n\
148 uint8 TYPE_BUZZER = 2\n\
149 \n\
150 uint8 type\n\
151 \n\
152 # This will hold an id number for each type of each feedback.\n\
153 # Example, the first led would be id=0, the second would be id=1\n\
154 uint8 id\n\
155 \n\
156 # Intensity of the feedback, from 0.0 to 1.0, inclusive. If device is\n\
157 # actually binary, driver should treat 0<=x<0.5 as off, 0.5<=x<=1 as on.\n\
158 float32 intensity\n\
159 \n\
160 ";
161 
162  yarp::os::Type getType() const override
163  {
165  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
166  typ.addProperty("message_definition", yarp::os::Value(typeText));
167  return typ;
168  }
169 };
170 
171 } // namespace sensor_msgs
172 } // namespace rosmsg
173 } // namespace yarp
174 
175 #endif // YARP_ROSMSG_sensor_msgs_JoyFeedbackArray_h
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
JoyFeedback.h
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::os::ConnectionReader::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
Wire.h
yarp::rosmsg::sensor_msgs::JoyFeedbackArray::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: JoyFeedbackArray.h:46
yarp::rosmsg::sensor_msgs::JoyFeedbackArray::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::JoyFeedbackArray > bottleStyle
Definition: JoyFeedbackArray.h:131
yarp::rosmsg::sensor_msgs::JoyFeedbackArray
Definition: JoyFeedbackArray.h:31
yarp::rosmsg::sensor_msgs::JoyFeedbackArray::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: JoyFeedbackArray.h:60
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
yarp::rosmsg::sensor_msgs::JoyFeedbackArray::array
std::vector< yarp::rosmsg::sensor_msgs::JoyFeedback > array
Definition: JoyFeedbackArray.h:33
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::sensor_msgs::JoyFeedbackArray::clear
void clear()
Definition: JoyFeedbackArray.h:40
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::rosmsg::sensor_msgs::JoyFeedbackArray::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: JoyFeedbackArray.h:90
yarp::rosmsg::sensor_msgs::JoyFeedbackArray::typeText
static constexpr const char * typeText
Definition: JoyFeedbackArray.h:140
yarp::os::ConnectionReader::isError
virtual bool isError() const =0
yarp::rosmsg::sensor_msgs::JoyFeedbackArray::typeChecksum
static constexpr const char * typeChecksum
Definition: JoyFeedbackArray.h:137
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::sensor_msgs::JoyFeedbackArray::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: JoyFeedbackArray.h:122
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::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::os::idl::BareStyle
Definition: BareStyle.h:22
yarp::rosmsg::sensor_msgs::JoyFeedbackArray::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: JoyFeedbackArray.h:84
yarp::rosmsg::sensor_msgs::JoyFeedbackArray::getType
yarp::os::Type getType() const override
Definition: JoyFeedbackArray.h:162
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::rosmsg::sensor_msgs::JoyFeedbackArray::JoyFeedbackArray
JoyFeedbackArray()
Definition: JoyFeedbackArray.h:35
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
sensor_msgs
Definition: BatteryState.h:22
yarp::rosmsg::sensor_msgs::JoyFeedbackArray::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::JoyFeedbackArray > rosStyle
Definition: JoyFeedbackArray.h:130
yarp::rosmsg::sensor_msgs::JoyFeedbackArray::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: JoyFeedbackArray.h:103
yarp::rosmsg::sensor_msgs::JoyFeedbackArray::typeName
static constexpr const char * typeName
Definition: JoyFeedbackArray.h:134
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