YARP
Yet Another Robot Platform
JoyFeedback.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 // This is an automatically generated file.
7 
8 // Generated from the following "sensor_msgs/JoyFeedback" msg definition:
9 // # Declare of the type of feedback
10 // uint8 TYPE_LED = 0
11 // uint8 TYPE_RUMBLE = 1
12 // uint8 TYPE_BUZZER = 2
13 //
14 // uint8 type
15 //
16 // # This will hold an id number for each type of each feedback.
17 // # Example, the first led would be id=0, the second would be id=1
18 // uint8 id
19 //
20 // # Intensity of the feedback, from 0.0 to 1.0, inclusive. If device is
21 // # actually binary, driver should treat 0<=x<0.5 as off, 0.5<=x<=1 as on.
22 // float32 intensity
23 //
24 // Instances of this class can be read and written with YARP ports,
25 // using a ROS-compatible format.
26 
27 #ifndef YARP_ROSMSG_sensor_msgs_JoyFeedback_h
28 #define YARP_ROSMSG_sensor_msgs_JoyFeedback_h
29 
30 #include <yarp/os/Wire.h>
31 #include <yarp/os/Type.h>
32 #include <yarp/os/idl/WireTypes.h>
33 #include <string>
34 #include <vector>
35 
36 namespace yarp {
37 namespace rosmsg {
38 namespace sensor_msgs {
39 
41 {
42 public:
43  static const std::uint8_t TYPE_LED = 0;
44  static const std::uint8_t TYPE_RUMBLE = 1;
45  static const std::uint8_t TYPE_BUZZER = 2;
46  std::uint8_t type;
47  std::uint8_t id;
49 
51  type(0),
52  id(0),
53  intensity(0.0f)
54  {
55  }
56 
57  void clear()
58  {
59  // *** TYPE_LED ***
60 
61  // *** TYPE_RUMBLE ***
62 
63  // *** TYPE_BUZZER ***
64 
65  // *** type ***
66  type = 0;
67 
68  // *** id ***
69  id = 0;
70 
71  // *** intensity ***
72  intensity = 0.0f;
73  }
74 
75  bool readBare(yarp::os::ConnectionReader& connection) override
76  {
77  // *** type ***
78  type = connection.expectInt8();
79 
80  // *** id ***
81  id = connection.expectInt8();
82 
83  // *** intensity ***
84  intensity = connection.expectFloat32();
85 
86  return !connection.isError();
87  }
88 
89  bool readBottle(yarp::os::ConnectionReader& connection) override
90  {
91  connection.convertTextMode();
92  yarp::os::idl::WireReader reader(connection);
93  if (!reader.readListHeader(6)) {
94  return false;
95  }
96 
97  // *** type ***
98  type = reader.expectInt8();
99 
100  // *** id ***
101  id = reader.expectInt8();
102 
103  // *** intensity ***
104  intensity = reader.expectFloat32();
105 
106  return !connection.isError();
107  }
108 
110  bool read(yarp::os::ConnectionReader& connection) override
111  {
112  return (connection.isBareMode() ? readBare(connection)
113  : readBottle(connection));
114  }
115 
116  bool writeBare(yarp::os::ConnectionWriter& connection) const override
117  {
118  // *** type ***
119  connection.appendInt8(type);
120 
121  // *** id ***
122  connection.appendInt8(id);
123 
124  // *** intensity ***
125  connection.appendFloat32(intensity);
126 
127  return !connection.isError();
128  }
129 
130  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
131  {
132  connection.appendInt32(BOTTLE_TAG_LIST);
133  connection.appendInt32(6);
134 
135  // *** type ***
136  connection.appendInt32(BOTTLE_TAG_INT8);
137  connection.appendInt8(type);
138 
139  // *** id ***
140  connection.appendInt32(BOTTLE_TAG_INT8);
141  connection.appendInt8(id);
142 
143  // *** intensity ***
144  connection.appendInt32(BOTTLE_TAG_FLOAT32);
145  connection.appendFloat32(intensity);
146 
147  connection.convertTextMode();
148  return !connection.isError();
149  }
150 
152  bool write(yarp::os::ConnectionWriter& connection) const override
153  {
154  return (connection.isBareMode() ? writeBare(connection)
155  : writeBottle(connection));
156  }
157 
158  // This class will serialize ROS style or YARP style depending on protocol.
159  // If you need to force a serialization style, use one of these classes:
162 
163  // The name for this message, ROS will need this
164  static constexpr const char* typeName = "sensor_msgs/JoyFeedback";
165 
166  // The checksum for this message, ROS will need this
167  static constexpr const char* typeChecksum = "f4dcd73460360d98f36e55ee7f2e46f1";
168 
169  // The source text for this message, ROS will need this
170  static constexpr const char* typeText = "\
171 # Declare of the type of feedback\n\
172 uint8 TYPE_LED = 0\n\
173 uint8 TYPE_RUMBLE = 1\n\
174 uint8 TYPE_BUZZER = 2\n\
175 \n\
176 uint8 type\n\
177 \n\
178 # This will hold an id number for each type of each feedback.\n\
179 # Example, the first led would be id=0, the second would be id=1\n\
180 uint8 id\n\
181 \n\
182 # Intensity of the feedback, from 0.0 to 1.0, inclusive. If device is\n\
183 # actually binary, driver should treat 0<=x<0.5 as off, 0.5<=x<=1 as on.\n\
184 float32 intensity\n\
185 \n\
186 ";
187 
188  yarp::os::Type getType() const override
189  {
191  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
192  typ.addProperty("message_definition", yarp::os::Value(typeText));
193  return typ;
194  }
195 };
196 
197 } // namespace sensor_msgs
198 } // namespace rosmsg
199 } // namespace yarp
200 
201 #endif // YARP_ROSMSG_sensor_msgs_JoyFeedback_h
#define BOTTLE_TAG_INT8
Definition: Bottle.h:19
#define BOTTLE_TAG_LIST
Definition: Bottle.h:28
#define BOTTLE_TAG_FLOAT32
Definition: Bottle.h:24
An interface for reading from a network connection.
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
virtual yarp::conf::float32_t expectFloat32()=0
Read a 32-bit floating point number from the network connection.
virtual bool isError() const =0
virtual std::int8_t expectInt8()=0
Read a 8-bit integer from the network connection.
An interface for writing to a network connection.
virtual bool isError() const =0
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual void appendInt8(std::int8_t data)=0
Send a representation of a 8-bit integer to the network connection.
virtual void appendFloat32(yarp::conf::float32_t data)=0
Send a representation of a 32-bit floating point number to the network connection.
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
static Type byName(const char *name)
Definition: Type.cpp:171
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:134
A single value (typically within a Bottle).
Definition: Value.h:45
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:23
virtual bool read(yarp::os::idl::WireReader &reader)
virtual bool write(const yarp::os::idl::WireWriter &writer) const
IDL-friendly connection reader.
Definition: WireReader.h:30
std::int8_t expectInt8()
Definition: WireReader.h:80
yarp::conf::float32_t expectFloat32()
Definition: WireReader.h:106
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::JoyFeedback > bottleStyle
Definition: JoyFeedback.h:161
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: JoyFeedback.h:110
static constexpr const char * typeName
Definition: JoyFeedback.h:164
static const std::uint8_t TYPE_RUMBLE
Definition: JoyFeedback.h:44
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: JoyFeedback.h:89
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: JoyFeedback.h:75
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: JoyFeedback.h:152
yarp::os::Type getType() const override
Definition: JoyFeedback.h:188
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::JoyFeedback > rosStyle
Definition: JoyFeedback.h:160
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: JoyFeedback.h:116
static const std::uint8_t TYPE_BUZZER
Definition: JoyFeedback.h:45
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: JoyFeedback.h:130
static constexpr const char * typeText
Definition: JoyFeedback.h:170
static constexpr const char * typeChecksum
Definition: JoyFeedback.h:167
static const std::uint8_t TYPE_LED
Definition: JoyFeedback.h:43
float float32_t
Definition: numeric.h:76
The main, catch-all namespace for YARP.
Definition: dirs.h:16