RequestObjectLocalization.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package RobotSkillTemplates::ObjectLocalization
17  * @author Markus Grotz ( markus dot grotz at kit dot edu )
18  * @date 2016
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
24 
25 
27 #include <RobotAPI/interface/components/ViewSelectionInterface.h>
28 
29 
30 using namespace armarx;
31 using namespace ObjectLocalization;
32 
33 // DO NOT EDIT NEXT LINE
34 RequestObjectLocalization::SubClassRegistry RequestObjectLocalization::Registry(RequestObjectLocalization::GetName(), &RequestObjectLocalization::CreateInstance);
35 
36 
37 
39 {
40  ARMARX_INFO << "Requesting object class " << in.getObjectName() << " with cycle time " << in.getCycleTime() << ".";
41 
42  if (in.getObjectName().find("/") != std::string::npos)
43  {
44  // TODO: Check in ObjectPoseStorage whether the class is requested
45  ARMARX_INFO << "Using ObjectPoseStorage object, not setting ObjectChannel";
46  // out.setObjectChannel(nullptr);
47  emitSuccess();
48  return;
49  }
50 
51  memoryx::ObjectMemoryObserverInterfacePrx objectMemoryObserver = getObjectMemoryObserver();
52 
53  int priority = in.isPrioritySet() ? in.getPriority() : armarx::DEFAULT_VIEWTARGET_PRIORITY;
54 
55  int cycleTime = static_cast<int>(in.getCycleTime() / 1000.0f);
56  // todo test if object exists
57  ChannelRefBasePtr channelRef = objectMemoryObserver->requestObjectClassRepeated(in.getObjectName(), cycleTime, priority);
58  if (channelRef)
59  {
60  out.setObjectChannel(channelRef);
61  emitSuccess();
62  }
63  else
64  {
65  emitFailure();
66  }
67 }
68 
69 //void RequestObjectLocalization::run()
70 //{
71 // // put your user code for the execution-phase here
72 // // runs in seperate thread, thus can do complex operations
73 // // should check constantly whether isRunningTaskStopped() returns true
74 //s
75 //// uncomment this if you need a continous run function. Make sure to use sleep or use blocking wait to reduce cpu load.
76 // while (!isRunningTaskStopped()) // stop run function if returning true
77 // {
78 // // do your calculations
79 // }
80 //}
81 
82 //void RequestObjectLocalization::onBreak()
83 //{
84 // // put your user code for the breaking point here
85 // // execution time should be short (<100ms)
86 //}
87 
89 {
90  // put your user code for the exit point here
91  // execution time should be short (<100ms)
92 }
93 
94 
95 // DO NOT EDIT NEXT FUNCTION
97 {
99 }
100 
armarx::ObjectLocalization::RequestObjectLocalization::onExit
void onExit() override
Definition: RequestObjectLocalization.cpp:88
armarx::ObjectLocalization::RequestObjectLocalization::RequestObjectLocalization
RequestObjectLocalization(const XMLStateConstructorParams &stateData)
Definition: RequestObjectLocalization.h:33
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
RequestObjectLocalization.h
IceInternal::Handle
Definition: forward_declarations.h:8
ObjectMemoryObserver.h
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::ObjectLocalization::RequestObjectLocalization::Registry
static SubClassRegistry Registry
Definition: RequestObjectLocalization.h:46
armarx::ObjectLocalization::RequestObjectLocalization::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: RequestObjectLocalization.cpp:96
armarx::ObjectLocalization::RequestObjectLocalization::onEnter
void onEnter() override
Definition: RequestObjectLocalization.cpp:38
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28