MoveToLocationTask.cpp
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 RobotSkillTemplates::DynamicPlatformObstacleAvoidanceGroup
17  * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
18  * @date 2021
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #include "MoveToLocationTask.h"
24 
25 //#include <ArmarXCore/core/time/TimeUtil.h>
26 //#include <ArmarXCore/observers/variant/DatafieldRef.h>
27 
29 
31 {
32  // DO NOT EDIT NEXT LINE
33  MoveToLocationTask::SubClassRegistry MoveToLocationTask::Registry(MoveToLocationTask::GetName(), &MoveToLocationTask::CreateInstance);
34 
36  {
37  std::string locationName;
38  if (in.isargsSet() && in.getargs().size() > 0)
39  {
40  locationName = in.getargs().at(0)->entityName;
41  }
42  else if (in.isLandmarkNameSet())
43  {
44  locationName = in.getLandmarkName();
45  }
46  else
47  {
48  throw LocalException() << "You need to set either LandmarkName or args";
49  }
50  ARMARX_IMPORTANT << "Moving to location: " << locationName;
51 
52  try
53  {
54  if (in.getSendLocationToTTS() && in.getTextReply().count(locationName))
55  {
56  std::string const textReply = in.getTextReply().at(locationName);
57  getTextToSpeech()->reportText(textReply);
58  }
59  }
60  catch (std::exception const& ex)
61  {
62  ARMARX_WARNING << "Text output failed: " << ex.what();
63  }
64 
65  local.settargetLandmark(locationName);
66  }
67 
68  //void MoveToLocationTask::run()
69  //{
70  // // put your user code for the execution-phase here
71  // // runs in seperate thread, thus can do complex operations
72  // // should check constantly whether isRunningTaskStopped() returns true
73  //
74  // // get a private kinematic instance for this state of the robot (tick "Robot State Component" proxy checkbox in statechart group)
75  // VirtualRobot::RobotPtr robot = getLocalRobot();
76  //
77  //// uncomment this if you need a continous run function. Make sure to use sleep or use blocking wait to reduce cpu load.
78  // while (!isRunningTaskStopped()) // stop run function if returning true
79  // {
80  // // do your calculations
81  // // synchronize robot clone to most recent state
82  // RemoteRobot::synchronizeLocalClone(robot, getRobotStateComponent());
83  // }
84  //}
85 
86  //void MoveToLocationTask::onBreak()
87  //{
88  // // put your user code for the breaking point here
89  // // execution time should be short (<100ms)
90  //}
91 
93  {
94  // put your user code for the exit point here
95  // execution time should be short (<100ms)
96  }
97 
98 
99  // DO NOT EDIT NEXT FUNCTION
101  {
102  return XMLStateFactoryBasePtr(new MoveToLocationTask(stateData));
103  }
104 }
armarx::DynamicPlatformObstacleAvoidanceGroup::MoveToLocationTask::MoveToLocationTask
MoveToLocationTask(const XMLStateConstructorParams &stateData)
Definition: MoveToLocationTask.h:33
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:183
MoveToLocationTask.h
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::DynamicPlatformObstacleAvoidanceGroup
Definition: DynamicPlatformObstacleAvoidance.h:30
armarx::DynamicPlatformObstacleAvoidanceGroup::MoveToLocationTask::onExit
void onExit() override
Definition: MoveToLocationTask.cpp:92
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::DynamicPlatformObstacleAvoidanceGroup::MoveToLocationTask::Registry
static SubClassRegistry Registry
Definition: MoveToLocationTask.h:46
MemoryXCoreObjectFactories.h
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
armarx::DynamicPlatformObstacleAvoidanceGroup::MoveToLocationTask::onEnter
void onEnter() override
Definition: MoveToLocationTask.cpp:35
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::DynamicPlatformObstacleAvoidanceGroup::MoveToLocationTask::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: MoveToLocationTask.cpp:100