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
27using namespace armarx;
28using namespace FindAndGraspObjectGroup;
29
30// DO NOT EDIT NEXT LINE
31WaitForUpdates::SubClassRegistry WaitForUpdates::Registry(WaitForUpdates::GetName(),
33
38
39void
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));
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
100void
102{
103 //removeCondition(condObjectPoseUpdated); //OLD
105}
106
107// DO NOT EDIT NEXT FUNCTION
108std::string
110{
111 return "WaitForUpdates";
112}
113
114// DO NOT EDIT NEXT FUNCTION
WaitForUpdates(XMLStateConstructorParams stateData)
void onEnter() override
Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden,...
void onExit() override
Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden,...
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Literals are part of the user front end of the ArmarX condition mechanism.
Definition Term.h:209
static VarList createParameterList()
Static helper method to create an empty parameterlist.
Definition Term.cpp:142
void removeCondition(ConditionIdentifier conditionId)
Utility function to remove an installed condition on the distributed conditionhandler.
EventPtr createEvent()
Utility function to create a new Event.
Definition StateUtil.h:63
ConditionIdentifier installCondition(const Term &condition, const EventPtr evt, const std::string &desc="")
Utility function to install a condition on the distributed conditionhandler.
std::enable_if_t< std::is_base_of_v< VariantDataClass, T >, IceInternal::Handle< T > > getInput(const std::string &key) const
getInput can be used to access a specific input parameter.
Definition State.h:620
XMLStateTemplate(const XMLStateConstructorParams &params)
Definition XMLState.h:149
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
Definition Logging.h:184
#define ARMARX_VERBOSE
The logging level for verbose information.
Definition Logging.h:187
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< ChannelRef > ChannelRefPtr
Definition ChannelRef.h:40
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64
IceInternal::Handle< FramedPose > FramedPosePtr
Definition FramedPose.h:272