CalculateLandmarkPose.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2014-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package RobotSkillTemplates::CalculateLandmarkPoseGroup
19 * @author [Author Name] ( [Author Email] )
20 * @date 2014
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
26
28
30
31using namespace armarx;
32using namespace CoupledInteractionGroup;
33
34// DO NOT EDIT NEXT LINE
35CalculateLandmarkPose::SubClassRegistry
38
41 CalculateLandmarkPoseGeneratedBase<CalculateLandmarkPose>(stateData)
42{
43}
44
45void
47{
48
49 Vector3 landmarkVector;
50
52 getContext<CoupledInteractionGroupStatechartContext>();
53 auto graphSegment = context->getPriorKnowledgeProxy()->getGraphSegment();
54
55 //read scene name
56 std::string sceneName = in.getSceneName();
57
58 //does the scene exist
59 if (!graphSegment->hasScene(sceneName))
60 {
61 ARMARX_WARNING << "Target scene " << sceneName << " does not exist in menory" << flush;
62 out.setLandmarkPose(landmarkVector);
63 emitEvLandmarkPoseCalculationFailed();
64 return;
65 }
66
67 //does the target landmark exist
68 std::string landmark = in.getLandmarkName();
69 auto landmarkNode = graphSegment->getNodeFromSceneByName(sceneName, landmark);
70
71 if (!graphSegment->hasNodeWithName(sceneName, landmark))
72 {
73 ARMARX_WARNING << "Target landmark '" << landmark << "' doesn't exist in graph "
74 << sceneName << flush;
75 auto nodes = graphSegment->getNodesByScene(sceneName);
76
77 for (auto& node : nodes)
78 {
79 ARMARX_INFO << "node: " << node->getName();
80 }
81
82 out.setLandmarkPose(landmarkVector);
83 emitEvLandmarkPoseCalculationFailed();
84 return;
85 }
86
87 if (landmark != landmarkNode->getName())
88 {
89 ARMARX_IMPORTANT << "Resolved " << landmark << " to " << landmarkNode->getName();
90 }
91
92 FramedPosePtr landmarkPose = FramedPosePtr::dynamicCast(landmarkNode->getPose());
93
94 ARMARX_DEBUG << "CalcPath::onEnter(): Looking for path" << flush;
95
96 Eigen::Vector3f pose = landmarkPose->getPosition()->toEigen();
97 landmarkVector = Vector3(pose);
98 out.setLandmarkPose(landmarkVector);
99 emitEvLandmarkPoseCalculated();
100}
101
102void
104{
105
106 // put your user code for the exit point here
107 // execution time should be short (<100ms)
108}
109
110// DO NOT EDIT NEXT FUNCTION
111std::string
113{
114 return "CalculateLandmarkPose";
115}
116
117// DO NOT EDIT NEXT FUNCTION
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
The Vector3 class.
Definition Pose.h:113
Class for legacy to stay compatible with old statecharts.
Definition XMLState.h:147
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
Definition Logging.h:184
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
This file offers overloads of toIce() and fromIce() functions for STL container types.
const LogSender::manipulator flush
Definition LogSender.h:251
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64
IceInternal::Handle< FramedPose > FramedPosePtr
Definition FramedPose.h:272