ChooseArmConfiguration.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::ForceControlGroup
19  * @author Peter Kaiser ( peter dot kaiser at kit dot edu )
20  * @date 2015
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #include "ChooseArmConfiguration.h"
26 
27 using namespace armarx;
28 using namespace ForceControlGroup;
29 
30 // DO NOT EDIT NEXT LINE
31 ChooseArmConfiguration::SubClassRegistry ChooseArmConfiguration::Registry(ChooseArmConfiguration::GetName(), &ChooseArmConfiguration::CreateInstance);
32 
33 
34 
36  XMLStateTemplate<ChooseArmConfiguration>(stateData), ChooseArmConfigurationGeneratedBase<ChooseArmConfiguration>(stateData)
37 {
38 }
39 
41 {
42  if (in.getHandUpright())
43  {
44  out.setArmConfigurationValues(in.getUprightArmConfigurationValues());
45  }
46  else
47  {
48  out.setArmConfigurationValues(in.getRotatedArmConfigurationValues());
49  }
50 
51  if (in.getUseRightArm())
52  {
53  ARMARX_INFO << "Using right arm";
54  out.setArmConfigurationJointNames(in.getArmConfigurationJointNamesRight());
55  out.setHand(in.getRightHand());
56  if (in.isRightObserverChannelNameSet())
57  {
58  out.setForceTorqueObserverChannelName(in.getRightObserverChannelName());
59  }
60  }
61  else
62  {
63  ARMARX_INFO << "Using left arm";
64  out.setArmConfigurationJointNames(in.getArmConfigurationJointNamesLeft());
65  out.setHand(in.getLeftHand());
66  if (in.isLeftObserverChannelNameSet())
67  {
68  out.setForceTorqueObserverChannelName(in.getLeftObserverChannelName());
69  }
70  }
71 
72  if (in.getUseIK())
73  {
74 
75  if (in.getUseRightArm())
76  {
77  out.setSelectedTCPPose(in.getRightArmTCPPose());
78  out.setSelectedKinematicChain(in.getRightArmKinematicChain());
79  }
80  else
81  {
82  Eigen::Matrix4f pose = in.getRightArmTCPPose()->toEigen();
83  pose(0, 3) *= -1;
84 
85  QuaternionPtr approachOriOld = new armarx::Quaternion(pose);
86  QuaternionPtr approachOri = new armarx::Quaternion();
87  approachOri->qw = approachOriOld->qz;
88  approachOri->qx = approachOriOld->qy * -1;
89  approachOri->qy = approachOriOld->qx * -1;
90  approachOri->qz = approachOriOld->qw;
91 
92  // Eigen::AngleAxisf aa(pose.block<3, 3>(0, 0));
93  // aa.axis().x() *= -1;
94  // aa.axis().y() *= -1;
95  // pose.block<3, 3>(0, 0) = aa.toRotationMatrix();
96  pose.block<3, 3>(0, 0) = approachOri->toEigen();
97 
98  out.setSelectedTCPPose(new FramedPose(pose, getLocalRobot()->getRootNode()->getName(), getLocalRobot()->getName()));
99  out.setSelectedKinematicChain(in.getLeftArmKinematicChain());
100  }
101  emitUseIK();
102  }
103  else
104  {
105 
106  emitUseJointControl();
107  }
108 }
109 
111 {
112 }
113 
115 {
116 }
117 
118 
119 // DO NOT EDIT NEXT FUNCTION
121 {
122  return XMLStateFactoryBasePtr(new ChooseArmConfiguration(stateData));
123 }
124 
armarx::VariantType::FramedPose
const VariantTypeId FramedPose
Definition: FramedPose.h:37
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
ChooseArmConfiguration.h
armarx::ForceControlGroup::ChooseArmConfiguration::ChooseArmConfiguration
ChooseArmConfiguration(const XMLStateConstructorParams &stateData)
Definition: ChooseArmConfiguration.cpp:35
armarx::VariantType::Quaternion
const VariantTypeId Quaternion
Definition: Pose.h:39
IceInternal::Handle< Quaternion >
armarx::ForceControlGroup::ChooseArmConfiguration::onEnter
void onEnter() override
Definition: ChooseArmConfiguration.cpp:40
armarx::ForceControlGroup::ChooseArmConfiguration
Definition: ChooseArmConfiguration.h:31
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:137
armarx::ForceControlGroup::ChooseArmConfiguration::Registry
static SubClassRegistry Registry
Definition: ChooseArmConfiguration.h:44
armarx::ForceControlGroup::ChooseArmConfiguration::onBreak
void onBreak() override
Definition: ChooseArmConfiguration.cpp:110
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::ForceControlGroup::ChooseArmConfiguration::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: ChooseArmConfiguration.cpp:120
armarx::ForceControlGroup::ChooseArmConfiguration::onExit
void onExit() override
Definition: ChooseArmConfiguration.cpp:114
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28