Gazebo Gazebo

API Reference

6.16.0
ElevatorStateMachine.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 #ifndef GZ_GAZEBO_SYSTEMS_ELEVATOR_STATE_MACHINE_HH_
24 #define GZ_GAZEBO_SYSTEMS_ELEVATOR_STATE_MACHINE_HH_
25 
26 #include <memory>
27 
28 #include <gz/sim/Entity.hh>
29 #include <gz/transport/Node.hh>
30 
31 #include "afsm/fsm.hpp"
32 
33 namespace ignition
34 {
35 namespace gazebo
36 {
37 // Inline bracket to help doxygen filtering
38 inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
39 namespace systems
40 {
41 // Data forward declarations
42 class ElevatorCommonPrivate;
43 class ElevatorStateMachinePrivate;
44 
45 // Event forward declarations
46 namespace events
47 {
48  struct EnqueueNewTarget;
49  struct NewTarget;
50  struct DoorOpen;
51  struct DoorClosed;
52  struct Timeout;
53  struct CabinAtTarget;
54 } // namespace events
55 
56 // Action forward declarations
57 namespace actions
58 {
59  template <bool>
61  struct NewTarget;
62  struct CabinAtTarget;
63 } // namespace actions
64 
65 // Guard forward declarations
66 namespace guards
67 {
68  template <typename TargetState>
69  struct IsInState;
70  struct CabinAtTarget;
71  struct NoQueuedTarget;
72 } // namespace guards
73 
77  : public ::afsm::def::state_machine<ElevatorStateMachineDef>
78 {
79  // State forward declarations
80  struct IdleState;
81  template <typename E>
82  struct DoorState;
83  struct OpenDoorState;
84  struct CloseDoorState;
85  struct WaitState;
86  struct MoveCabinState;
87 
93 
95  public: ~ElevatorStateMachineDef();
96 
98  public: using initial_state = IdleState;
99 
101  public: using internal_transitions = transition_table <
102  in<events::EnqueueNewTarget, actions::EnqueueNewTarget<true>,
104  in<events::EnqueueNewTarget, actions::EnqueueNewTarget<false>,
106  >;
107 
109  public: using transitions = transition_table<
110  // +--------------------------------------------------------------+
114  not_<guards::CabinAtTarget> >,
115  // +--------------------------------------------------------------+
116  tr<OpenDoorState, events::DoorOpen, WaitState, none, none>,
117  // +--------------------------------------------------------------+
118  tr<WaitState, events::Timeout, CloseDoorState, none, none>,
119  // +--------------------------------------------------------------+
123  not_<guards::NoQueuedTarget> >,
124  // +--------------------------------------------------------------+
127  >;
128 
131 };
132 
134 using ElevatorStateMachine = ::afsm::state_machine<ElevatorStateMachineDef>;
135 
136 } // namespace systems
137 } // namespace IGNITION_GAZEBO_VERSION_NAMESPACE
138 } // namespace gazebo
139 } // namespace ignition
140 
142 
143 #endif // GZ_GAZEBO_SYSTEMS_ELEVATOR_STATE_MACHINE_HH_
ElevatorStateMachineDef(const std::shared_ptr< ElevatorCommonPrivate > &_system)
Constructor.
Definition: ElevatorStateMachineImpl.hh:117
Event that signifies there is a new target that needs to be enqueued.
Definition: EventsImpl.hh:34
This library is part of the Gazebo project.
Guard that checks whether the state machine is in a given state.
Definition: ElevatorStateMachine.hh:69
Action that cleans up the target queue when a new target is processed.
Definition: ActionsImpl.hh:59
transition_table< in< events::EnqueueNewTarget, actions::EnqueueNewTarget< true >, guards::IsInState< IdleState > >, in< events::EnqueueNewTarget, actions::EnqueueNewTarget< false >, guards::IsInState< CloseDoorState > > > internal_transitions
Transition transition table.
Definition: ElevatorStateMachine.hh:106
Action that cleans up the target queue when the cabin reaches the target floor level.
Definition: ActionsImpl.hh:79
Action that enqueues a new target in the target queue.
Definition: ElevatorStateMachine.hh:60
std::unique_ptr< ElevatorStateMachinePrivate > dataPtr
Public data pointer.
Definition: ElevatorStateMachine.hh:130
State at which the elevator is moving the cabin to the target floor.
Definition: StatesImpl.hh:194
State at which the elevator is waiting with a door open.
Definition: StatesImpl.hh:164
State at which the elevator is idling.
Definition: StatesImpl.hh:39
Event that signifies the cabin has reached the target floor level.
Definition: EventsImpl.hh:70
State at which the elevator is closing a door.
Definition: StatesImpl.hh:142
transition_table< tr< IdleState, events::NewTarget, OpenDoorState, actions::NewTarget, guards::CabinAtTarget >, tr< IdleState, events::NewTarget, MoveCabinState, actions::NewTarget, not_< guards::CabinAtTarget > >, tr< OpenDoorState, events::DoorOpen, WaitState, none, none >, tr< WaitState, events::Timeout, CloseDoorState, none, none >, tr< CloseDoorState, events::DoorClosed, IdleState, none, guards::NoQueuedTarget >, tr< CloseDoorState, events::DoorClosed, MoveCabinState, none, not_< guards::NoQueuedTarget > >, tr< MoveCabinState, events::CabinAtTarget, OpenDoorState, actions::CabinAtTarget, none > > transitions
Transition table.
Definition: ElevatorStateMachine.hh:127
Event that signifies the door at the target floor level has been opened.
Definition: EventsImpl.hh:53
Event that signifies the door at the target floor level has remained open for the required amount of ...
Definition: EventsImpl.hh:65
Elevator state machine frontend. Defines the transition table and initial state of the state machine.
Definition: ElevatorStateMachine.hh:76
State at which the elevator is opening a door.
Definition: StatesImpl.hh:117
Guard that checks whether the cabin is at the target floor level.
Definition: GuardsImpl.hh:52
Event that signifies the door at the target floor level has been closed.
Definition: EventsImpl.hh:59
Guard that checks whether the target queue is empty.
Definition: GuardsImpl.hh:65
STL class.
::afsm::state_machine< ElevatorStateMachineDef > ElevatorStateMachine
Elevator state machine backend.
Definition: ElevatorStateMachine.hh:134
Event that signifies a new target will be processed.
Definition: EventsImpl.hh:47