Go to the documentation of this file.
26 #include "../ElevatorStateMachine.hh"
28 #include <gz/common/Console.hh>
35 inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE
43 public:
template <
typename Event,
typename FSM>
52 struct ElevatorStateMachineDef::DoorState : state<DoorState<E>>
59 public: DoorState(
double _posEps = 2e-2,
double _velEps = 1e-2)
60 : posEps(_posEps), velEps(_velEps)
65 public:
virtual ~DoorState()
72 public:
template <
typename Event,
typename FSM>
73 void on_enter(
const Event &, FSM &_fsm)
75 const auto &data = _fsm.dataPtr;
76 int32_t floorTarget = data->system->state;
79 double jointTarget = this->JointTarget(data, floorTarget);
80 data->SendCmd(data->system->doorJointCmdPubs[floorTarget], jointTarget);
81 this->triggerEvent = [&_fsm] { _fsm.process_event(E()); };
82 data->system->SetDoorMonitor(
83 floorTarget, jointTarget, this->posEps, this->velEps,
84 std::bind(&DoorState::OnJointTargetReached,
this));
97 private:
virtual double JointTarget(
99 int32_t _floorTarget)
const = 0;
102 private:
void OnJointTargetReached()
104 this->triggerEvent();
108 private:
double posEps;
111 private:
double velEps;
134 private:
virtual double JointTarget(
136 int32_t _floorTarget)
const override
138 return _data->system->doorTargets[_floorTarget];
156 private:
virtual double JointTarget(
158 int32_t )
const override
172 public:
template <
typename Event,
typename FSM>
175 const auto &data = _fsm.dataPtr;
176 ignmsg <<
"The elevator is waiting to close door " << data->system->state
179 this->triggerEvent = [&_fsm] { _fsm.process_event(
events::Timeout()); };
180 data->system->StartDoorTimer(data->system->state,
185 private:
void OnTimeout()
187 this->triggerEvent();
206 : posEps(_posEps), velEps(_velEps)
213 public:
template <
typename Event,
typename FSM>
216 const auto &data = _fsm.dataPtr;
217 int32_t floorTarget = data->targets.front();
218 ignmsg <<
"The elevator is moving the cabin [ " << data->system->state
219 <<
" -> " << floorTarget <<
" ]" <<
std::endl;
221 double jointTarget = data->system->cabinTargets[floorTarget];
222 data->SendCmd(data->system->cabinJointCmdPub, jointTarget);
223 this->triggerEvent = [&_fsm] {
226 data->system->SetCabinMonitor(
227 floorTarget, jointTarget, this->posEps, this->velEps,
228 std::bind(&MoveCabinState::OnJointTargetReached,
this));
232 private:
void OnJointTargetReached()
234 this->triggerEvent();
238 private:
double posEps;
241 private:
double velEps;
type_tuple< events::EnqueueNewTarget > deferred_events
This state defers EnqueueNewTargetEvent events.
Definition: StatesImpl.hh:198
This library is part of the Ignition Robotics project.
MoveCabinState(double _posEps=15e-2, double _velEps=1e-2)
Constructor.
Definition: StatesImpl.hh:205
CloseDoorState()=default
Constructor.
Event that signifies the cabin has reached the target floor level.
Definition: EventsImpl.hh:71
type_tuple< events::EnqueueNewTarget > deferred_events
This state defers EnqueueNewTargetEvent events.
Definition: StatesImpl.hh:121
void on_enter(const Event &, FSM &)
Logs the entry to the state.
Definition: StatesImpl.hh:44
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
type_tuple< events::EnqueueNewTarget > deferred_events
This state defers EnqueueNewTargetEvent events.
Definition: StatesImpl.hh:168
State at which the elevator is closing a door.
Definition: StatesImpl.hh:143
void on_enter(const Event &, FSM &_fsm)
Sends the command that moves the cabin joint to the target floor and configures the monitor that chec...
Definition: StatesImpl.hh:214
State at which the elevator is opening a door.
Definition: StatesImpl.hh:118
void on_enter(const Event &, FSM &_fsm)
Starts the timer that keeps the door at the target floor level open.
Definition: StatesImpl.hh:173
State at which the elevator is idling.
Definition: StatesImpl.hh:40
OpenDoorState()=default
Constructor.
Event that signifies the door at the target floor level has remained open for the required amount of ...
Definition: EventsImpl.hh:66