CARLA
CameraInfo.cpp
Go to the documentation of this file.
1 // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 /*!
16  * @file CameraInfo.cpp
17  * This source file contains the definition of the described types in the IDL file.
18  *
19  * This file was generated by the tool gen.
20  */
21 
22 #ifdef _WIN32
23 // Remove linker warning LNK4221 on Visual Studio
24 namespace {
25 char dummy;
26 } // namespace
27 #endif // _WIN32
28 
29 #include "CameraInfo.h"
30 #include <fastcdr/Cdr.h>
31 
32 #include <fastcdr/exceptions/BadParamException.h>
33 using namespace eprosima::fastcdr::exception;
34 
35 #include <utility>
36 #include <cmath>
37 
38 #define builtin_interfaces_msg_Time_max_cdr_typesize 8ULL;
39 #define sensor_msgs_msg_CameraInfo_max_cdr_typesize 3793ULL;
40 #define sensor_msgs_msg_RegionOfInterest_max_cdr_typesize 17ULL;
41 #define std_msgs_msg_Header_max_cdr_typesize 268ULL;
42 #define builtin_interfaces_msg_Time_max_key_cdr_typesize 0ULL;
43 #define sensor_msgs_msg_CameraInfo_max_key_cdr_typesize 0ULL;
44 #define sensor_msgs_msg_RegionOfInterest_max_key_cdr_typesize 0ULL;
45 #define std_msgs_msg_Header_max_key_cdr_typesize 0ULL;
46 
47 sensor_msgs::msg::CameraInfo::CameraInfo(uint32_t height, uint32_t width, double fov) :
48 m_height(height),
49 m_width(width)
50 {
51  // string m_distortion_model
52  m_distortion_model = "plumb_bob";
53 
54  const double cx = static_cast<double>(m_width) / 2.0;
55  const double cy = static_cast<double>(m_height) / 2.0;
56  const double fx = static_cast<double>(m_width) / (2.0 * std::tan(fov) * M_PI / 360.0);
57  const double fy = fx;
58 
59  m_d = { 0.0, 0.0, 0.0, 0.0, 0.0 };
60  m_k = {fx, 0.0, cx, 0.0, fy, cy, 0.0, 0.0, 1.0};
61  m_r = { 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 };
62  m_p = {fx, 0.0, cx, 0.0, 0.0, fy, cy, 0.0, 0.0, 0.0, 1.0, 0.0};
63 
64  m_binning_x = 0;
65  m_binning_y = 0;
66 }
67 
69 {
70 }
71 
73  const CameraInfo& x)
74 {
75  m_header = x.m_header;
76  m_height = x.m_height;
77  m_width = x.m_width;
79  m_d = x.m_d;
80  m_k = x.m_k;
81  m_r = x.m_r;
82  m_p = x.m_p;
85  m_roi = x.m_roi;
86 }
87 
89  CameraInfo&& x) noexcept
90 {
91  m_header = std::move(x.m_header);
92  m_height = x.m_height;
93  m_width = x.m_width;
94  m_distortion_model = std::move(x.m_distortion_model);
95  m_d = std::move(x.m_d);
96  m_k = std::move(x.m_k);
97  m_r = std::move(x.m_r);
98  m_p = std::move(x.m_p);
99  m_binning_x = x.m_binning_x;
100  m_binning_y = x.m_binning_y;
101  m_roi = std::move(x.m_roi);
102 }
103 
105  const CameraInfo& x)
106 {
107  m_header = x.m_header;
108  m_height = x.m_height;
109  m_width = x.m_width;
111  m_d = x.m_d;
112  m_k = x.m_k;
113  m_r = x.m_r;
114  m_p = x.m_p;
117  m_roi = x.m_roi;
118 
119  return *this;
120 }
121 
123  CameraInfo&& x) noexcept
124 {
125  m_header = std::move(x.m_header);
126  m_height = x.m_height;
127  m_width = x.m_width;
128  m_distortion_model = std::move(x.m_distortion_model);
129  m_d = std::move(x.m_d);
130  m_k = std::move(x.m_k);
131  m_r = std::move(x.m_r);
132  m_p = std::move(x.m_p);
133  m_binning_x = x.m_binning_x;
134  m_binning_y = x.m_binning_y;
135  m_roi = std::move(x.m_roi);
136 
137  return *this;
138 }
139 
141  const CameraInfo& x) const
142 {
143  return (m_header == x.m_header && m_height == x.m_height && m_width == x.m_width && m_distortion_model == x.m_distortion_model && m_d == x.m_d && m_k == x.m_k && m_r == x.m_r && m_p == x.m_p && m_binning_x == x.m_binning_x && m_binning_y == x.m_binning_y && m_roi == x.m_roi);
144 }
145 
147  const CameraInfo& x) const
148 {
149  return !(*this == x);
150 }
151 
153  size_t current_alignment)
154 {
155  static_cast<void>(current_alignment);
157 }
158 
160  const sensor_msgs::msg::CameraInfo& data,
161  size_t current_alignment)
162 {
163  (void)data;
164  size_t initial_alignment = current_alignment;
165  current_alignment += std_msgs::msg::Header::getCdrSerializedSize(data.header(), current_alignment);
166  current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
167  current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
168  current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.distortion_model().size() + 1;
169  current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
170 
171  if (data.D().size() > 0)
172  {
173  current_alignment += (data.D().size() * 8) + eprosima::fastcdr::Cdr::alignment(current_alignment, 8);
174  }
175 
176  current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
177 
178  if (data.k().size() > 0)
179  {
180  current_alignment += (data.k().size() * 8) + eprosima::fastcdr::Cdr::alignment(current_alignment, 8);
181  }
182 
183  current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
184 
185  if (data.r().size() > 0)
186  {
187  current_alignment += (data.r().size() * 8) + eprosima::fastcdr::Cdr::alignment(current_alignment, 8);
188  }
189 
190  current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
191 
192  if (data.p().size() > 0)
193  {
194  current_alignment += (data.p().size() * 8) + eprosima::fastcdr::Cdr::alignment(current_alignment, 8);
195  }
196 
197  current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
198  current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
199  current_alignment += sensor_msgs::msg::RegionOfInterest::getCdrSerializedSize(data.roi(), current_alignment);
200 
201  return current_alignment - initial_alignment;
202 }
203 
205  eprosima::fastcdr::Cdr& scdr) const
206 {
207  scdr << m_header;
208  scdr << m_height;
209  scdr << m_width;
210  scdr << m_distortion_model.c_str();
211  scdr << m_d;
212  scdr << m_k;
213  scdr << m_r;
214  scdr << m_p;
215  scdr << m_binning_x;
216  scdr << m_binning_y;
217  scdr << m_roi;
218 }
219 
221  eprosima::fastcdr::Cdr& dcdr)
222 {
223  dcdr >> m_header;
224  dcdr >> m_height;
225  dcdr >> m_width;
226  dcdr >> m_distortion_model;
227  dcdr >> m_d;
228  dcdr >> m_k;
229  dcdr >> m_r;
230  dcdr >> m_p;
231  dcdr >> m_binning_x;
232  dcdr >> m_binning_y;
233  dcdr >> m_roi;
234 }
235 
236 /*!
237  * @brief This function copies the value in member header
238  * @param _header New value to be copied in member header
239  */
241  const std_msgs::msg::Header& _header)
242 {
243  m_header = _header;
244 }
245 
246 /*!
247  * @brief This function moves the value in member header
248  * @param _header New value to be moved in member header
249  */
251  std_msgs::msg::Header&& _header)
252 {
253  m_header = std::move(_header);
254 }
255 
256 /*!
257  * @brief This function returns a constant reference to member header
258  * @return Constant reference to member header
259  */
261 {
262  return m_header;
263 }
264 
265 /*!
266  * @brief This function returns a reference to member header
267  * @return Reference to member header
268  */
270 {
271  return m_header;
272 }
273 /*!
274  * @brief This function sets a value in member height
275  * @param _height New value for member height
276  */
278  uint32_t _height)
279 {
280  m_height = _height;
281 }
282 
283 /*!
284  * @brief This function returns the value of member height
285  * @return Value of member height
286  */
288 {
289  return m_height;
290 }
291 
292 /*!
293  * @brief This function returns a reference to member height
294  * @return Reference to member height
295  */
297 {
298  return m_height;
299 }
300 
301 /*!
302  * @brief This function sets a value in member width
303  * @param _width New value for member width
304  */
306  uint32_t _width)
307 {
308  m_width = _width;
309 }
310 
311 /*!
312  * @brief This function returns the value of member width
313  * @return Value of member width
314  */
316 {
317  return m_width;
318 }
319 
320 /*!
321  * @brief This function returns a reference to member width
322  * @return Reference to member width
323  */
325 {
326  return m_width;
327 }
328 
329 /*!
330  * @brief This function copies the value in member distortion_model
331  * @param _distortion_model New value to be copied in member distortion_model
332  */
334  const std::string& _distortion_model)
335 {
336  m_distortion_model = _distortion_model;
337 }
338 
339 /*!
340  * @brief This function moves the value in member distortion_model
341  * @param _distortion_model New value to be moved in member distortion_model
342  */
344  std::string&& _distortion_model)
345 {
346  m_distortion_model = std::move(_distortion_model);
347 }
348 
349 /*!
350  * @brief This function returns a constant reference to member distortion_model
351  * @return Constant reference to member distortion_model
352  */
354 {
355  return m_distortion_model;
356 }
357 
358 /*!
359  * @brief This function returns a reference to member distortion_model
360  * @return Reference to member distortion_model
361  */
363 {
364  return m_distortion_model;
365 }
366 
367 /*!
368  * @brief This function copies the value in member D
369  * @param _D New value to be copied in member D
370  */
372  const std::vector<double>& _D)
373 {
374  m_d = _D;
375 }
376 
377 /*!
378  * @brief This function moves the value in member D
379  * @param _D New value to be moved in member D
380  */
382  std::vector<double>&& _D)
383 {
384  m_d = std::move(_D);
385 }
386 
387 /*!
388  * @brief This function returns a constant reference to member D
389  * @return Constant reference to member D
390  */
391 const std::vector<double>& sensor_msgs::msg::CameraInfo::D() const
392 {
393  return m_d;
394 }
395 
396 /*!
397  * @brief This function returns a reference to member D
398  * @return Reference to member D
399  */
400 std::vector<double>& sensor_msgs::msg::CameraInfo::D()
401 {
402  return m_d;
403 }
404 
405 /*!
406  * @brief This function copies the value in member k
407  * @param _k New value to be copied in member k
408  */
410  const std::array<double, 9>& _k)
411 {
412  m_k = _k;
413 }
414 
415 /*!
416  * @brief This function moves the value in member k
417  * @param _k New value to be moved in member k
418  */
420  std::array<double, 9>&& _k)
421 {
422  m_k = std::move(_k);
423 }
424 
425 /*!
426  * @brief This function returns a constant reference to member k
427  * @return Constant reference to member k
428  */
429 const std::array<double, 9>& sensor_msgs::msg::CameraInfo::k() const
430 {
431  return m_k;
432 }
433 
434 /*!
435  * @brief This function returns a reference to member k
436  * @return Reference to member k
437  */
438 std::array<double, 9>& sensor_msgs::msg::CameraInfo::k()
439 {
440  return m_k;
441 }
442 /*!
443  * @brief This function copies the value in member r
444  * @param _r New value to be copied in member r
445  */
447  const std::array<double, 9>& _r)
448 {
449  m_r = _r;
450 }
451 
452 /*!
453  * @brief This function moves the value in member r
454  * @param _r New value to be moved in member r
455  */
457  std::array<double, 9>&& _r)
458 {
459  m_r = std::move(_r);
460 }
461 
462 /*!
463  * @brief This function returns a constant reference to member r
464  * @return Constant reference to member r
465  */
466 const std::array<double, 9>& sensor_msgs::msg::CameraInfo::r() const
467 {
468  return m_r;
469 }
470 
471 /*!
472  * @brief This function returns a reference to member r
473  * @return Reference to member r
474  */
475 std::array<double, 9>& sensor_msgs::msg::CameraInfo::r()
476 {
477  return m_r;
478 }
479 
480 /*!
481  * @brief This function copies the value in member p
482  * @param _p New value to be copied in member p
483  */
485  const std::array<double, 12>& _p)
486 {
487  m_p = _p;
488 }
489 
490 /*!
491  * @brief This function moves the value in member p
492  * @param _p New value to be moved in member p
493  */
495  std::array<double, 12>&& _p)
496 {
497  m_p = std::move(_p);
498 }
499 
500 /*!
501  * @brief This function returns a constant reference to member p
502  * @return Constant reference to member p
503  */
504 const std::array<double, 12>& sensor_msgs::msg::CameraInfo::p() const
505 {
506  return m_p;
507 }
508 
509 /*!
510  * @brief This function returns a reference to member p
511  * @return Reference to member p
512  */
513 std::array<double, 12>& sensor_msgs::msg::CameraInfo::p()
514 {
515  return m_p;
516 }
517 
518 /*!
519  * @brief This function sets a value in member binning_x
520  * @param _binning_x New value for member binning_x
521  */
523  uint32_t _binning_x)
524 {
525  m_binning_x = _binning_x;
526 }
527 
528 /*!
529  * @brief This function returns the value of member binning_x
530  * @return Value of member binning_x
531  */
533 {
534  return m_binning_x;
535 }
536 
537 /*!
538  * @brief This function returns a reference to member binning_x
539  * @return Reference to member binning_x
540  */
542 {
543  return m_binning_x;
544 }
545 
546 /*!
547  * @brief This function sets a value in member binning_y
548  * @param _binning_y New value for member binning_y
549  */
551  uint32_t _binning_y)
552 {
553  m_binning_y = _binning_y;
554 }
555 
556 /*!
557  * @brief This function returns the value of member binning_y
558  * @return Value of member binning_y
559  */
561 {
562  return m_binning_y;
563 }
564 
565 /*!
566  * @brief This function returns a reference to member binning_y
567  * @return Reference to member binning_y
568  */
570 {
571  return m_binning_y;
572 }
573 
574 /*!
575  * @brief This function copies the value in member roi
576  * @param _roi New value to be copied in member roi
577  */
580 {
581  m_roi = _roi;
582 }
583 
584 /*!
585  * @brief This function moves the value in member roi
586  * @param _roi New value to be moved in member roi
587  */
590 {
591  m_roi = std::move(_roi);
592 }
593 
594 /*!
595  * @brief This function returns a constant reference to member roi
596  * @return Constant reference to member roi
597  */
599 {
600  return m_roi;
601 }
602 
603 /*!
604  * @brief This function returns a reference to member roi
605  * @return Reference to member roi
606  */
608 {
609  return m_roi;
610 }
611 
613  size_t current_alignment)
614 {
615  static_cast<void>(current_alignment);
617 }
618 
620 {
621  return false;
622 }
623 
625  eprosima::fastcdr::Cdr& scdr) const
626 {
627  (void) scdr;
628 }
#define sensor_msgs_msg_CameraInfo_max_cdr_typesize
Definition: CameraInfo.cpp:39
eProsima_user_DllExport void k(const std::array< double, 9 > &_k)
This function copies the value in member K.
Definition: CameraInfo.cpp:409
eProsima_user_DllExport void serialize(eprosima::fastcdr::Cdr &cdr) const
This function serializes an object using CDR serialization.
Definition: CameraInfo.cpp:204
eProsima_user_DllExport const std::string & distortion_model() const
This function returns a constant reference to member distortion_model.
Definition: CameraInfo.cpp:353
eProsima_user_DllExport const std::vector< double > & D() const
This function returns a constant reference to member D.
Definition: CameraInfo.cpp:391
static eProsima_user_DllExport size_t getMaxCdrSerializedSize(size_t current_alignment=0)
This function returns the maximum serialized size of an object depending on the buffer alignment...
Definition: CameraInfo.cpp:152
eProsima_user_DllExport uint32_t binning_x() const
This function returns the value of member binning_x.
Definition: CameraInfo.cpp:532
eProsima_user_DllExport void D(const std::vector< double > &_D)
This function copies the value in member D.
Definition: CameraInfo.cpp:371
eProsima_user_DllExport void distortion_model(const std::string &_distortion_model)
This function copies the value in member distortion_model.
Definition: CameraInfo.cpp:333
eProsima_user_DllExport void roi(const sensor_msgs::msg::RegionOfInterest &_roi)
This function copies the value in member roi.
Definition: CameraInfo.cpp:578
eProsima_user_DllExport bool operator!=(const CameraInfo &x) const
Comparison operator.
Definition: CameraInfo.cpp:146
This class represents the structure Header defined by the user in the IDL file.
Definition: Header.h:72
This class represents the structure CameraInfo defined by the user in the IDL file.
Definition: CameraInfo.h:73
static eProsima_user_DllExport size_t getCdrSerializedSize(const sensor_msgs::msg::RegionOfInterest &data, size_t current_alignment=0)
This function returns the serialized size of a data depending on the buffer alignment.
sensor_msgs::msg::RegionOfInterest m_roi
Definition: CameraInfo.h:446
eProsima_user_DllExport const std_msgs::msg::Header & header() const
This function returns a constant reference to member header.
Definition: CameraInfo.cpp:260
std::vector< double > m_d
Definition: CameraInfo.h:440
std::array< double, 9 > m_k
Definition: CameraInfo.h:441
eProsima_user_DllExport ~CameraInfo()
Default destructor.
Definition: CameraInfo.cpp:68
#define sensor_msgs_msg_CameraInfo_max_key_cdr_typesize
Definition: CameraInfo.cpp:43
static eProsima_user_DllExport size_t getCdrSerializedSize(const std_msgs::msg::Header &data, size_t current_alignment=0)
This function returns the serialized size of a data depending on the buffer alignment.
Definition: Header.cpp:102
static eProsima_user_DllExport bool isKeyDefined()
This function tells you if the Key has been defined for this type.
Definition: CameraInfo.cpp:619
eProsima_user_DllExport void header(const std_msgs::msg::Header &_header)
This function copies the value in member header.
Definition: CameraInfo.cpp:240
eProsima_user_DllExport void r(const std::array< double, 9 > &_r)
This function copies the value in member r.
Definition: CameraInfo.cpp:446
static eProsima_user_DllExport size_t getKeyMaxCdrSerializedSize(size_t current_alignment=0)
This function returns the maximum serialized size of the Key of an object depending on the buffer ali...
Definition: CameraInfo.cpp:612
eProsima_user_DllExport void deserialize(eprosima::fastcdr::Cdr &cdr)
This function deserializes an object using CDR serialization.
Definition: CameraInfo.cpp:220
eProsima_user_DllExport void p(const std::array< double, 12 > &_p)
This function copies the value in member p.
Definition: CameraInfo.cpp:484
eProsima_user_DllExport const sensor_msgs::msg::RegionOfInterest & roi() const
This function returns a constant reference to member roi.
Definition: CameraInfo.cpp:598
eProsima_user_DllExport const std::array< double, 9 > & k() const
This function returns a constant reference to member k.
Definition: CameraInfo.cpp:429
This class represents the structure RegionOfInterest defined by the user in the IDL file...
eProsima_user_DllExport bool operator==(const CameraInfo &x) const
Comparison operator.
Definition: CameraInfo.cpp:140
eProsima_user_DllExport uint32_t width() const
This function returns the value of member width.
Definition: CameraInfo.cpp:315
eProsima_user_DllExport void serializeKey(eprosima::fastcdr::Cdr &cdr) const
This function serializes the key members of an object using CDR serialization.
Definition: CameraInfo.cpp:624
std_msgs::msg::Header m_header
Definition: CameraInfo.h:436
eProsima_user_DllExport const std::array< double, 12 > & p() const
This function returns a constant reference to member p.
Definition: CameraInfo.cpp:504
std::array< double, 12 > m_p
Definition: CameraInfo.h:443
eProsima_user_DllExport uint32_t height() const
This function returns the value of member height.
Definition: CameraInfo.cpp:287
eProsima_user_DllExport uint32_t binning_y() const
This function returns the value of member binning_y.
Definition: CameraInfo.cpp:560
static eProsima_user_DllExport size_t getCdrSerializedSize(const sensor_msgs::msg::CameraInfo &data, size_t current_alignment=0)
This function returns the serialized size of a data depending on the buffer alignment.
Definition: CameraInfo.cpp:159
eProsima_user_DllExport const std::array< double, 9 > & r() const
This function returns a constant reference to member r.
Definition: CameraInfo.cpp:466
std::array< double, 9 > m_r
Definition: CameraInfo.h:442
eProsima_user_DllExport CameraInfo & operator=(const CameraInfo &x)
Copy assignment.
Definition: CameraInfo.cpp:104
eProsima_user_DllExport CameraInfo(uint32_t height=0, uint32_t width=0, double fov=0.0)
Default constructor.
Definition: CameraInfo.cpp:47