Gazebo Sim
API Reference
9.0.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
include
gz
sim
components
components/Actor.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2019 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_SIM_COMPONENTS_ACTOR_HH_
18
#define GZ_SIM_COMPONENTS_ACTOR_HH_
19
20
#include <gz/msgs/actor.pb.h>
21
22
#include <chrono>
23
#include <ratio>
24
#include <string>
25
26
#include <sdf/Actor.hh>
27
28
#include <
gz/sim/components/Factory.hh
>
29
#include <
gz/sim/components/Component.hh
>
30
#include <
gz/sim/components/Serialization.hh
>
31
#include <
gz/sim/Conversions.hh
>
32
#include <gz/sim/config.hh>
33
34
namespace
gz
35
{
36
namespace
sim
37
{
38
// Inline bracket to help doxygen filtering.
39
inline
namespace
GZ_SIM_VERSION_NAMESPACE {
40
namespace
serializers
41
{
42
using
ActorSerializer
=
43
serializers::ComponentToMsgSerializer<sdf::Actor, msgs::Actor>
;
44
45
class
AnimationTimeSerializer
46
{
51
public
:
static
std::ostream
&
Serialize
(
std::ostream
&_out,
52
const
std::chrono::steady_clock::duration &_time)
53
{
54
_out << std::chrono::duration_cast<std::chrono::nanoseconds>(
55
_time).count();
56
return
_out;
57
}
58
63
public
:
static
std::istream
&
Deserialize
(
std::istream
&_in,
64
std::chrono::steady_clock::duration &_time)
65
{
66
int64_t time;
67
_in >> time;
68
_time =
std::chrono::duration<int64_t, std::nano>
(time);
69
return
_in;
70
}
71
};
72
}
73
74
namespace
components
75
{
79
using
Actor
=
80
Component<sdf::Actor, class ActorTag, serializers::ActorSerializer>
;
81
GZ_SIM_REGISTER_COMPONENT
(
"gz_sim_components.Actor"
,
Actor
)
82
83
84
using
AnimationTime =
Component
<std::chrono::steady_clock::duration,
85
class
AnimationTimeTag, serializers::AnimationTimeSerializer>;
86
GZ_SIM_REGISTER_COMPONENT
("gz_sim_components.AnimationTime",
87
AnimationTime)
88
90
using AnimationName =
Component
<std::string, class AnimationNameTag,
91
serializers::StringSerializer>;
92
GZ_SIM_REGISTER_COMPONENT
("gz_sim_components.AnimationName",
93
AnimationName)
94
}
95
}
96
}
97
}
98
99
#endif