YARP
Yet Another Robot Platform
RegionOfInterest.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/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  {
230  yarp::os::Type typ = yarp::os::Type::byName(typeName, typeName);
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
#define BOTTLE_TAG_INT32
Definition: Bottle.h:23
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::RegionOfInterest > rosStyle
bool readBare(yarp::os::ConnectionReader &connection) override
#define BOTTLE_TAG_INT8
Definition: Bottle.h:21
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
bool writeBare(yarp::os::ConnectionWriter &connection) const override
virtual void appendBlock(const char *data, size_t len)=0
Send a block of data to the network connection.
static Type byName(const char *name)
Definition: Type.cpp:179
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:141
std::int8_t expectInt8()
Definition: WireReader.h:85
virtual bool isError() const =0
static constexpr const char * typeChecksum
The main, catch-all namespace for YARP.
Definition: numeric.h:47
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr const char * typeText
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary...
virtual bool isBareMode() const =0
Check if the connection is bare mode.
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::RegionOfInterest > bottleStyle
std::int32_t expectInt32()
Definition: WireReader.h:95
An interface for writing to a network connection.
virtual bool write(const yarp::os::idl::WireWriter &writer) const
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
yarp::os::Type getType() const override
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:30
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
static constexpr const char * typeName
An interface for reading from a network connection.
A single value (typically within a Bottle).
Definition: Value.h:40
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...
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
bool readBottle(yarp::os::ConnectionReader &connection) override
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.