Gazebo Sim

API Reference

10.1.1
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
25namespace gz
26{
27namespace sim
28{
29// Inline bracket to help doxygen filtering
30inline namespace GZ_SIM_VERSION_NAMESPACE {
31namespace systems
32{
33namespace actions
34{
38template <bool trigger>
40{
44 public: template <typename Event, typename Fsm, typename Source,
45 typename Target>
46 void operator()(const Event &_event, Fsm &_fsm, Source & /*_source*/,
47 Target & /*_target*/)
48 {
49 _fsm.dataPtr->EnqueueNewTarget(_event.target);
50 if (trigger)
51 _fsm.process_event(events::NewTarget());
52 }
53};
54
58{
61 public: template <typename Event, typename Fsm, typename Source,
62 typename Target>
63 void operator()(const Event & /*_event*/, Fsm &_fsm, Source & /*_source*/,
64 Target & /*_target*/)
65 {
66 std::lock_guard<std::recursive_mutex> lock(_fsm.dataPtr->system->mutex);
67 if (_fsm.dataPtr->targets.front() == _fsm.dataPtr->system->state)
68 _fsm.dataPtr->targets.pop_front();
69 }
70};
71
75{
78 public: template <typename Event, typename Fsm, typename Source,
79 typename Target>
80 void operator()(const Event & /*_event*/, Fsm &_fsm, Source & /*_source*/,
81 Target & /*_target*/)
82 {
83 std::lock_guard<std::recursive_mutex> lock(_fsm.dataPtr->system->mutex);
84 _fsm.dataPtr->targets.pop_front();
85 }
86};
87
88} // namespace actions
89} // namespace systems
90} // namespace GZ_SIM_VERSION_NAMESPACE
91} // namespace sim
92} // namespace gz