ReleaseTable.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::ReleaseTableGroup
19 * @author [Author Name] ( [Author Email] )
20 * @date 2014
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#include "ReleaseTable.h"
26
28
31
32using namespace armarx;
33using namespace CoupledInteractionGroup;
34
35// DO NOT EDIT NEXT LINE
36ReleaseTable::SubClassRegistry ReleaseTable::Registry(ReleaseTable::GetName(),
38
40 XMLStateTemplate<ReleaseTable>(stateData), ReleaseTableGeneratedBase<ReleaseTable>(stateData)
41{
42}
43
44void
46{
47 //CoupledInteractionGroupStatechartContext* context = getContext<CoupledInteractionGroupStatechartContext>();
48 float goBackDistance = in.getGoBackDistance();
49 Eigen::Vector3f targetPoseRelativeVec;
50 targetPoseRelativeVec(0) = 0.0;
51 targetPoseRelativeVec(1) = -goBackDistance;
52 targetPoseRelativeVec(2) = 0.0;
53 std::vector<std::string> jointNames;
54 jointNames.push_back("Shoulder 2 L"); // -> Pitch
55 jointNames.push_back("Shoulder 2 R"); // -> Pitch
56 jointNames.push_back("Upperarm L"); // -> Pitch
57 jointNames.push_back("Upperarm R"); // -> Pitch
58 jointNames.push_back("Elbow L"); // -> Pitch
59 jointNames.push_back("Elbow R"); // -> Pitch
60 local.setGoBackJointNames(jointNames);
61
62
63 std::vector<float> targetJointValues;
64 targetJointValues.push_back(0.5);
65 targetJointValues.push_back(0.5);
66 targetJointValues.push_back(0.0);
67 targetJointValues.push_back(0.0);
68 targetJointValues.push_back(-0.5);
69 targetJointValues.push_back(-0.5);
70 local.setGoBackTargetJointValues(targetJointValues);
71 local.setPlatformTargetPose(Vector3(targetPoseRelativeVec));
72}
73
74void
76{
78 getContext<CoupledInteractionGroupStatechartContext>();
79
80 // detach table from hand
81 // is always executed, even if release failed (but that should be ok)
82
83 // todo: get object class name from input
84 std::string objClassName = "lighttable"; // in.getObjectClassName();
85 auto instances =
86 context->getWorkingMemoryProxy()->getObjectInstancesSegment()->getObjectInstancesByClass(
87 objClassName);
88
89 if (instances.size() > 0)
90 {
91 memoryx::ObjectInstanceBasePtr obj = instances.front();
93 memoryx::ObjectInstancePtr obj2 = memoryx::ObjectInstancePtr::dynamicCast(obj);
94 FramedPosePtr pose = obj2->getPose();
95 ARMARX_VERBOSE << "Detaching " << objClassName << " from hand. Setting pose to:\n"
96 << pose->output();
97
100 context->getWorkingMemoryProxy()->getObjectInstancesSegment()->setObjectPose(
101 obj->getId(),
102 new LinkedPose(*pose,
103 context->getRobotStateComponent()->getRobotSnapshot(
104 context->getRobot()->getName())));
105 context->getWorkingMemoryProxy()->getObjectInstancesSegment()->setNewMotionModel(
106 obj->getId(), newMotionModel);
107 }
108 else
109 {
111 << "No object instance with name '" << objClassName
112 << "' found! Could not change working memory position and motion model of object.";
113 }
114}
115
116// DO NOT EDIT NEXT FUNCTION
117std::string
119{
120 return "ReleaseTable";
121}
122
123// DO NOT EDIT NEXT FUNCTION
ReleaseTable(XMLStateConstructorParams stateData)
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
The LinkedPose class.
Definition LinkedPose.h:61
The Vector3 class.
Definition Pose.h:113
Class for legacy to stay compatible with old statecharts.
Definition XMLState.h:147
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
#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< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64
IceInternal::Handle< FramedPose > FramedPosePtr
Definition FramedPose.h:272
IceInternal::Handle< MotionModelStaticObject > MotionModelStaticObjectPtr
IceInternal::Handle< ObjectInstance > ObjectInstancePtr