RobotControl.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 Robot::
17 * @author Mirko Waechter( mirko.waechter at kit dot edu)
18 * @date 2012
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
27 #include <ArmarXCore/interface/operations/RobotControlIceBase.h>
28 
29 namespace armarx
30 {
31  // ****************************************************************
32  // Component and context
33  // ****************************************************************
34 
36  {
39  {
40 
41  defineOptionalProperty<std::string>("XMLStatechartProfile", "", "Name of the statechart profile to be used. This is used as prefix to the proxyName. So GraspGroupRemoteStateOfferer will be Armar3aGraspGroupRemoteStateOfferer");
42  defineOptionalProperty<std::string>("proxyName", "", "name of the proxy to load");
43  defineOptionalProperty<std::string>("stateName", "", "name of the state to load");
44  }
45  };
46 
47 
48 
49  /**
50  * \class RobotControl
51  * \brief RobotControl is used for dynamically loading and starting robot programs.
52  * \ingroup RobotAPI-Statecharts
53  *
54  * The toplevel state Statechart_Robot describes the basic operational levels
55  * of the robot.
56  *
57  * The behavior of the functional state is described in StateRobotControl
58  */
60  virtual public RemoteStateOfferer<StatechartContext>,
61  virtual public RobotControlIceBase
62  {
63  public:
64  /**
65  * Refernce to the currently active Functionsl state.
66  */
68  // inherited from RemoteStateOfferer
69  std::string getStateOffererName() const override
70  {
71  return "RobotControl";
72  }
73 
74  void onInitRemoteStateOfferer() override;
75  void onConnectRemoteStateOfferer() override;
76  void onExitRemoteStateOfferer() override;
77  void startRobotStatechart();
78 
79  void hardReset(const Ice::Current& = Ice::emptyCurrent) override;
80 
81  PropertyDefinitionsPtr createPropertyDefinitions() override;
82 
83  private:
84  void createStaticInstance();
86  int stateId;
87  };
88 
89  DEFINEEVENT(EvRobotFailure)
90  DEFINEEVENT(EvStopRobot)
91  DEFINEEVENT(EvStartRobot)
92  DEFINEEVENT(EvLoadingFailed)
93  /**
94  * Statechart which describes the most basic states of a robot:
95 
96  \dot
97  digraph States {
98  functional [ label="Functional (Initial State)" ];
99  stopped [ label="Stopped" ];
100  failure [ label="Failure" ];
101  functional -> failure [ label="Failure" ];
102  functional -> stopped [ label="EvStopRobot" ];
103  stopped -> functional [ label="EvStartRobot" ];
104  failure -> functional [ label="EvStartRobot" ];
105  }
106  \enddot
107  */
110  {
111  void defineState() override;
112  void defineSubstates() override;
113  };
114 
115 
116  DEFINEEVENT(EvInit)
117  DEFINEEVENT(EvInitialized)
118  DEFINEEVENT(EvLoadScenario)
119  DEFINEEVENT(EvStartScenario)
120  DEFINEEVENT(EvInitFailed)
121  /**
122  * Statechart which describes the operational states of a robot program.
123  * The state "Robot Program Running" is a DynamicRemoteState and needs to
124  * be passed the input parameters \p proxyName and \p stateName via Event
125  * parameters.
126 
127  \dot
128  digraph States {
129  idle [ label="Idling" ];
130  preinit [ label="RobotPreInitialized" ];
131  init [ label="RobotInitialized (Initial State)" ];
132  running [ label="Robot Program Running" ];
133  error [ label="FatalError" ];
134  idle -> preinit [ label="EvInit" ];
135  preinit -> init [ label="EvInitialized" ];
136  init -> running [ label="EvLoadScenario" ];
137  running -> preinit [ label="EvInit" ];
138  running -> preinit [ label="Success" ];
139  running -> error [ label="EvLoadingFailed" ];
140  preinit -> error [ label="EvInitFailed" ];
141  ALL -> error [ label="Failure" ];
142  }
143  \enddot
144  */
147  {
148  void onEnter() override;
149  void defineSubstates() override;
150  };
151 
152  /**
153  * Robot is in the state preinitialized.
154  */
156  StateTemplate<RobotPreInitialized>
157  {
159  void onEnter() override;
160  };
161 }
162 
armarx::RobotPreInitialized
Robot is in the state preinitialized.
Definition: RobotControl.h:155
armarx::RobotControlContextProperties::RobotControlContextProperties
RobotControlContextProperties(std::string prefix)
Definition: RobotControl.h:37
armarx::RobotPreInitialized::RobotPreInitialized
RobotPreInitialized()
Definition: RobotControl.cpp:166
armarx::StateTemplate
Definition: State.h:39
armarx::RobotControl::robotFunctionalState
StateBasePtr robotFunctionalState
Refernce to the currently active Functionsl state.
Definition: RobotControl.h:67
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
Statechart.h
IceInternal::Handle< StateBase >
armarx::RobotControl
RobotControl is used for dynamically loading and starting robot programs.
Definition: RobotControl.h:59
armarx::RemoteStateOfferer
Class that holds states, which offer functionality for other states over Ice.
Definition: RemoteStateOfferer.h:182
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
armarx::Statechart_Robot
Statechart which describes the most basic states of a robot:
Definition: RobotControl.h:108
armarx::RobotControlContextProperties
Definition: RobotControl.h:35
armarx::RobotPreInitialized::onEnter
void onEnter() override
Definition: RobotControl.cpp:170
IceUtil::Handle
Definition: forward_declarations.h:29
armarx::DEFINEEVENT
DEFINEEVENT(EvInit) struct StateRun
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::RobotControl::getStateOffererName
std::string getStateOffererName() const override
Implement this function to specify the RemoteStateOfferer prefix.
Definition: RobotControl.h:69
armarx::StatechartContextPropertyDefinitions
The StatechartContextPropertyDefinitions class contains properties associated with all statecharts.
Definition: StatechartContext.h:58
armarx::StateRobotControl
Statechart which describes the operational states of a robot program.
Definition: RobotControl.h:145
ImportExportComponent.h