Gazebo Gazebo

API Reference

3.15.1
GuardsImpl.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 <mutex>
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 guards
35 {
38 template <typename TargetState>
39 struct IsInState
40 {
43  public: template <typename Fsm, typename State>
44  bool operator()(const Fsm &_fsm, const State &)
45  {
46  // NOTE Mind the inversion; the internal transition table needs
47  // the guard to return false in order to trigger a transition
48  return !_fsm.template is_in_state<TargetState()>();
49  }
50 };
51 
54 {
57  public: template <typename Fsm, typename State>
58  bool operator()(const Fsm &_fsm, const State &)
59  {
60  std::lock_guard<std::recursive_mutex> lock(_fsm.dataPtr->system->mutex);
61  return _fsm.dataPtr->targets.front() == _fsm.dataPtr->system->state;
62  }
63 };
64 
67 {
70  public: template <typename Fsm, typename State>
71  bool operator()(const Fsm &_fsm, const State &)
72  {
73  std::lock_guard<std::recursive_mutex> lock(_fsm.dataPtr->system->mutex);
74  return _fsm.dataPtr->targets.empty();
75  }
76 };
77 
78 } // namespace guards
79 } // namespace systems
80 } // namespace IGNITION_GAZEBO_VERSION_NAMESPACE
81 } // namespace gazebo
82 } // namespace ignition
This library is part of the Ignition Robotics project.
bool operator()(const Fsm &_fsm, const State &)
Function call operator.
Definition: GuardsImpl.hh:58
STL class.
bool operator()(const Fsm &_fsm, const State &)
Function call operator.
Definition: GuardsImpl.hh:71
bool operator()(const Fsm &_fsm, const State &)
Function call operator.
Definition: GuardsImpl.hh:44
Guard that checks whether the cabin is at the target floor level.
Definition: GuardsImpl.hh:53
Guard that checks whether the target queue is empty.
Definition: GuardsImpl.hh:66