YARP
Yet Another Robot Platform
JoyFeedbackArray.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2018 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  {
164  yarp::os::Type typ = yarp::os::Type::byName(typeName, typeName);
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
static constexpr const char * typeText
static Type byName(const char *name)
Definition: Type.cpp:179
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:141
virtual bool isError() const =0
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
The main, catch-all namespace for YARP.
Definition: numeric.h:47
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary...
virtual bool isBareMode() const =0
Check if the connection is bare mode.
static constexpr const char * typeChecksum
An interface for writing to a network connection.
virtual bool write(const yarp::os::idl::WireWriter &writer) const
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
virtual bool read(yarp::os::idl::WireReader &reader)
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::JoyFeedbackArray > bottleStyle
virtual bool isError() const =0
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool writeBare(yarp::os::ConnectionWriter &connection) const override
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::JoyFeedbackArray > rosStyle
std::vector< yarp::rosmsg::sensor_msgs::JoyFeedback > array
yarp::os::Type getType() const override
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:30
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
An interface for reading from a network connection.
bool readBare(yarp::os::ConnectionReader &connection) override
static constexpr const char * typeName
A single value (typically within a Bottle).
Definition: Value.h:40
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
bool readBottle(yarp::os::ConnectionReader &connection) override
IDL-friendly connection reader.
Definition: WireReader.h:37