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
yarp::rosmsg::sensor_msgs::JoyFeedback::TYPE_BUZZER
static const std::uint8_t TYPE_BUZZER
Definition: JoyFeedback.h:48
yarp::os::ConnectionWriter::appendFloat32
virtual void appendFloat32(yarp::conf::float32_t data)=0
Send a representation of a 32-bit floating point number to the network connection.
yarp::rosmsg::sensor_msgs::JoyFeedback::getType
yarp::os::Type getType() const override
Definition: JoyFeedback.h:191
yarp::rosmsg::sensor_msgs::JoyFeedback::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: JoyFeedback.h:155
WireTypes.h
yarp::rosmsg::sensor_msgs::JoyFeedback::clear
void clear()
Definition: JoyFeedback.h:60
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::os::idl::WireReader::expectFloat32
yarp::conf::float32_t expectFloat32()
Definition: WireReader.h:113
yarp::rosmsg::sensor_msgs::JoyFeedback::JoyFeedback
JoyFeedback()
Definition: JoyFeedback.h:53
yarp::os::idl::BottleStyle
Definition: BottleStyle.h:22
yarp::os::Type
Definition: Type.h:24
yarp::rosmsg::sensor_msgs::JoyFeedback::TYPE_LED
static const std::uint8_t TYPE_LED
Definition: JoyFeedback.h:46
yarp::os::idl::WirePortable::read
virtual bool read(yarp::os::idl::WireReader &reader)
Definition: WirePortable.cpp:14
yarp::rosmsg::sensor_msgs::JoyFeedback::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: JoyFeedback.h:92
yarp::os::ConnectionWriter::appendInt8
virtual void appendInt8(std::int8_t data)=0
Send a representation of a 8-bit integer to the network connection.
yarp::os::ConnectionReader::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
Wire.h
BOTTLE_TAG_INT8
#define BOTTLE_TAG_INT8
Definition: Bottle.h:21
yarp::rosmsg::sensor_msgs::JoyFeedback::intensity
yarp::conf::float32_t intensity
Definition: JoyFeedback.h:51
yarp::os::ConnectionReader::expectInt8
virtual std::int8_t expectInt8()=0
Read a 8-bit integer from the network connection.
yarp::rosmsg::sensor_msgs::JoyFeedback::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::JoyFeedback > bottleStyle
Definition: JoyFeedback.h:164
yarp::rosmsg::sensor_msgs::JoyFeedback::TYPE_RUMBLE
static const std::uint8_t TYPE_RUMBLE
Definition: JoyFeedback.h:47
yarp::rosmsg::sensor_msgs::JoyFeedback::type
std::uint8_t type
Definition: JoyFeedback.h:49
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
BOTTLE_TAG_FLOAT32
#define BOTTLE_TAG_FLOAT32
Definition: Bottle.h:26
yarp::os::Type::byName
static Type byName(const char *name)
Definition: Type.cpp:174
yarp::os::Type::addProperty
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:137
Type.h
yarp::rosmsg::sensor_msgs::JoyFeedback
Definition: JoyFeedback.h:44
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::rosmsg::sensor_msgs::JoyFeedback::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: JoyFeedback.h:113
yarp::os::ConnectionReader::isError
virtual bool isError() const =0
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::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::rosmsg::sensor_msgs::JoyFeedback::id
std::uint8_t id
Definition: JoyFeedback.h:50
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::conf::float32_t
float float32_t
Definition: numeric.h:50
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::rosmsg::sensor_msgs::JoyFeedback::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: JoyFeedback.h:119
yarp::os::idl::BareStyle
Definition: BareStyle.h:22
yarp::rosmsg::sensor_msgs::JoyFeedback::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: JoyFeedback.h:78
yarp::rosmsg::sensor_msgs::JoyFeedback::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: JoyFeedback.h:133
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::os::ConnectionReader::expectFloat32
virtual yarp::conf::float32_t expectFloat32()=0
Read a 32-bit floating point number from the network connection.
yarp::os::idl::WireReader::expectInt8
std::int8_t expectInt8()
Definition: WireReader.h:87
yarp::rosmsg::sensor_msgs::JoyFeedback::typeText
static constexpr const char * typeText
Definition: JoyFeedback.h:173
yarp::rosmsg::sensor_msgs::JoyFeedback::typeChecksum
static constexpr const char * typeChecksum
Definition: JoyFeedback.h:170
yarp::rosmsg::sensor_msgs::JoyFeedback::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::JoyFeedback > rosStyle
Definition: JoyFeedback.h:163
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
sensor_msgs
Definition: BatteryState.h:22
yarp::rosmsg::sensor_msgs::JoyFeedback::typeName
static constexpr const char * typeName
Definition: JoyFeedback.h:167
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