CARLA
 
载入中...
搜索中...
未找到
CameraInfo.cpp
浏览该文件的文档.
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 * 该源文件包含接口定义文件(Interface definition file,IDL)中所描述类型的定义。
18 *
19 * 这个文件是由工具生成的。
20 */
21
22#ifdef _WIN32
23// 移除Visual Studio上的链接器警告LNK4221
24namespace {
25char dummy;
26} // namespace
27#endif // _WIN32
28
29#include "CameraInfo.h"
30#include <fastcdr/Cdr.h>
31
32#include <fastcdr/exceptions/BadParamException.h>
33using 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
47sensor_msgs::msg::CameraInfo::CameraInfo(uint32_t height, uint32_t width, double fov) :
48m_height(height),
49m_width(width)
50{
51 // 字符串 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
71
73 const CameraInfo& x)
74{
75 m_header = x.m_header;
76 m_height = x.m_height;
77 m_width = x.m_width;
78 m_distortion_model = x.m_distortion_model;
79 m_d = x.m_d;
80 m_k = x.m_k;
81 m_r = x.m_r;
82 m_p = x.m_p;
83 m_binning_x = x.m_binning_x;
84 m_binning_y = x.m_binning_y;
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;
110 m_distortion_model = x.m_distortion_model;
111 m_d = x.m_d;
112 m_k = x.m_k;
113 m_r = x.m_r;
114 m_p = x.m_p;
115 m_binning_x = x.m_binning_x;
116 m_binning_y = x.m_binning_y;
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
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 这个函数复制成员头中的值
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 这个函数移动成员头中的值
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 此函数返回对成员头的常量引用
258 * @return Constant reference to member header
259 */
261{
262 return m_header;
263}
264
265/*!
266 * @brief 这个函数返回对成员头的引用
267 * @return 对成员头的引用
268 */
273/*!
274 * @brief 这个函数设置成员高度的值
275 * @param _height New value for member height
276 */
278 uint32_t _height)
279{
280 m_height = _height;
281}
282
283/*!
284 * @brief 这个函数返回成员高度的值
285 * @return Value of member height
286 */
288{
289 return m_height;
290}
291
292/*!
293 * @brief 这个函数返回对成员高度的引用
294 * @return Reference to member height
295 */
297{
298 return m_height;
299}
300
301/*!
302 * @brief 这个函数设置成员宽度的值
303 * @param _width New value for member width
304 */
306 uint32_t _width)
307{
308 m_width = _width;
309}
310
311/*!
312 * @brief 这个函数返回成员宽度的值
313 * @return 成员宽度的值
314 */
316{
317 return m_width;
318}
319
320/*!
321 * @brief 这个函数返回成员宽度的引用
322 * @return 成员宽度的引用
323 */
325{
326 return m_width;
327}
328
329/*!
330 * @brief 这个函数复制成员twisttion_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 这个函数移动成员twisttion_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 这个函数返回一个对成员畸变模型 distortion_model 的常量引用
351 * @return Constant reference to member distortion_model
352 */
354{
355 return m_distortion_model;
356}
357
358/*!
359 * @brief 这个函数返回对成员twisttion_model的引用
360 * @return Reference to member distortion_model
361 */
363{
364 return m_distortion_model;
365}
366
367/*!
368 * @brief 这个函数复制成员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 这个函数移动成员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 这个函数返回一个对成员D的常量引用
389 * @return Constant reference to member D
390 */
391const std::vector<double>& sensor_msgs::msg::CameraInfo::D() const
392{
393 return m_d;
394}
395
396/*!
397 * @brief 这个函数返回对成员D的引用
398 * @return Reference to member D
399 */
401{
402 return m_d;
403}
404
405/*!
406 * @brief 这个函数复制成员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 这个函数移动成员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 这个函数返回对成员k的常量引用
427 * @return Constant reference to member k
428 */
429const std::array<double, 9>& sensor_msgs::msg::CameraInfo::k() const
430{
431 return m_k;
432}
433
434/*!
435 * @brief 这个函数返回对成员k的引用
436 * @return Reference to member k
437 */
438std::array<double, 9>& sensor_msgs::msg::CameraInfo::k()
439{
440 return m_k;
441}
442/*!
443 * @brief 这个函数复制成员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 这个函数移动成员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 这个函数返回一个对成员r的常量引用
464 * @return Constant reference to member r
465 */
466const std::array<double, 9>& sensor_msgs::msg::CameraInfo::r() const
467{
468 return m_r;
469}
470
471/*!
472 * @brief 这个函数返回对成员r的引用
473 * @return Reference to member r
474 */
475std::array<double, 9>& sensor_msgs::msg::CameraInfo::r()
476{
477 return m_r;
478}
479
480/*!
481 * @brief 这个函数复制成员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 这个函数移动成员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 这个函数返回一个对成员p的常量引用
502 * @return Constant reference to member p
503 */
504const std::array<double, 12>& sensor_msgs::msg::CameraInfo::p() const
505{
506 return m_p;
507}
508
509/*!
510 * @brief 这个函数返回对成员p的引用
511 * @return Reference to member p
512 */
513std::array<double, 12>& sensor_msgs::msg::CameraInfo::p()
514{
515 return m_p;
516}
517
518/*!
519 * @brief 这个函数在成员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 这个函数返回成员binning_x的值
530 * @return Value of member binning_x
531 */
533{
534 return m_binning_x;
535}
536
537/*!
538 * @brief 这个函数返回对成员binning_x的引用
539 * @return Reference to member binning_x
540 */
542{
543 return m_binning_x;
544}
545
546/*!
547 * @brief 该函数设置成员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 这个函数返回成员binning_y的值
558 * @return Value of member binning_y
559 */
561{
562 return m_binning_y;
563}
564
565/*!
566 * @brief 这个函数返回对成员binning_y的引用
567 * @return Reference to member binning_y
568 */
570{
571 return m_binning_y;
572}
573
574/*!
575 * @brief 这个函数复制成员roi中的值
576 * @param _roi New value to be copied in member roi
577 */
580{
581 m_roi = _roi;
582}
583
584/*!
585 * @brief 这个函数移动成员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 这个函数返回一个对成员roi的常量引用
596 * @return Constant reference to member roi
597 */
602
603/*!
604 * @brief 这个函数返回对成员roi的引用
605 * @return Reference to member roi
606 */
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
#define sensor_msgs_msg_CameraInfo_max_key_cdr_typesize
This class represents the structure CameraInfo defined by the user in the IDL file.
Definition CameraInfo.h:74
std::array< double, 12 > m_p
Definition CameraInfo.h:443
std_msgs::msg::Header m_header
Definition CameraInfo.h:436
eProsima_user_DllExport void p(const std::array< double, 12 > &_p)
This function copies the value in member p
static eProsima_user_DllExport bool isKeyDefined()
This function tells you if the Key has been defined for this type
std::array< double, 9 > m_r
Definition CameraInfo.h:442
eProsima_user_DllExport void k(const std::array< double, 9 > &_k)
This function copies the value in member K
eProsima_user_DllExport const std::array< double, 9 > & r() const
This function returns a constant reference to member r
eProsima_user_DllExport void D(const std::vector< double > &_D)
This function copies the value in member D
eProsima_user_DllExport const sensor_msgs::msg::RegionOfInterest & roi() const
This function returns a constant reference to member roi
eProsima_user_DllExport void deserialize(eprosima::fastcdr::Cdr &cdr)
This function deserializes an object using CDR serialization.
eProsima_user_DllExport bool operator==(const CameraInfo &x) const
Comparison operator.
eProsima_user_DllExport CameraInfo(uint32_t height=0, uint32_t width=0, double fov=0.0)
Default constructor.
eProsima_user_DllExport bool operator!=(const CameraInfo &x) const
Comparison operator.
eProsima_user_DllExport void roi(const sensor_msgs::msg::RegionOfInterest &_roi)
This function copies the value in member roi
std::vector< double > m_d
Definition CameraInfo.h:440
eProsima_user_DllExport uint32_t binning_y() const
This function returns the value of member binning_y
eProsima_user_DllExport const std::array< double, 12 > & p() const
This function returns a constant reference to member p
eProsima_user_DllExport uint32_t width() const
This function returns the value of member width
eProsima_user_DllExport void serialize(eprosima::fastcdr::Cdr &cdr) const
This function serializes an object using CDR serialization.
eProsima_user_DllExport CameraInfo & operator=(const CameraInfo &x)
Copy assignment.
eProsima_user_DllExport const std_msgs::msg::Header & header() const
This function returns a constant reference to member header
eProsima_user_DllExport void serializeKey(eprosima::fastcdr::Cdr &cdr) const
This function serializes the key members of an object using CDR serialization.
eProsima_user_DllExport void header(const std_msgs::msg::Header &_header)
This function copies the value in member header
eProsima_user_DllExport void distortion_model(const std::string &_distortion_model)
This function copies the value in member distortion_model
eProsima_user_DllExport void r(const std::array< double, 9 > &_r)
This function copies the value in member r
eProsima_user_DllExport const std::vector< double > & D() const
This function returns a constant reference to member D
eProsima_user_DllExport uint32_t binning_x() const
This function returns the value of member binning_x
eProsima_user_DllExport uint32_t height() const
This function returns the value of member height
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...
sensor_msgs::msg::RegionOfInterest m_roi
Definition CameraInfo.h:446
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.
std::array< double, 9 > m_k
Definition CameraInfo.h:441
eProsima_user_DllExport const std::string & distortion_model() const
This function returns a constant reference to member distortion_model
eProsima_user_DllExport ~CameraInfo()
Default destructor.
eProsima_user_DllExport const std::array< double, 9 > & k() const
This function returns a constant reference to member k
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.
This class represents the structure RegionOfInterest defined by the user in the IDL file.
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.
This class represents the structure Header defined by the user in the IDL file.
Definition Header.h:73
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