Gazebo Gazebo

API Reference

3.15.2
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 ignition
26 {
27 namespace gazebo
28 {
29 // Inline bracket to help doxygen filtering
30 inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE
31 {
32 namespace systems
33 {
34 namespace actions
35 {
39 template <bool trigger>
40 struct EnqueueNewTarget
41 {
47  public: template <typename Event, typename Fsm, typename Source,
48  typename Target>
49  void operator()(const Event &_event, Fsm &_fsm, Source & /*_source*/,
50  Target & /*_target*/)
51  {
52  _fsm.dataPtr->EnqueueNewTarget(_event.target);
53  if (trigger)
54  _fsm.process_event(events::NewTarget());
55  }
56 };
57 
60 struct NewTarget
61 {
67  public: template <typename Event, typename Fsm, typename Source,
68  typename Target>
69  void operator()(const Event & /*_event*/, Fsm &_fsm, Source & /*_source*/,
70  Target & /*_target*/)
71  {
72  std::lock_guard<std::recursive_mutex> lock(_fsm.dataPtr->system->mutex);
73  if (_fsm.dataPtr->targets.front() == _fsm.dataPtr->system->state)
74  _fsm.dataPtr->targets.pop_front();
75  }
76 };
77 
81 {
87  public: template <typename Event, typename Fsm, typename Source,
88  typename Target>
89  void operator()(const Event & /*_event*/, Fsm &_fsm, Source & /*_source*/,
90  Target & /*_target*/)
91  {
92  std::lock_guard<std::recursive_mutex> lock(_fsm.dataPtr->system->mutex);
93  _fsm.dataPtr->targets.pop_front();
94  }
95 };
96 
97 } // namespace actions
98 } // namespace systems
99 } // namespace IGNITION_GAZEBO_VERSION_NAMESPACE
100 } // namespace gazebo
101 } // namespace ignition
This library is part of the Ignition Robotics project.
STL class.
Action that cleans up the target queue when a new target is processed.
Definition: ActionsImpl.hh:60
Event that signifies a new target will be processed.
Definition: EventsImpl.hh:48
void operator()(const Event &, Fsm &_fsm, Source &, Target &)
Function call operator.
Definition: ActionsImpl.hh:89
Action that cleans up the target queue when the cabin reaches the target floor level.
Definition: ActionsImpl.hh:80
void operator()(const Event &_event, Fsm &_fsm, Source &, Target &)
Function call operator.
Definition: ActionsImpl.hh:49
void operator()(const Event &, Fsm &_fsm, Source &, Target &)
Function call operator.
Definition: ActionsImpl.hh:69