Gazebo Sim
API Reference
10.1.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-sim
src
systems
elevator
state_machine
ActionsImpl.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
18
/*
19
* \author Nick Lamprianidis <nlamprian@gmail.com>
20
* \date January 2021
21
*/
22
23
#include "../ElevatorStateMachine.hh"
24
25
namespace
gz
26
{
27
namespace
sim
28
{
29
// Inline bracket to help doxygen filtering
30
inline
namespace
GZ_SIM_VERSION_NAMESPACE {
31
namespace
systems
32
{
33
namespace
actions
34
{
38
template
<
bool
trigger>
39
struct
EnqueueNewTarget
40
{
44
public
:
template
<
typename
Event,
typename
Fsm,
typename
Source,
45
typename
Target>
46
void
operator()
(
const
Event &_event, Fsm &_fsm, Source &
/*_source*/
,
47
Target &
/*_target*/
)
48
{
49
_fsm.dataPtr->EnqueueNewTarget(_event.target);
50
if
(trigger)
51
_fsm.process_event(
events::NewTarget
());
52
}
53
};
54
57
struct
NewTarget
58
{
61
public
:
template
<
typename
Event,
typename
Fsm,
typename
Source,
62
typename
Target>
63
void
operator()
(
const
Event &
/*_event*/
, Fsm &_fsm, Source &
/*_source*/
,
64
Target &
/*_target*/
)
65
{
66
std::lock_guard<std::recursive_mutex>
lock(_fsm.dataPtr->system->mutex);
67
if
(_fsm.dataPtr->targets.front() == _fsm.dataPtr->system->state)
68
_fsm.dataPtr->targets.pop_front();
69
}
70
};
71
74
struct
CabinAtTarget
75
{
78
public
:
template
<
typename
Event,
typename
Fsm,
typename
Source,
79
typename
Target>
80
void
operator()
(
const
Event &
/*_event*/
, Fsm &_fsm, Source &
/*_source*/
,
81
Target &
/*_target*/
)
82
{
83
std::lock_guard<std::recursive_mutex>
lock(_fsm.dataPtr->system->mutex);
84
_fsm.dataPtr->targets.pop_front();
85
}
86
};
87
88
}
// namespace actions
89
}
// namespace systems
90
}
// namespace GZ_SIM_VERSION_NAMESPACE
91
}
// namespace sim
92
}
// namespace gz