YARP
Yet Another Robot Platform
JoyFeedbackArray.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/JoyFeedbackArray" msg definition:
9// # This message publishes values for multiple feedback at once.
10// JoyFeedback[] array// Instances of this class can be read and written with YARP ports,
11// using a ROS-compatible format.
12
13#ifndef YARP_ROSMSG_sensor_msgs_JoyFeedbackArray_h
14#define YARP_ROSMSG_sensor_msgs_JoyFeedbackArray_h
15
16#include <yarp/os/Wire.h>
17#include <yarp/os/Type.h>
19#include <string>
20#include <vector>
22
23namespace yarp {
24namespace rosmsg {
25namespace sensor_msgs {
26
28{
29public:
30 std::vector<yarp::rosmsg::sensor_msgs::JoyFeedback> array;
31
33 array()
34 {
35 }
36
37 void clear()
38 {
39 // *** array ***
40 array.clear();
41 }
42
43 bool readBare(yarp::os::ConnectionReader& connection) override
44 {
45 // *** array ***
46 int len = connection.expectInt32();
47 array.resize(len);
48 for (int i=0; i<len; i++) {
49 if (!array[i].read(connection)) {
50 return false;
51 }
52 }
53
54 return !connection.isError();
55 }
56
57 bool readBottle(yarp::os::ConnectionReader& connection) override
58 {
59 connection.convertTextMode();
60 yarp::os::idl::WireReader reader(connection);
61 if (!reader.readListHeader(1)) {
62 return false;
63 }
64
65 // *** array ***
66 if (connection.expectInt32() != BOTTLE_TAG_LIST) {
67 return false;
68 }
69 int len = connection.expectInt32();
70 array.resize(len);
71 for (int i=0; i<len; i++) {
72 if (!array[i].read(connection)) {
73 return false;
74 }
75 }
76
77 return !connection.isError();
78 }
79
81 bool read(yarp::os::ConnectionReader& connection) override
82 {
83 return (connection.isBareMode() ? readBare(connection)
84 : readBottle(connection));
85 }
86
87 bool writeBare(yarp::os::ConnectionWriter& connection) const override
88 {
89 // *** array ***
90 connection.appendInt32(array.size());
91 for (size_t i=0; i<array.size(); i++) {
92 if (!array[i].write(connection)) {
93 return false;
94 }
95 }
96
97 return !connection.isError();
98 }
99
100 bool writeBottle(yarp::os::ConnectionWriter& connection) const override
101 {
102 connection.appendInt32(BOTTLE_TAG_LIST);
103 connection.appendInt32(1);
104
105 // *** array ***
106 connection.appendInt32(BOTTLE_TAG_LIST);
107 connection.appendInt32(array.size());
108 for (size_t i=0; i<array.size(); i++) {
109 if (!array[i].write(connection)) {
110 return false;
111 }
112 }
113
114 connection.convertTextMode();
115 return !connection.isError();
116 }
117
119 bool write(yarp::os::ConnectionWriter& connection) const override
120 {
121 return (connection.isBareMode() ? writeBare(connection)
122 : writeBottle(connection));
123 }
124
125 // This class will serialize ROS style or YARP style depending on protocol.
126 // If you need to force a serialization style, use one of these classes:
129
130 // The name for this message, ROS will need this
131 static constexpr const char* typeName = "sensor_msgs/JoyFeedbackArray";
132
133 // The checksum for this message, ROS will need this
134 static constexpr const char* typeChecksum = "cde5730a895b1fc4dee6f91b754b213d";
135
136 // The source text for this message, ROS will need this
137 static constexpr const char* typeText = "\
138# This message publishes values for multiple feedback at once. \n\
139JoyFeedback[] array\n\
140================================================================================\n\
141MSG: sensor_msgs/JoyFeedback\n\
142# Declare of the type of feedback\n\
143uint8 TYPE_LED = 0\n\
144uint8 TYPE_RUMBLE = 1\n\
145uint8 TYPE_BUZZER = 2\n\
146\n\
147uint8 type\n\
148\n\
149# This will hold an id number for each type of each feedback.\n\
150# Example, the first led would be id=0, the second would be id=1\n\
151uint8 id\n\
152\n\
153# Intensity of the feedback, from 0.0 to 1.0, inclusive. If device is\n\
154# actually binary, driver should treat 0<=x<0.5 as off, 0.5<=x<=1 as on.\n\
155float32 intensity\n\
156\n\
157";
158
159 yarp::os::Type getType() const override
160 {
163 typ.addProperty("message_definition", yarp::os::Value(typeText));
164 return typ;
165 }
166};
167
168} // namespace sensor_msgs
169} // namespace rosmsg
170} // namespace yarp
171
172#endif // YARP_ROSMSG_sensor_msgs_JoyFeedbackArray_h
#define BOTTLE_TAG_LIST
Definition: Bottle.h:28
An interface for reading from a network connection.
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
virtual bool isError() const =0
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 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:43
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:21
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:27
std::vector< yarp::rosmsg::sensor_msgs::JoyFeedback > array
static constexpr const char * typeName
bool writeBare(yarp::os::ConnectionWriter &connection) const override
static constexpr const char * typeChecksum
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::JoyFeedbackArray > bottleStyle
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::JoyFeedbackArray > rosStyle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool readBare(yarp::os::ConnectionReader &connection) override
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
yarp::os::Type getType() const override
bool readBottle(yarp::os::ConnectionReader &connection) override
static constexpr const char * typeText
The main, catch-all namespace for YARP.
Definition: dirs.h:16