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