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 
25 #include "CalculateLandmarkPose.h"
27 
29 
30 using namespace armarx;
31 using namespace CoupledInteractionGroup;
32 
33 // DO NOT EDIT NEXT LINE
35 
36 
37 
39  XMLStateTemplate < CalculateLandmarkPose > (stateData), CalculateLandmarkPoseGeneratedBase < CalculateLandmarkPose > (stateData)
40 {
41 }
42 
44 {
45 
46  Vector3 landmarkVector;
47 
48  CoupledInteractionGroupStatechartContext* context = getContext<CoupledInteractionGroupStatechartContext>();
49  auto graphSegment = context->getPriorKnowledgeProxy()->getGraphSegment();
50 
51  //read scene name
52  std::string sceneName = in.getSceneName();
53 
54  //does the scene exist
55  if (!graphSegment->hasScene(sceneName))
56  {
57  ARMARX_WARNING << "Target scene " << sceneName << " does not exist in menory" << flush;
58  out.setLandmarkPose(landmarkVector);
59  emitEvLandmarkPoseCalculationFailed();
60  return;
61  }
62 
63  //does the target landmark exist
64  std::string landmark = in.getLandmarkName();
65  auto landmarkNode = graphSegment->getNodeFromSceneByName(sceneName, landmark);
66 
67  if (!graphSegment->hasNodeWithName(sceneName, landmark))
68  {
69  ARMARX_WARNING << "Target landmark '" << landmark << "' doesn't exist in graph " << sceneName << flush;
70  auto nodes = graphSegment->getNodesByScene(sceneName);
71 
72  for (auto& node : nodes)
73  {
74  ARMARX_INFO << "node: " << node->getName();
75  }
76 
77  out.setLandmarkPose(landmarkVector);
78  emitEvLandmarkPoseCalculationFailed();
79  return;
80  }
81 
82  if (landmark != landmarkNode->getName())
83  {
84  ARMARX_IMPORTANT << "Resolved " << landmark << " to " << landmarkNode->getName();
85  }
86 
87  FramedPosePtr landmarkPose = FramedPosePtr::dynamicCast(landmarkNode->getPose());
88 
89  ARMARX_DEBUG << "CalcPath::onEnter(): Looking for path" << flush;
90 
91  Eigen::Vector3f pose = landmarkPose->getPosition()->toEigen();
92  landmarkVector = Vector3(pose);
93  out.setLandmarkPose(landmarkVector);
94  emitEvLandmarkPoseCalculated();
95 
96 }
97 
98 
100 {
101 
102  // put your user code for the exit point here
103  // execution time should be short (<100ms)
104 
105 }
106 
107 // DO NOT EDIT NEXT FUNCTION
109 {
110  return "CalculateLandmarkPose";
111 }
112 
113 // DO NOT EDIT NEXT FUNCTION
115 {
116  return XMLStateFactoryBasePtr(new CalculateLandmarkPose(stateData));
117 }
118 
RemoteRobot.h
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:183
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getPriorKnowledgeProxy
memoryx::PriorKnowledgeInterfacePrx getPriorKnowledgeProxy()
Definition: CoupledInteractionGroupStatechartContext.h:133
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::CoupledInteractionGroup::CalculateLandmarkPose::GetName
static std::string GetName()
Definition: CalculateLandmarkPose.cpp:108
IceInternal::Handle< FramedPose >
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:137
armarx::CoupledInteractionGroup::CalculateLandmarkPose::CalculateLandmarkPose
CalculateLandmarkPose(XMLStateConstructorParams stateData)
Definition: CalculateLandmarkPose.cpp:38
armarx::flush
const LogSender::manipulator flush
Definition: LogSender.h:251
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
armarx::CoupledInteractionGroup::CalculateLandmarkPose::Registry
static SubClassRegistry Registry
Definition: CalculateLandmarkPose.h:48
armarx::Vector3
The Vector3 class.
Definition: Pose.h:112
armarx::CoupledInteractionGroup::CalculateLandmarkPose::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: CalculateLandmarkPose.cpp:114
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
memoryx::KBM::Vector3
Eigen::Vector3d Vector3
Definition: kbm.h:41
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext
Definition: CoupledInteractionGroupStatechartContext.h:88
armarx::CoupledInteractionGroup::CalculateLandmarkPose::onExit
void onExit() override
Definition: CalculateLandmarkPose.cpp:99
CalculateLandmarkPose.h
Logging.h
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::CoupledInteractionGroup::CalculateLandmarkPose
Definition: CalculateLandmarkPose.h:34
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::CoupledInteractionGroup::CalculateLandmarkPose::onEnter
void onEnter() override
Definition: CalculateLandmarkPose.cpp:43