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