Gazebo Gazebo

API Reference

3.15.1
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 {
40 namespace systems
41 {
42 // Data forward declarations
43 class ElevatorCommonPrivate;
44 class ElevatorStateMachinePrivate;
45 
46 // Event forward declarations
47 namespace events
48 {
49  struct EnqueueNewTarget;
50  struct NewTarget;
51  struct DoorOpen;
52  struct DoorClosed;
53  struct Timeout;
54  struct CabinAtTarget;
55 } // namespace events
56 
57 // Action forward declarations
58 namespace actions
59 {
60  template <bool>
62  struct NewTarget;
63  struct CabinAtTarget;
64 } // namespace actions
65 
66 // Guard forward declarations
67 namespace guards
68 {
69  template <typename TargetState>
70  struct IsInState;
71  struct CabinAtTarget;
72  struct NoQueuedTarget;
73 } // namespace guards
74 
78  : public ::afsm::def::state_machine<ElevatorStateMachineDef>
79 {
80  // State forward declarations
81  struct IdleState;
82  template <typename E>
83  struct DoorState;
84  struct OpenDoorState;
85  struct CloseDoorState;
86  struct WaitState;
87  struct MoveCabinState;
88 
94 
96  public: ~ElevatorStateMachineDef();
97 
99  public: using initial_state = IdleState;
100 
102  public: using internal_transitions = transition_table <
103  in<events::EnqueueNewTarget, actions::EnqueueNewTarget<true>,
105  in<events::EnqueueNewTarget, actions::EnqueueNewTarget<false>,
107  >;
108 
110  public: using transitions = transition_table<
111  // +--------------------------------------------------------------+
115  not_<guards::CabinAtTarget> >,
116  // +--------------------------------------------------------------+
117  tr<OpenDoorState, events::DoorOpen, WaitState, none, none>,
118  // +--------------------------------------------------------------+
119  tr<WaitState, events::Timeout, CloseDoorState, none, none>,
120  // +--------------------------------------------------------------+
124  not_<guards::NoQueuedTarget> >,
125  // +--------------------------------------------------------------+
128  >;
129 
132 };
133 
135 using ElevatorStateMachine = ::afsm::state_machine<ElevatorStateMachineDef>;
136 
137 } // namespace systems
138 } // namespace IGNITION_GAZEBO_VERSION_NAMESPACE
139 } // namespace gazebo
140 } // namespace ignition
141 
143 
144 #endif // GZ_GAZEBO_SYSTEMS_ELEVATOR_STATE_MACHINE_HH_
std::unique_ptr< ElevatorStateMachinePrivate > dataPtr
Public data pointer.
Definition: ElevatorStateMachine.hh:131
This library is part of the Ignition Robotics project.
Elevator state machine frontend. Defines the transition table and initial state of the state machine.
Definition: ElevatorStateMachine.hh:77
Event that signifies there is a new target that needs to be enqueued.
Definition: EventsImpl.hh:35
Event that signifies the cabin has reached the target floor level.
Definition: EventsImpl.hh:71
Event that signifies the door at the target floor level has been closed.
Definition: EventsImpl.hh:60
Event that signifies the door at the target floor level has been opened.
Definition: EventsImpl.hh:54
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:107
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:128
ElevatorStateMachineDef(const std::shared_ptr< ElevatorCommonPrivate > &_system)
Constructor.
Definition: ElevatorStateMachineImpl.hh:118
State at which the elevator is moving the cabin to the target floor.
Definition: StatesImpl.hh:195
State at which the elevator is waiting with a door open.
Definition: StatesImpl.hh:165
Guard that checks whether the state machine is in a given state.
Definition: ElevatorStateMachine.hh:70
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
Action that cleans up the target queue when the cabin reaches the target floor level.
Definition: ActionsImpl.hh:80
State at which the elevator is closing a door.
Definition: StatesImpl.hh:143
State at which the elevator is opening a door.
Definition: StatesImpl.hh:118
::afsm::state_machine< ElevatorStateMachineDef > ElevatorStateMachine
Elevator state machine backend.
Definition: ElevatorStateMachine.hh:135
Action that enqueues a new target in the target queue.
Definition: ElevatorStateMachine.hh:61
Guard that checks whether the cabin is at the target floor level.
Definition: GuardsImpl.hh:53
State at which the elevator is idling.
Definition: StatesImpl.hh:40
Guard that checks whether the target queue is empty.
Definition: GuardsImpl.hh:66
STL class.
Event that signifies the door at the target floor level has remained open for the required amount of ...
Definition: EventsImpl.hh:66