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
29namespace armarx
30{
31 // ****************************************************************
32 // Component and context
33 // ****************************************************************
34
36 {
39 {
40
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
#define ARMARXCOMPONENT_IMPORT_EXPORT
#define DEFINEEVENT(NEWEVENT)
this macro declares a new event-class derived vom Event, to have a compiletime check for typos in eve...
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
RobotControl is used for dynamically loading and starting robot programs.
StateBasePtr robotFunctionalState
Refernce to the currently active Functionsl state.
std::string getStateOffererName() const override
Implement this function to specify the RemoteStateOfferer prefix.
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
IceInternal::Handle< StateBase > StateBasePtr
Definition StateBase.h:49
Class that holds states, which offer functionality for other states over Ice.
RobotControlContextProperties(std::string prefix)
void onEnter() override
Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden,...
Statechart which describes the operational states of a robot program.
void onEnter() override
Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden,...
void defineSubstates() override
Virtual function, in which substates, transition and mappings can be added.
Statechart which describes the most basic states of a robot:
void defineState() override
Virtual function, in which this state can be configured.
void defineSubstates() override
Virtual function, in which substates, transition and mappings can be added.