YARP
Yet Another Robot Platform
JoyFeedback.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/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  // Give source text for class, ROS will need this
167  static std::string typeText()
168  {
169  return std::string("\
170 # Declare of the type of feedback\n\
171 uint8 TYPE_LED = 0\n\
172 uint8 TYPE_RUMBLE = 1\n\
173 uint8 TYPE_BUZZER = 2\n\
174 \n\
175 uint8 type\n\
176 \n\
177 # This will hold an id number for each type of each feedback.\n\
178 # Example, the first led would be id=0, the second would be id=1\n\
179 uint8 id\n\
180 \n\
181 # Intensity of the feedback, from 0.0 to 1.0, inclusive. If device is\n\
182 # actually binary, driver should treat 0<=x<0.5 as off, 0.5<=x<=1 as on.\n\
183 float32 intensity\n\
184 \n\
185 ");
186  }
187 
188  std::string getTypeText() const
189  {
191  }
192 
193  // Name the class, ROS will need this
194  yarp::os::Type getType() const override
195  {
196  yarp::os::Type typ = yarp::os::Type::byName("sensor_msgs/JoyFeedback", "sensor_msgs/JoyFeedback");
197  typ.addProperty("md5sum", yarp::os::Value("f4dcd73460360d98f36e55ee7f2e46f1"));
198  typ.addProperty("message_definition", yarp::os::Value(getTypeText()));
199  return typ;
200  }
201 };
202 
203 } // namespace sensor_msgs
204 } // namespace rosmsg
205 } // namespace yarp
206 
207 #endif // YARP_ROSMSG_sensor_msgs_JoyFeedback_h
virtual std::int8_t expectInt8()=0
Read a 8-bit integer from the network connection.
#define BOTTLE_TAG_INT8
Definition: Bottle.h:21
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: JoyFeedback.h:113
static Type byName(const char *name)
Definition: Type.cpp:165
virtual void appendFloat32(yarp::conf::float32_t data)=0
Send a representation of a 32-bit floating point number to the network connection.
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:127
std::int8_t expectInt8()
Definition: WireReader.h:85
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: JoyFeedback.h:155
#define BOTTLE_TAG_FLOAT32
Definition: Bottle.h:26
virtual bool isError() const =0
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...
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: JoyFeedback.h:78
virtual bool isBareMode() const =0
Check if the connection is bare mode.
static const std::uint8_t TYPE_BUZZER
Definition: JoyFeedback.h:48
An interface for writing to a network connection.
virtual bool write(const yarp::os::idl::WireWriter &writer) const
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::JoyFeedback > rosStyle
Definition: JoyFeedback.h:163
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)
virtual bool isError() const =0
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:30
virtual yarp::conf::float32_t expectFloat32()=0
Read a 32-bit floating point number from the network connection.
static const std::uint8_t TYPE_LED
Definition: JoyFeedback.h:46
An interface for reading from a network connection.
float float32_t
Definition: numeric.h:50
yarp::os::Type getType() const override
Definition: JoyFeedback.h:194
A single value (typically within a Bottle).
Definition: Value.h:40
yarp::conf::float32_t expectFloat32()
Definition: WireReader.h:107
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: JoyFeedback.h:92
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...
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: JoyFeedback.h:133
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::JoyFeedback > bottleStyle
Definition: JoyFeedback.h:164
static const std::uint8_t TYPE_RUMBLE
Definition: JoyFeedback.h:47
IDL-friendly connection reader.
Definition: WireReader.h:37
virtual void appendInt8(std::int8_t data)=0
Send a representation of a 8-bit integer to the network connection.
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: JoyFeedback.h:119