Gazebo Sim
API Reference
8.7.0
insert_drive_file
Tutorials
library_books
Classes
toc
Namespaces
insert_drive_file
Files
launch
Gazebo Website
Index
List
Hierarchy
Members: All
Members: Functions
Members: Variables
Members: Typedefs
Members: Enumerations
Members: Enumerator
List
Members
Functions
Typedefs
Variables
Enumerations
Enumerator
src
gz-sim
src
systems
environmental_sensor_system
TransformTypes.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2022 Open Source Robotics Foundation
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
*/
17
#ifndef GZ_ENVIRONMENTAL_SYSTEM_TRANFORM_TYPE_HH_
18
#define GZ_ENVIRONMENTAL_SYSTEM_TRANFORM_TYPE_HH_
19
20
#include <string>
21
#include <optional>
22
23
#include <gz/math/Vector3.hh>
24
#include <gz/math/Pose3.hh>
25
26
namespace
gz
{
27
namespace
sim {
29
enum
TransformType
{
33
ADD_VELOCITY_LOCAL
,
36
ADD_VELOCITY_GLOBAL
,
39
LOCAL
,
42
GLOBAL
43
};
44
48
std::optional<TransformType>
getTransformType
(
const
std::string
&_str)
49
{
50
if
(_str ==
"ADD_VELOCITY_LOCAL"
)
51
return
TransformType::ADD_VELOCITY_LOCAL
;
52
if
(_str ==
"ADD_VELOCITY_GLOBAL"
)
53
return
TransformType::ADD_VELOCITY_GLOBAL
;
54
if
(_str ==
"LOCAL"
)
55
return
TransformType::LOCAL
;
56
if
(_str ==
"GLOBAL"
)
57
return
TransformType::GLOBAL
;
58
return
std::nullopt;
59
}
60
67
math::Vector3d
transformFrame
(
68
const
TransformType
_type,
const
math::Pose3d
& _pose,
69
const
math::Vector3d
& _velocity,
const
math::Vector3d
& _reading)
70
{
71
math::Vector3d
result;
72
math::Vector3d
offset{0, 0, 0};
73
74
if
(_type ==
ADD_VELOCITY_LOCAL
|| _type ==
ADD_VELOCITY_GLOBAL
)
75
{
76
offset = -_velocity;
77
}
78
79
switch
(_type) {
80
case
ADD_VELOCITY_LOCAL
:
81
case
LOCAL
:
82
result = _pose.
Rot
().Inverse() * (_reading + offset);
83
break
;
84
default
:
85
result = (_reading + offset);
86
}
87
88
return
result;
89
}
90
}
91
}
92
#endif