YARP
Yet Another Robot Platform
RegionOfInterest.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/RegionOfInterest" msg definition:
12 // # This message is used to specify a region of interest within an image.
13 // #
14 // # When used to specify the ROI setting of the camera when the image was
15 // # taken, the height and width fields should either match the height and
16 // # width fields for the associated image; or height = width = 0
17 // # indicates that the full resolution image was captured.
18 //
19 // uint32 x_offset # Leftmost pixel of the ROI
20 // # (0 if the ROI includes the left edge of the image)
21 // uint32 y_offset # Topmost pixel of the ROI
22 // # (0 if the ROI includes the top edge of the image)
23 // uint32 height # Height of ROI
24 // uint32 width # Width of ROI
25 //
26 // # True if a distinct rectified ROI should be calculated from the "raw"
27 // # ROI in this message. Typically this should be False if the full image
28 // # is captured (ROI not used), and True if a subwindow is captured (ROI
29 // # used).
30 // bool do_rectify
31 // Instances of this class can be read and written with YARP ports,
32 // using a ROS-compatible format.
33 
34 #ifndef YARP_ROSMSG_sensor_msgs_RegionOfInterest_h
35 #define YARP_ROSMSG_sensor_msgs_RegionOfInterest_h
36 
37 #include <yarp/os/Wire.h>
38 #include <yarp/os/Type.h>
39 #include <yarp/os/idl/WireTypes.h>
40 #include <string>
41 #include <vector>
42 
43 namespace yarp {
44 namespace rosmsg {
45 namespace sensor_msgs {
46 
48 {
49 public:
50  std::uint32_t x_offset;
51  std::uint32_t y_offset;
52  std::uint32_t height;
53  std::uint32_t width;
54  bool do_rectify;
55 
57  x_offset(0),
58  y_offset(0),
59  height(0),
60  width(0),
61  do_rectify(false)
62  {
63  }
64 
65  void clear()
66  {
67  // *** x_offset ***
68  x_offset = 0;
69 
70  // *** y_offset ***
71  y_offset = 0;
72 
73  // *** height ***
74  height = 0;
75 
76  // *** width ***
77  width = 0;
78 
79  // *** do_rectify ***
80  do_rectify = false;
81  }
82 
83  bool readBare(yarp::os::ConnectionReader& connection) override
84  {
85  // *** x_offset ***
86  x_offset = connection.expectInt32();
87 
88  // *** y_offset ***
89  y_offset = connection.expectInt32();
90 
91  // *** height ***
92  height = connection.expectInt32();
93 
94  // *** width ***
95  width = connection.expectInt32();
96 
97  // *** do_rectify ***
98  if (!connection.expectBlock((char*)&do_rectify, 1)) {
99  return false;
100  }
101 
102  return !connection.isError();
103  }
104 
105  bool readBottle(yarp::os::ConnectionReader& connection) override
106  {
107  connection.convertTextMode();
108  yarp::os::idl::WireReader reader(connection);
109  if (!reader.readListHeader(5)) {
110  return false;
111  }
112 
113  // *** x_offset ***
114  x_offset = reader.expectInt32();
115 
116  // *** y_offset ***
117  y_offset = reader.expectInt32();
118 
119  // *** height ***
120  height = reader.expectInt32();
121 
122  // *** width ***
123  width = reader.expectInt32();
124 
125  // *** do_rectify ***
126  do_rectify = reader.expectInt8();
127 
128  return !connection.isError();
129  }
130 
132  bool read(yarp::os::ConnectionReader& connection) override
133  {
134  return (connection.isBareMode() ? readBare(connection)
135  : readBottle(connection));
136  }
137 
138  bool writeBare(yarp::os::ConnectionWriter& connection) const override
139  {
140  // *** x_offset ***
141  connection.appendInt32(x_offset);
142 
143  // *** y_offset ***
144  connection.appendInt32(y_offset);
145 
146  // *** height ***
147  connection.appendInt32(height);
148 
149  // *** width ***
150  connection.appendInt32(width);
151 
152  // *** do_rectify ***
153  connection.appendBlock((char*)&do_rectify, 1);
154 
155  return !connection.isError();
156  }
157 
158  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
159  {
160  connection.appendInt32(BOTTLE_TAG_LIST);
161  connection.appendInt32(5);
162 
163  // *** x_offset ***
164  connection.appendInt32(BOTTLE_TAG_INT32);
165  connection.appendInt32(x_offset);
166 
167  // *** y_offset ***
168  connection.appendInt32(BOTTLE_TAG_INT32);
169  connection.appendInt32(y_offset);
170 
171  // *** height ***
172  connection.appendInt32(BOTTLE_TAG_INT32);
173  connection.appendInt32(height);
174 
175  // *** width ***
176  connection.appendInt32(BOTTLE_TAG_INT32);
177  connection.appendInt32(width);
178 
179  // *** do_rectify ***
180  connection.appendInt32(BOTTLE_TAG_INT8);
181  connection.appendInt8(do_rectify);
182 
183  connection.convertTextMode();
184  return !connection.isError();
185  }
186 
188  bool write(yarp::os::ConnectionWriter& connection) const override
189  {
190  return (connection.isBareMode() ? writeBare(connection)
191  : writeBottle(connection));
192  }
193 
194  // This class will serialize ROS style or YARP style depending on protocol.
195  // If you need to force a serialization style, use one of these classes:
198 
199  // The name for this message, ROS will need this
200  static constexpr const char* typeName = "sensor_msgs/RegionOfInterest";
201 
202  // The checksum for this message, ROS will need this
203  static constexpr const char* typeChecksum = "bdb633039d588fcccb441a4d43ccfe09";
204 
205  // The source text for this message, ROS will need this
206  static constexpr const char* typeText = "\
207 # This message is used to specify a region of interest within an image.\n\
208 #\n\
209 # When used to specify the ROI setting of the camera when the image was\n\
210 # taken, the height and width fields should either match the height and\n\
211 # width fields for the associated image; or height = width = 0\n\
212 # indicates that the full resolution image was captured.\n\
213 \n\
214 uint32 x_offset # Leftmost pixel of the ROI\n\
215  # (0 if the ROI includes the left edge of the image)\n\
216 uint32 y_offset # Topmost pixel of the ROI\n\
217  # (0 if the ROI includes the top edge of the image)\n\
218 uint32 height # Height of ROI\n\
219 uint32 width # Width of ROI\n\
220 \n\
221 # True if a distinct rectified ROI should be calculated from the \"raw\"\n\
222 # ROI in this message. Typically this should be False if the full image\n\
223 # is captured (ROI not used), and True if a subwindow is captured (ROI\n\
224 # used).\n\
225 bool do_rectify\n\
226 ";
227 
228  yarp::os::Type getType() const override
229  {
231  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
232  typ.addProperty("message_definition", yarp::os::Value(typeText));
233  return typ;
234  }
235 };
236 
237 } // namespace sensor_msgs
238 } // namespace rosmsg
239 } // namespace yarp
240 
241 #endif // YARP_ROSMSG_sensor_msgs_RegionOfInterest_h
yarp::os::ConnectionWriter::appendBlock
virtual void appendBlock(const char *data, size_t len)=0
Send a block of data to the network connection.
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::os::idl::BottleStyle
Definition: BottleStyle.h:22
yarp::rosmsg::sensor_msgs::RegionOfInterest::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: RegionOfInterest.h:188
yarp::os::Type
Definition: Type.h:24
yarp::rosmsg::sensor_msgs::RegionOfInterest::y_offset
std::uint32_t y_offset
Definition: RegionOfInterest.h:51
yarp::os::idl::WirePortable::read
virtual bool read(yarp::os::idl::WireReader &reader)
Definition: WirePortable.cpp:14
yarp::rosmsg::sensor_msgs::RegionOfInterest::RegionOfInterest
RegionOfInterest()
Definition: RegionOfInterest.h:56
yarp::rosmsg::sensor_msgs::RegionOfInterest::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: RegionOfInterest.h:83
yarp::rosmsg::sensor_msgs::RegionOfInterest::typeText
static constexpr const char * typeText
Definition: RegionOfInterest.h:206
yarp::rosmsg::sensor_msgs::RegionOfInterest::width
std::uint32_t width
Definition: RegionOfInterest.h:53
yarp::rosmsg::sensor_msgs::RegionOfInterest::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::RegionOfInterest > rosStyle
Definition: RegionOfInterest.h:196
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
yarp::rosmsg::sensor_msgs::RegionOfInterest::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: RegionOfInterest.h:158
yarp::rosmsg::sensor_msgs::RegionOfInterest::height
std::uint32_t height
Definition: RegionOfInterest.h:52
BOTTLE_TAG_INT8
#define BOTTLE_TAG_INT8
Definition: Bottle.h:21
yarp::rosmsg::sensor_msgs::RegionOfInterest::do_rectify
bool do_rectify
Definition: RegionOfInterest.h:54
BOTTLE_TAG_INT32
#define BOTTLE_TAG_INT32
Definition: Bottle.h:23
yarp::rosmsg::sensor_msgs::RegionOfInterest::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::RegionOfInterest > bottleStyle
Definition: RegionOfInterest.h:197
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
yarp::os::Type::byName
static Type byName(const char *name)
Definition: Type.cpp:174
yarp::os::ConnectionReader::expectInt32
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
yarp::os::Type::addProperty
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:137
Type.h
yarp::rosmsg::sensor_msgs::RegionOfInterest::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: RegionOfInterest.h:138
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::rosmsg::sensor_msgs::RegionOfInterest::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: RegionOfInterest.h:132
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::RegionOfInterest::typeName
static constexpr const char * typeName
Definition: RegionOfInterest.h:200
yarp::rosmsg::sensor_msgs::RegionOfInterest::getType
yarp::os::Type getType() const override
Definition: RegionOfInterest.h:228
yarp::rosmsg::sensor_msgs::RegionOfInterest
Definition: RegionOfInterest.h:48
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::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::os::idl::BareStyle
Definition: BareStyle.h:22
yarp::os::idl::WireReader::expectInt32
std::int32_t expectInt32()
Definition: WireReader.h:99
yarp::rosmsg::sensor_msgs::RegionOfInterest::typeChecksum
static constexpr const char * typeChecksum
Definition: RegionOfInterest.h:203
yarp::rosmsg::sensor_msgs::RegionOfInterest::clear
void clear()
Definition: RegionOfInterest.h:65
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::os::idl::WireReader::expectInt8
std::int8_t expectInt8()
Definition: WireReader.h:87
yarp::rosmsg::sensor_msgs::RegionOfInterest::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: RegionOfInterest.h:105
yarp::os::ConnectionReader::expectBlock
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
sensor_msgs
Definition: BatteryState.h:22
yarp::rosmsg::sensor_msgs::RegionOfInterest::x_offset
std::uint32_t x_offset
Definition: RegionOfInterest.h:50
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