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::NavigateToLocationGroup
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
34 MoveToLocationTask::Registry(MoveToLocationTask::GetName(),
36
37 void
39 {
40 std::string locationName;
41 if (in.isargsSet() && in.getargs().size() > 0)
42 {
43 locationName = in.getargs().at(0)->entityName;
44 }
45 else if (in.isLandmarkNameSet())
46 {
47 locationName = in.getLandmarkName();
48 }
49 else
50 {
51 throw LocalException() << "You need to set either LandmarkName or args";
52 }
53 ARMARX_IMPORTANT << "Moving to location: " << locationName;
54
55 try
56 {
57 if (in.getSendLocationToTTS() && in.getTextReply().count(locationName))
58 {
59 std::string const textReply = in.getTextReply().at(locationName);
60 getTextToSpeech()->reportText(textReply);
61 }
62 }
63 catch (std::exception const& ex)
64 {
65 ARMARX_WARNING << "Text output failed: " << ex.what();
66 }
67
68 local.settargetLandmark(locationName);
69 }
70
71 //void MoveToLocationTask::run()
72 //{
73 // // put your user code for the execution-phase here
74 // // runs in seperate thread, thus can do complex operations
75 // // should check constantly whether isRunningTaskStopped() returns true
76 //
77 // // get a private kinematic instance for this state of the robot (tick "Robot State Component" proxy checkbox in statechart group)
78 // VirtualRobot::RobotPtr robot = getLocalRobot();
79 //
80 //// uncomment this if you need a continous run function. Make sure to use sleep or use blocking wait to reduce cpu load.
81 // while (!isRunningTaskStopped()) // stop run function if returning true
82 // {
83 // // do your calculations
84 // // synchronize robot clone to most recent state
85 // RemoteRobot::synchronizeLocalClone(robot, getRobotStateComponent());
86 // }
87 //}
88
89 //void MoveToLocationTask::onBreak()
90 //{
91 // // put your user code for the breaking point here
92 // // execution time should be short (<100ms)
93 //}
94
95 void
97 {
98 // put your user code for the exit point here
99 // execution time should be short (<100ms)
100 }
101
102 // DO NOT EDIT NEXT FUNCTION
108} // namespace armarx::NavigateToLocationGroup
MoveToLocationTask(const XMLStateConstructorParams &stateData)
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64