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 #include <RobotAPI/interface/components/ViewSelectionInterface.h>
26 
28 
29 
30 using namespace armarx;
31 using namespace ObjectLocalization;
32 
33 // DO NOT EDIT NEXT LINE
34 RequestObjectLocalization::SubClassRegistry
35  RequestObjectLocalization::Registry(RequestObjectLocalization::GetName(),
37 
38 void
40 {
41  ARMARX_INFO << "Requesting object class " << in.getObjectName() << " with cycle time "
42  << in.getCycleTime() << ".";
43 
44  if (in.getObjectName().find("/") != std::string::npos)
45  {
46  // TODO: Check in ObjectPoseStorage whether the class is requested
47  ARMARX_INFO << "Using ObjectPoseStorage object, not setting ObjectChannel";
48  // out.setObjectChannel(nullptr);
49  emitSuccess();
50  return;
51  }
52 
53  memoryx::ObjectMemoryObserverInterfacePrx objectMemoryObserver = getObjectMemoryObserver();
54 
55  int priority = in.isPrioritySet() ? in.getPriority() : armarx::DEFAULT_VIEWTARGET_PRIORITY;
56 
57  int cycleTime = static_cast<int>(in.getCycleTime() / 1000.0f);
58  // todo test if object exists
59  ChannelRefBasePtr channelRef =
60  objectMemoryObserver->requestObjectClassRepeated(in.getObjectName(), cycleTime, priority);
61  if (channelRef)
62  {
63  out.setObjectChannel(channelRef);
64  emitSuccess();
65  }
66  else
67  {
68  emitFailure();
69  }
70 }
71 
72 //void RequestObjectLocalization::run()
73 //{
74 // // put your user code for the execution-phase here
75 // // runs in seperate thread, thus can do complex operations
76 // // should check constantly whether isRunningTaskStopped() returns true
77 //s
78 //// uncomment this if you need a continous run function. Make sure to use sleep or use blocking wait to reduce cpu load.
79 // while (!isRunningTaskStopped()) // stop run function if returning true
80 // {
81 // // do your calculations
82 // }
83 //}
84 
85 //void RequestObjectLocalization::onBreak()
86 //{
87 // // put your user code for the breaking point here
88 // // execution time should be short (<100ms)
89 //}
90 
91 void
93 {
94  // put your user code for the exit point here
95  // execution time should be short (<100ms)
96 }
97 
98 // DO NOT EDIT NEXT FUNCTION
101 {
102  return XMLStateFactoryBasePtr(new RequestObjectLocalization(stateData));
103 }
armarx::ObjectLocalization::RequestObjectLocalization::onExit
void onExit() override
Definition: RequestObjectLocalization.cpp:92
armarx::ObjectLocalization::RequestObjectLocalization::RequestObjectLocalization
RequestObjectLocalization(const XMLStateConstructorParams &stateData)
Definition: RequestObjectLocalization.h:33
armarx::XMLStateConstructorParams
Definition: XMLState.h:49
RequestObjectLocalization.h
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:64
IceInternal::Handle
Definition: forward_declarations.h:8
ObjectMemoryObserver.h
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx::ObjectLocalization::RequestObjectLocalization::Registry
static SubClassRegistry Registry
Definition: RequestObjectLocalization.h:47
armarx::ObjectLocalization::RequestObjectLocalization::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: RequestObjectLocalization.cpp:100
armarx::ObjectLocalization::RequestObjectLocalization::onEnter
void onEnter() override
Definition: RequestObjectLocalization.cpp:39
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27