DetachObjectInMemory.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::MemoryXUtility
17 * @author Fabian Paus ( fabian dot paus at kit dot edu )
18 * @date 2019
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
24
25//#include <ArmarXCore/core/time/TimeUtil.h>
26//#include <ArmarXCore/observers/variant/DatafieldRef.h>
27
29
30using namespace armarx;
31using namespace MemoryXUtility;
32
33// DO NOT EDIT NEXT LINE
34DetachObjectInMemory::SubClassRegistry
35 DetachObjectInMemory::Registry(DetachObjectInMemory::GetName(),
37
38void
40{
41 memoryx::ObjectInstanceMemorySegmentBasePrx instanceMemory =
42 getWorkingMemory()->getObjectInstancesSegment();
43 std::string attachedObjectId;
44
45 if (in.isAttachedObjectChannelSet() and in.getAttachedObjectChannel())
46 {
47 try
48 {
49 TimedVariantPtr idField =
50 ChannelRefPtr::dynamicCast(in.getAttachedObjectChannel())->getDataField("id");
51 attachedObjectId = idField->getString();
52 }
53 catch (std::exception const& ex)
54 {
55 ARMARX_WARNING << "Could not get ID of attached object from channel. Reason:\n"
56 << ex.what();
57 throw;
58 }
59 }
60 else if (in.isAttachedObjectIDSet())
61 {
62 attachedObjectId = in.getAttachedObjectID();
63 }
64 else
65 {
66 ARMARX_INFO << "Attached object is not defined. Either set ID or channel!";
67 emitFailure();
68 return;
69 }
70
72 new memoryx::MotionModelStaticObject(getRobotStateComponent()));
73 getWorkingMemory()->getObjectInstancesSegment()->setNewMotionModel(attachedObjectId,
74 newMotionModel);
75 emitSuccess();
76}
77
78//void DetachObjectInMemory::run()
79//{
80// // put your user code for the execution-phase here
81// // runs in seperate thread, thus can do complex operations
82// // should check constantly whether isRunningTaskStopped() returns true
83//
84//// uncomment this if you need a continous run function. Make sure to use sleep or use blocking wait to reduce cpu load.
85// while (!isRunningTaskStopped()) // stop run function if returning true
86// {
87// // do your calculations
88// }
89//}
90
91//void DetachObjectInMemory::onBreak()
92//{
93// // put your user code for the breaking point here
94// // execution time should be short (<100ms)
95//}
96
97void
99{
100 // put your user code for the exit point here
101 // execution time should be short (<100ms)
102}
103
104// DO NOT EDIT NEXT FUNCTION
DetachObjectInMemory(const XMLStateConstructorParams &stateData)
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< TimedVariant > TimedVariantPtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64
IceInternal::Handle< MotionModelStaticObject > MotionModelStaticObjectPtr