SelectObject.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 "SelectObject.h"
26 
27 using namespace armarx;
28 using namespace FindAndGraspObjectGroup;
29 
30 // DO NOT EDIT NEXT LINE
32 
33 
34 
36  XMLStateTemplate < SelectObject > (stateData)
37 {
38 }
39 
41 {
42  FindAndGraspObjectContext* context = getContext<FindAndGraspObjectContext>();
43 
44  memoryx::ChannelRefBaseSequence objectChannelRefs = context->objectMemoryObserver->getObjectInstances(getInput<ChannelRef>("objectChannel"));
45  memoryx::ChannelRefBaseSequence markerChannelRefs = context->objectMemoryObserver->getObjectInstances(getInput<ChannelRef>("markerChannel"));
46  ARMARX_DEBUG << "objectChannel available: " << objectChannelRefs.size() << "; " << "markerChannel available: " << markerChannelRefs.size();
47 
48  if (objectChannelRefs.size() == 0 || markerChannelRefs.size() == 0)
49  {
50  ARMARX_IMPORTANT << "object or marker channel ref not available (yet?)" << flush;
51  waitForObject = setTimeoutEvent(1000, createEvent<EvObjectInstanceNotAvailableYet>());
52  return;
53  }
54 
55  setOutput("objectInstanceChannel", objectChannelRefs.front());
56  setOutput("markerInstanceChannel", markerChannelRefs.front());
57 
58  ARMARX_DEBUG << "SelectObjectsState::onEnter(): objectChannelRefs.front(): " << objectChannelRefs.front() << " (to: setOutput())" << flush;
59  ARMARX_DEBUG << "SelectObjectsState::onEnter(): markerChannelRefs.front(): " << markerChannelRefs.front() << " (to: setOutput())" << flush;
60  sendEvent<EvObjectsSelected>();
61 
62  ARMARX_VERBOSE << "Done SelectObject::onEnter()" << flush;
63 }
64 
66 {
68 }
69 
70 // DO NOT EDIT NEXT FUNCTION
71 std::string SelectObject::GetName()
72 {
73  return "SelectObject";
74 }
75 
76 // DO NOT EDIT NEXT FUNCTION
78 {
79  return XMLStateFactoryBasePtr(new SelectObject(stateData));
80 }
81 
armarx::FindAndGraspObjectGroup::SelectObject
Definition: SelectObject.h:35
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:183
armarx::State::setOutput
void setOutput(std::string const &key, const Variant &value)
setOuput() sets an output parameter of this state.
Definition: State.cpp:434
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::FindAndGraspObjectGroup::SelectObject::onExit
void onExit() override
Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden,...
Definition: SelectObject.cpp:65
armarx::FindAndGraspObjectGroup::SelectObject::waitForObject
ActionEventIdentifier waitForObject
Definition: SelectObject.h:54
armarx::FindAndGraspObjectContext::objectMemoryObserver
memoryx::ObjectMemoryObserverInterfacePrx objectMemoryObserver
Definition: FindAndGraspObjectContext.h:152
armarx::FindAndGraspObjectContext
Definition: FindAndGraspObjectContext.h:67
SelectObject.h
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::StateUtility::setTimeoutEvent
ActionEventIdentifier setTimeoutEvent(int timeoutDurationMs, const EventPtr &evt)
Utility function to start a timer on the systemObserver and register an event on the conditionHandler...
Definition: StateUtil.cpp:144
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:137
armarx::flush
const LogSender::manipulator flush
Definition: LogSender.h:251
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
armarx::FindAndGraspObjectGroup::SelectObject::onEnter
void onEnter() override
Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden,...
Definition: SelectObject.cpp:40
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
armarx::FindAndGraspObjectGroup::SelectObject::Registry
static SubClassRegistry Registry
Definition: SelectObject.h:49
armarx::FindAndGraspObjectGroup::SelectObject::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: SelectObject.cpp:77
armarx::FindAndGraspObjectGroup::SelectObject::SelectObject
SelectObject(XMLStateConstructorParams stateData)
Definition: SelectObject.cpp:35
armarx::FindAndGraspObjectGroup::SelectObject::GetName
static std::string GetName()
Definition: SelectObject.cpp:71
armarx::StateUtility::removeTimeoutEvent
void removeTimeoutEvent(const ActionEventIdentifier &id)
Definition: StateUtil.cpp:178
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28