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
31 WaitForUpdates::SubClassRegistry WaitForUpdates::Registry(WaitForUpdates::GetName(),
33 
36 {
37 }
38 
39 void
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"),
62  "larger",
63  Literal::createParameterList(minRecognitionLikelihood));
64  condMarkerPoseUpdated = installCondition(markerUpdated, createEvent<EvMarkerPoseUpdate>());
65 
66 
67  // Vector3Ptr relativePosition = getInput<Vector3>("relativeTargetPosition");
68  // QuaternionPtr relativeOrientation = getInput<Quaternion>("relativeTargetOrientation");
69 
70 
71  // TODO: target reached is not nice in this state. (LEGACY TODO)
72  // Once available install this as condition in toplevel state
73  // also remove the reference frame input
74  // VisualServoContext* visualServoContext = getContext<VisualServoContext>();
75  //std::string refFrame = getInput<std::string>("referenceFrame");
76 
77  //OLD:
78  //Eigen::Matrix4f objectPose_ref = getObjectPoseInRefFrame(objectChannel, refFrame, visualServoContext); //TODO: get objectPose_ref from elsewhere! (replace by framedPose)
79  //NEW:
80  FramedPosePtr targetPose = getInput<FramedPose>("targetPose");
81  //Eigen::Matrix4f objectPose_ref = targetPose->toEigen();
82 
83  std::string frame = targetPose->getFrame();
84  ARMARX_DEBUG << "Using frame " << frame;
85 
86  //Eigen::Matrix4f markerPose_ref = getObjectPoseInRefFrame(markerChannel, frame, visualServoContext);
87  /*
88  float distance = (objectPose_ref.block(0,3,3,1) - markerPose_ref.block(0,3,3,1)).norm();
89 
90  ARMARX_LOG << "Distance: " << distance << flush;
91  if(distance < 16.3f && distance >= 15.7f)
92  {
93  EventPtr reached = new EvTargetReached(EVENTTOALL);
94  sendEvent(reached);
95  }*/
96 
97  ARMARX_VERBOSE << "Done WaitForUpdates::onEnter()";
98 }
99 
100 void
102 {
103  //removeCondition(condObjectPoseUpdated); //OLD
105 }
106 
107 // DO NOT EDIT NEXT FUNCTION
108 std::string
110 {
111  return "WaitForUpdates";
112 }
113 
114 // DO NOT EDIT NEXT FUNCTION
117 {
118  return XMLStateFactoryBasePtr(new WaitForUpdates(stateData));
119 }
armarx::StateUtility::removeCondition
void removeCondition(ConditionIdentifier conditionId)
Utility function to remove an installed condition on the distributed conditionhandler.
Definition: StateUtil.cpp:148
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:187
armarx::FindAndGraspObjectGroup::WaitForUpdates::condMarkerPoseUpdated
ConditionIdentifier condMarkerPoseUpdated
Definition: WaitForUpdates.h:56
armarx::FindAndGraspObjectGroup::WaitForUpdates
Definition: WaitForUpdates.h:37
armarx::FindAndGraspObjectGroup::WaitForUpdates::Registry
static SubClassRegistry Registry
Definition: WaitForUpdates.h:51
armarx::XMLStateConstructorParams
Definition: XMLState.h:49
armarx::Literal::createParameterList
static VarList createParameterList()
Static helper method to create an empty parameterlist.
Definition: Term.cpp:142
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:64
IceInternal::Handle< ChannelRef >
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:146
WaitForUpdates.h
armarx::FindAndGraspObjectGroup::WaitForUpdates::GetName
static std::string GetName()
Definition: WaitForUpdates.cpp:109
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:184
armarx::FindAndGraspObjectGroup::WaitForUpdates::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: WaitForUpdates.cpp:116
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:102
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::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:101
armarx::FindAndGraspObjectGroup::WaitForUpdates::WaitForUpdates
WaitForUpdates(XMLStateConstructorParams stateData)
Definition: WaitForUpdates.cpp:34
armarx::Literal
Definition: Term.h:208
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27