CARLA
 
载入中...
搜索中...
未找到
Quaternion.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 Quaternion.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
24namespace {
25char dummy;
26} // namespace
27#endif // _WIN32
28
29#include "Quaternion.h"
30#include <fastcdr/Cdr.h>
31
32#include <fastcdr/exceptions/BadParamException.h>
33using namespace eprosima::fastcdr::exception;
34
35#include <utility>
36
37#define geometry_msgs_msg_Quaternion_max_cdr_typesize 32ULL;
38#define geometry_msgs_msg_Quaternion_max_key_cdr_typesize 0ULL;
39
41{
42 // double m_x
43 m_x = 0.0;
44 // double m_y
45 m_y = 0.0;
46 // double m_z
47 m_z = 0.0;
48 // double m_w
49 m_w = 1.0;
50}
51
55
57 const Quaternion& x)
58{
59 m_x = x.m_x;
60 m_y = x.m_y;
61 m_z = x.m_z;
62 m_w = x.m_w;
63}
64
66 Quaternion&& x) noexcept
67{
68 m_x = x.m_x;
69 m_y = x.m_y;
70 m_z = x.m_z;
71 m_w = x.m_w;
72}
73
75 const Quaternion& x)
76{
77 m_x = x.m_x;
78 m_y = x.m_y;
79 m_z = x.m_z;
80 m_w = x.m_w;
81
82 return *this;
83}
84
86 Quaternion&& x) noexcept
87{
88 m_x = x.m_x;
89 m_y = x.m_y;
90 m_z = x.m_z;
91 m_w = x.m_w;
92
93 return *this;
94}
95
97 const Quaternion& x) const
98{
99 return (m_x == x.m_x && m_y == x.m_y && m_z == x.m_z && m_w == x.m_w);
100}
101
103 const Quaternion& x) const
104{
105 return !(*this == x);
106}
107
114
117 size_t current_alignment)
118{
119 // (void)data;
120 // 此行代码用于消除未使用变量 'data' 的编译器警告,因为在此函数中并没有使用该参数。
121
122 // 记录当前对齐值
124
125 // 为第一个 8 字节(例如 x 坐标)分配空间,并计算对齐要求
126 current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8);
127
128 // 为第二个 8 字节(例如 y 坐标)分配空间,并计算对齐要求
129 current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8);
130
131 // 为第三个 8 字节(例如 z 坐标)分配空间,并计算对齐要求
132 current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8);
133
134 // 为第四个 8 字节(例如 w 坐标)分配空间,并计算对齐要求
135 current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8);
136
137 // 返回序列化后的总大小,减去初始的对齐值
139}
140
141
143 eprosima::fastcdr::Cdr& scdr) const
144{
145 scdr << m_x;
146 scdr << m_y;
147 scdr << m_z;
148 scdr << m_w;
149}
150
152 eprosima::fastcdr::Cdr& dcdr)
153{
154 dcdr >> m_x;
155 dcdr >> m_y;
156 dcdr >> m_z;
157 dcdr >> m_w;
158}
159
160/*!
161 * @brief This function sets a value in member x
162 * @param _x New value for member x
163 */
165 double _x)
166{
167 m_x = _x;
168}
169
170/*!
171 * @brief This function returns the value of member x
172 * @return Value of member x
173 */
175{
176 return m_x;
177}
178
179/*!
180 * @brief This function returns a reference to member x
181 * @return Reference to member x
182 */
184{
185 return m_x;
186}
187
188/*!
189 * @brief This function sets a value in member y
190 * @param _y New value for member y
191 */
193 double _y)
194{
195 m_y = _y;
196}
197
198/*!
199 * @brief This function returns the value of member y
200 * @return Value of member y
201 */
203{
204 return m_y;
205}
206
207/*!
208 * @brief This function returns a reference to member y
209 * @return Reference to member y
210 */
212{
213 return m_y;
214}
215
216/*!
217 * @brief This function sets a value in member z
218 * @param _z New value for member z
219 */
221 double _z)
222{
223 m_z = _z;
224}
225
226/*!
227 * @brief This function returns the value of member z
228 * @return Value of member z
229 */
231{
232 return m_z;
233}
234
235/*!
236 * @brief This function returns a reference to member z
237 * @return Reference to member z
238 */
240{
241 return m_z;
242}
243
244/*!
245 * @brief This function sets a value in member w
246 * @param _w New value for member w
247 */
249 double _w)
250{
251 m_w = _w;
252}
253
254/*!
255 * @brief This function returns the value of member w
256 * @return Value of member w
257 */
259{
260 return m_w;
261}
262
263/*!
264 * @brief This function returns a reference to member w
265 * @return Reference to member w
266 */
268{
269 return m_w;
270}
271
278
280{
281 return false;
282}
283
285 eprosima::fastcdr::Cdr& scdr) const
286{
287 (void) scdr;
288}
#define geometry_msgs_msg_Quaternion_max_cdr_typesize
Definition Imu.cpp:30
#define geometry_msgs_msg_Quaternion_max_key_cdr_typesize
Definition Imu.cpp:36
return current_alignment initial_alignment
This class represents the structure Quaternion defined by the user in the IDL file.
Definition Quaternion.h:71
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.
eProsima_user_DllExport ~Quaternion()
Default destructor.
static eProsima_user_DllExport size_t getCdrSerializedSize(const geometry_msgs::msg::Quaternion &data, size_t current_alignment=0)
This function returns the serialized size of a data depending on the buffer alignment.
eProsima_user_DllExport void serialize(eprosima::fastcdr::Cdr &cdr) const
This function serializes an object using CDR serialization.
eProsima_user_DllExport double z() const
This function returns the value of member z
eProsima_user_DllExport Quaternion & operator=(const Quaternion &x)
Copy assignment.
eProsima_user_DllExport Quaternion()
Default constructor.
eProsima_user_DllExport void deserialize(eprosima::fastcdr::Cdr &cdr)
This function deserializes an object using CDR serialization.
eProsima_user_DllExport double y() const
This function returns the value of member y
eProsima_user_DllExport double w() const
This function returns the value of member w
eProsima_user_DllExport double x() const
This function returns the value of member x
eProsima_user_DllExport bool operator==(const Quaternion &x) const
Comparison operator.
eProsima_user_DllExport void serializeKey(eprosima::fastcdr::Cdr &cdr) const
This function serializes the key members of an object using CDR serialization.
static eProsima_user_DllExport bool isKeyDefined()
This function tells you if the Key has been defined for this type
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...
eProsima_user_DllExport bool operator!=(const Quaternion &x) const
Comparison operator.