VisualServoTowardsTargetPoseWrapper.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::GraspObjectGroup
19  * @author David ( david dot schiebener at kit dot edu )
20  * @date 2014
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
26 
27 #include "VisualServoGroupStatechartContext.generated.h"
28 
29 
30 using namespace armarx;
31 using namespace VisualServoGroup;
32 
33 
34 // DO NOT EDIT NEXT LINE
36 
37 
38 
41  VisualServoTowardsTargetPoseWrapperGeneratedBase < VisualServoTowardsTargetPoseWrapper > (stateData)
42 {
43 }
44 
45 
46 
48 {
49  // install event ObjectPoseUpdated
50  VisualServoGroupStatechartContext* context = getContext<VisualServoGroupStatechartContext>();
51  // FramedPositionPtr objPos = in.getObjectInstanceChannel()->getDataField("position")->get<FramedPosition>();
52 
53  ChannelRefPtr handMemoryChannel = in.getHandMemoryChannel();
54  FramedPositionPtr handPosFromMemoryX;
55  memoryx::ChannelRefBaseSequence instances = context->getObjectMemoryObserver()->getObjectInstances(handMemoryChannel);
56 
57  if (instances.size() == 0)
58  {
59  ARMARX_WARNING << "No instances of the hand in the memory";
60  }
61  else
62  {
63  ARMARX_VERBOSE << "Getting hand pose from memory";
64 
65  handPosFromMemoryX = ChannelRefPtr::dynamicCast(instances.front())->get<FramedPosition>("position");
66  }
67 
68  if (handPosFromMemoryX && (handPosFromMemoryX->toGlobal(context->getRobot())->toEigen()
69  - in.getTcpTargetPose()->toGlobal(context->getRobot())->toEigen().block<3, 1>(0, 3)).norm() > in.getNoObjectUpdateDistance())
70  // if (!handPosFromMemoryX || (handPosFromMemoryX->toGlobal(context->getRobot())->toEigen()
71  // - in.getTcpTargetPose()->toGlobal(context->getRobot())->toEigen().block<3, 1>(0, 3)).norm() > in.getNoObjectUpdateDistance())
72  {
73  ChannelRefPtr objectInstanceChannel = in.getObjectInstanceChannel();
74  Literal poseUpdated(objectInstanceChannel->observerName + "." + objectInstanceChannel->channelName + ".position", "updated", {});
75  installCondition<ObjectPoseUpdated>(poseUpdated);
76  }
77 
78 
79 
80 }
81 
82 
83 
84 
85 
86 
88 {
89  // put your user code for the breaking point here
90  // execution time should be short (<100ms)
91 }
92 
93 
94 
96 {
97  // put your user code for the exit point here
98  // execution time should be short (<100ms)
99 }
100 
101 
102 
103 // DO NOT EDIT NEXT FUNCTION
105 {
106  return "VisualServoTowardsTargetPoseWrapper";
107 }
108 
109 
110 
111 // DO NOT EDIT NEXT FUNCTION
113 {
115 }
116 
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
armarx::VisualServoGroup::VisualServoTowardsTargetPoseWrapper::onEnter
void onEnter() override
Definition: VisualServoTowardsTargetPoseWrapper.cpp:47
armarx::VisualServoGroup::VisualServoTowardsTargetPoseWrapper
Definition: VisualServoTowardsTargetPoseWrapper.h:34
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::VisualServoGroup::VisualServoTowardsTargetPoseWrapper::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: VisualServoTowardsTargetPoseWrapper.cpp:112
VisualServoTowardsTargetPoseWrapper.h
IceInternal::Handle< ChannelRef >
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:137
armarx::FramedPosition
The FramedPosition class.
Definition: FramedPose.h:142
armarx::VisualServoGroup::VisualServoTowardsTargetPoseWrapper::onExit
void onExit() override
Definition: VisualServoTowardsTargetPoseWrapper.cpp:95
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
armarx::Literal
Definition: Term.h:208
armarx::VisualServoGroup::VisualServoTowardsTargetPoseWrapper::Registry
static SubClassRegistry Registry
Definition: VisualServoTowardsTargetPoseWrapper.h:48
armarx::VisualServoGroup::VisualServoTowardsTargetPoseWrapper::VisualServoTowardsTargetPoseWrapper
VisualServoTowardsTargetPoseWrapper(XMLStateConstructorParams stateData)
Definition: VisualServoTowardsTargetPoseWrapper.cpp:39
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::VisualServoGroup::VisualServoTowardsTargetPoseWrapper::GetName
static std::string GetName()
Definition: VisualServoTowardsTargetPoseWrapper.cpp:104
armarx::VisualServoGroup::VisualServoTowardsTargetPoseWrapper::onBreak
void onBreak() override
Definition: VisualServoTowardsTargetPoseWrapper.cpp:87
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28