Gazebo Rendering
API Reference
8.2.1
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-rendering
include
gz
rendering
base
BaseInertiaVisual.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2021 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_RENDERING_BASE_BASEINERTIAVISUAL_HH_
18
#define GZ_RENDERING_BASE_BASEINERTIAVISUAL_HH_
19
20
#include "gz/common/Console.hh"
21
22
#include "
gz/rendering/base/BaseObject.hh
"
23
#include "
gz/rendering/base/BaseRenderTypes.hh
"
24
#include "
gz/rendering/InertiaVisual.hh
"
25
#include "
gz/rendering/Scene.hh
"
26
27
namespace
gz
28
{
29
namespace
rendering
30
{
31
inline
namespace
GZ_RENDERING_VERSION_NAMESPACE {
32
//
34
template
<
class
T>
35
class
BaseInertiaVisual
:
36
public
virtual
InertiaVisual
,
37
public
virtual
T
38
{
40
protected
:
BaseInertiaVisual
();
41
43
public
:
virtual
~BaseInertiaVisual
();
44
45
// Documentation inherited.
46
protected
:
virtual
void
Init
()
override
;
47
48
// Documentation inherited.
49
protected
:
virtual
void
PreRender
()
override
;
50
51
// Documentation inherited.
52
public
:
virtual
void
SetInertial
(
53
const
gz::math::Inertiald
&_inertial)
override
;
54
55
// Documentation inherited.
56
public
:
virtual
void
Load
(
const
gz::math::Pose3d
&,
57
const
gz::math::Vector3d
&)
override
;
58
59
// Documentation inherited
60
public
:
virtual
VisualPtr
BoxVisual
()
const override
;
61
};
62
64
template
<
class
T>
65
BaseInertiaVisual<T>::BaseInertiaVisual
()
66
{
67
}
68
70
template
<
class
T>
71
BaseInertiaVisual<T>::~BaseInertiaVisual
()
72
{
73
}
74
76
template
<
class
T>
77
void
BaseInertiaVisual<T>::PreRender
()
78
{
79
T::PreRender();
80
}
81
83
template
<
class
T>
84
void
BaseInertiaVisual<T>::Init
()
85
{
86
T::Init();
87
}
88
90
template
<
class
T>
91
void
BaseInertiaVisual<T>::SetInertial
(
92
const
gz::math::Inertiald
&_inertial)
93
{
94
auto
xyz = _inertial.
Pose
().Pos();
95
auto
q = _inertial.
Pose
().Rot();
96
97
// Use gz::math::MassMatrix3 to compute
98
// equivalent box size and rotation
99
auto
m = _inertial.
MassMatrix
();
100
gz::math::Vector3d
boxScale;
101
gz::math::Quaterniond
boxRot;
102
if
(!m.EquivalentBox(boxScale, boxRot))
103
{
104
// Invalid inertia, load with default scale
105
gzlog
<<
"The link is static or has unrealistic "
106
<<
"inertia, so the equivalent inertia box will not be shown.\n"
;
107
}
108
else
109
{
110
// Apply additional rotation by boxRot
111
this->Load(
gz::math::Pose3d
(xyz, q * boxRot), boxScale);
112
}
113
}
114
116
template
<
class
T>
117
void
BaseInertiaVisual<T>::Load
(
const
gz::math::Pose3d
&,
118
const
gz::math::Vector3d
&)
119
{
120
// no op
121
}
122
124
template
<
class
T>
125
VisualPtr
BaseInertiaVisual<T>::BoxVisual
()
const
126
{
127
return
nullptr
;
128
}
129
}
130
}
131
}
132
#endif