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