CalculateTarget.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::GraspObjectGroup
19 * @author David ( david dot schiebener at 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 "CalculateTarget.h"
26
27#include "GraspObjectGroupStatechartContext.generated.h"
28
29using namespace armarx;
30using namespace GraspObjectGroup;
31
32// DO NOT EDIT NEXT LINE
33CalculateTarget::SubClassRegistry CalculateTarget::Registry(CalculateTarget::GetName(),
35
38 CalculateTargetGeneratedBase<CalculateTarget>(stateData)
39{
40}
41
42void
44{
45 // get hand pose from MemoryX
46 GraspObjectGroupStatechartContext* context = getContext<GraspObjectGroupStatechartContext>();
47 FramedPose handPoseFromMemoryX;
48 ChannelRefPtr handMemoryChannel = getInput<ChannelRef>("HandMemoryChannel");
49 memoryx::ChannelRefBaseSequence instances =
50 context->getObjectMemoryObserver()->getObjectInstances(handMemoryChannel);
51
52 if (instances.size() == 0)
53 {
54 ARMARX_ERROR << "No instances of the hand in the memory";
55 return;
56 }
57 else
58 {
59 ARMARX_VERBOSE << "Getting hand pose from memory";
60
61 FramedPositionPtr position =
62 ChannelRefPtr::dynamicCast(instances.front())->get<FramedPosition>("position");
63 FramedOrientationPtr orientation =
64 ChannelRefPtr::dynamicCast(instances.front())->get<FramedOrientation>("orientation");
65 handPoseFromMemoryX = FramedPose(
66 orientation->toEigen(), position->toEigen(), position->getFrame(), position->agent);
67
68 if (position->getFrame().empty())
69 {
70 ARMARX_WARNING << "Empty frame name!";
71 }
72 }
73
74 ARMARX_IMPORTANT << "Hand pose from MemoryX: " << handPoseFromMemoryX;
75
76 Eigen::Vector3f liftTranslation = in.getLiftTranslation()->toEigen();
77 Eigen::Matrix4f targetEigen1 = handPoseFromMemoryX.toRootEigen(getRobot());
78 targetEigen1(2, 3) += 0.7f * liftTranslation(2);
79 FramedPose target1(
80 targetEigen1, getRobot()->getRootNode()->getName(), handPoseFromMemoryX.agent);
81 out.setTcpTargetPose1(target1);
82 Eigen::Matrix4f targetEigen2 = handPoseFromMemoryX.toRootEigen(getRobot());
83 targetEigen2.block<3, 1>(0, 3) += liftTranslation;
84 FramedPose target2(
85 targetEigen1, getRobot()->getRootNode()->getName(), handPoseFromMemoryX.agent);
86 out.setTcpTargetPose2(target2);
87
88 emitTargetCalculated();
89}
90
91void
93{
94 // put your user code for the breaking point here
95 // execution time should be short (<100ms)
96}
97
98void
100{
101 // put your user code for the exit point here
102 // execution time should be short (<100ms)
103}
104
105// DO NOT EDIT NEXT FUNCTION
The FramedOrientation class.
Definition FramedPose.h:216
The FramedPose class.
Definition FramedPose.h:281
Eigen::Matrix4f toRootEigen(const SharedRobotInterfacePrx &referenceRobot) const
The FramedPosition class.
Definition FramedPose.h:158
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
CalculateTarget(XMLStateConstructorParams stateData)
virtual Eigen::Matrix4f toEigen() const
Definition Pose.cpp:334
Class for legacy to stay compatible with old statecharts.
Definition XMLState.h:147
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
Definition Logging.h:196
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
#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< FramedPosition > FramedPositionPtr
Definition FramedPose.h:149
IceInternal::Handle< FramedOrientation > FramedOrientationPtr
Definition FramedPose.h:207
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64