WaitForUpdates.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::FindAndGraspObjectGroup
19  * @author Valerij Wittenbeck ( valerij dot wittenbeck at student dot kit dot edu )
20  * @date 2014
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #include "WaitForUpdates.h"
26 
27 using namespace armarx;
28 using namespace FindAndGraspObjectGroup;
29 
30 // DO NOT EDIT NEXT LINE
32 
33 
34 
36  XMLStateTemplate < WaitForUpdates > (stateData)
37 {
38 }
39 
41 {
42  // retrieve channels
43  //ChannelRefPtr objectChannel = getInput<ChannelRef>("objectChannel"); //2014-03-07: not needed any more
44  ChannelRefPtr markerChannel = getInput<ChannelRef>("markerChannel");
45 
46  float minRecognitionLikelihood = getInput<float>("minRecognitionLikelihood");
47 
48  // condition for object update (EvObjectPoseUpdated)
49 
50  //OLD:
51  /*
52  Literal objectUpdated(*objectChannel->getDataFieldIdentifier("existenceCertainty"), "larger", Literal::createParameterList(minRecognitionLikelihood));
53  Literal markerUpdated(*markerChannel->getDataFieldIdentifier("existenceCertainty"), "larger", Literal::createParameterList(minRecognitionLikelihood));
54  Term objectOrMarkerUpdated = objectUpdated || markerUpdated;
55 
56  condObjectPoseUpdated = installCondition( objectUpdated,
57  createEvent<EvObjectPoseUpdate>());
58  */
59 
60  //NEW: now only marker update
61  Literal markerUpdated(*markerChannel->getDataFieldIdentifier("existenceCertainty"), "larger", Literal::createParameterList(minRecognitionLikelihood));
62  condMarkerPoseUpdated = installCondition(markerUpdated, createEvent<EvMarkerPoseUpdate>());
63 
64 
65  // Vector3Ptr relativePosition = getInput<Vector3>("relativeTargetPosition");
66  // QuaternionPtr relativeOrientation = getInput<Quaternion>("relativeTargetOrientation");
67 
68 
69  // TODO: target reached is not nice in this state. (LEGACY TODO)
70  // Once available install this as condition in toplevel state
71  // also remove the reference frame input
72  // VisualServoContext* visualServoContext = getContext<VisualServoContext>();
73  //std::string refFrame = getInput<std::string>("referenceFrame");
74 
75  //OLD:
76  //Eigen::Matrix4f objectPose_ref = getObjectPoseInRefFrame(objectChannel, refFrame, visualServoContext); //TODO: get objectPose_ref from elsewhere! (replace by framedPose)
77  //NEW:
78  FramedPosePtr targetPose = getInput<FramedPose>("targetPose");
79  //Eigen::Matrix4f objectPose_ref = targetPose->toEigen();
80 
81  std::string frame = targetPose->getFrame();
82  ARMARX_DEBUG << "Using frame " << frame;
83 
84  //Eigen::Matrix4f markerPose_ref = getObjectPoseInRefFrame(markerChannel, frame, visualServoContext);
85  /*
86  float distance = (objectPose_ref.block(0,3,3,1) - markerPose_ref.block(0,3,3,1)).norm();
87 
88  ARMARX_LOG << "Distance: " << distance << flush;
89  if(distance < 16.3f && distance >= 15.7f)
90  {
91  EventPtr reached = new EvTargetReached(EVENTTOALL);
92  sendEvent(reached);
93  }*/
94 
95  ARMARX_VERBOSE << "Done WaitForUpdates::onEnter()";
96 }
97 
99 {
100  //removeCondition(condObjectPoseUpdated); //OLD
102 }
103 
104 // DO NOT EDIT NEXT FUNCTION
106 {
107  return "WaitForUpdates";
108 }
109 
110 // DO NOT EDIT NEXT FUNCTION
112 {
113  return XMLStateFactoryBasePtr(new WaitForUpdates(stateData));
114 }
115 
armarx::StateUtility::removeCondition
void removeCondition(ConditionIdentifier conditionId)
Utility function to remove an installed condition on the distributed conditionhandler.
Definition: StateUtil.cpp:131
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
armarx::FindAndGraspObjectGroup::WaitForUpdates::condMarkerPoseUpdated
ConditionIdentifier condMarkerPoseUpdated
Definition: WaitForUpdates.h:53
armarx::FindAndGraspObjectGroup::WaitForUpdates
Definition: WaitForUpdates.h:34
armarx::FindAndGraspObjectGroup::WaitForUpdates::Registry
static SubClassRegistry Registry
Definition: WaitForUpdates.h:48
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::Literal::createParameterList
static VarList createParameterList()
Static helper method to create an empty parameterlist.
Definition: Term.cpp:129
IceInternal::Handle< ChannelRef >
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:137
WaitForUpdates.h
armarx::FindAndGraspObjectGroup::WaitForUpdates::GetName
static std::string GetName()
Definition: WaitForUpdates.cpp:105
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
armarx::FindAndGraspObjectGroup::WaitForUpdates::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: WaitForUpdates.cpp:111
armarx::StateUtility::installCondition
ConditionIdentifier installCondition(const Term &condition, const EventPtr evt, const std::string &desc="")
Utility function to install a condition on the distributed conditionhandler.
Definition: StateUtil.cpp:97
armarx::FindAndGraspObjectGroup::WaitForUpdates::onEnter
void onEnter() override
Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden,...
Definition: WaitForUpdates.cpp:40
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
armarx::FindAndGraspObjectGroup::WaitForUpdates::onExit
void onExit() override
Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden,...
Definition: WaitForUpdates.cpp:98
armarx::FindAndGraspObjectGroup::WaitForUpdates::WaitForUpdates
WaitForUpdates(XMLStateConstructorParams stateData)
Definition: WaitForUpdates.cpp:35
armarx::Literal
Definition: Term.h:208
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28