SensorActorUnit.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarXCore::utils
17 * @author Kai Welke (welke@kit.edu)
18 * @date 2011
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
25 #include <mutex>
26 
30 
31 #include <RobotAPI/interface/units/UnitInterface.h>
32 
33 namespace armarx
34 {
35  /**
36  * \class SensorActorUnit
37  * \ingroup RobotAPI-SensorActorUnits
38  * \brief Base Class for SensorActorUnits.
39  *
40  * SensorActorUnits are ArmarX component which provide an actor API and a sensor data stream.
41  * The SensorActorUnit provides basic execution state handling and concurrent access handling.
42  */
44  virtual public SensorActorUnitInterface,
45  virtual public Component
46  {
47  public:
48  /**
49  * Constructs a SensorActorUnit.
50  */
52  /**
53  * Destructor of SensorActorUnit.
54  */
55  ~SensorActorUnit() override;
56 
57  /**
58  * Set execution state to eInitialized.
59  *
60  * Assures that init is called only once and the calls subclass method onInit().
61  *
62  * \param c Ice context provided by the Ice framework
63  */
64  void init(const Ice::Current& c = Ice::emptyCurrent) override;
65 
66  /**
67  * Set execution state to eStarted
68  *
69  * Start streaming of sensory data and acceptance of control data.
70  *
71  * Start can be called if the unit is initialized and not started yet (stopped).
72  * Calls subclass method inStart().
73  *
74  * \param c Ice context provided by the Ice framework
75  */
76  void start(const Ice::Current& c = Ice::emptyCurrent) override;
77 
78  /**
79  * Set execution state to eStopped
80  *
81  * Stop streaming of sensory data and acceptance of control data.
82  *
83  * Stop can be called if the unit is started.
84  * Calls subclass method onStop()
85  *
86  * \param c Ice context provided by the Ice framework
87  */
88  void stop(const Ice::Current& c = Ice::emptyCurrent) override;
89 
90  /**
91  * Retrieve current execution state
92  *
93  * \param c Ice context provided by the Ice framework
94  * \return current execution state
95  */
96  UnitExecutionState getExecutionState(const Ice::Current& c = Ice::emptyCurrent) override;
97 
98  /**
99  * Request exclusive access to current unit. Throws ResourceUnavailableException on error.
100  *
101  * \param c Ice context provided by the Ice framework
102  */
103  void request(const Ice::Current& c = Ice::emptyCurrent) override;
104 
105  /**
106  * Release exclusive access to current unit. Throws ResourceUnavailableException on error.
107  *
108  * \param c Ice context provided by the Ice framework
109  */
110  void release(const Ice::Current& c = Ice::emptyCurrent) override;
111 
112  protected:
113  void onExitComponent() override;
114  /**
115  * callback onInit for subclass hook. See init().
116  */
117  virtual void onInit(){};
118 
119  /**
120  * callback onStart for subclass hook. See start().
121  */
122  virtual void onStart(){};
123 
124  /**
125  * callback onStop for subclass hook. See stop().
126  */
127  virtual void onStop(){};
128 
129  std::mutex unitMutex;
131  UnitExecutionState executionState;
132  };
133 } // namespace armarx
armarx::SensorActorUnit::onInit
virtual void onInit()
callback onInit for subclass hook.
Definition: SensorActorUnit.h:117
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:570
armarx::SensorActorUnit::ownerId
Ice::Identity ownerId
Definition: SensorActorUnit.h:130
armarx::SensorActorUnit::executionState
UnitExecutionState executionState
Definition: SensorActorUnit.h:131
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:91
armarx::SensorActorUnit
Base Class for SensorActorUnits.
Definition: SensorActorUnit.h:43
ImportExport.h
armarx::SensorActorUnit::onStart
virtual void onStart()
callback onStart for subclass hook.
Definition: SensorActorUnit.h:122
ARMARXCORE_IMPORT_EXPORT
#define ARMARXCORE_IMPORT_EXPORT
Definition: ImportExport.h:38
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
Exception.h