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
26
27using namespace armarx;
28using namespace ForceControlGroup;
29
30// DO NOT EDIT NEXT LINE
31ChooseArmConfiguration::SubClassRegistry
32 ChooseArmConfiguration::Registry(ChooseArmConfiguration::GetName(),
34
37 ChooseArmConfigurationGeneratedBase<ChooseArmConfiguration>(stateData)
38{
39}
40
41void
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
113void
117
118void
122
123// DO NOT EDIT NEXT FUNCTION
ChooseArmConfiguration(const XMLStateConstructorParams &stateData)
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
The FramedPose class.
Definition FramedPose.h:281
The Quaternion class.
Definition Pose.h:174
Class for legacy to stay compatible with old statecharts.
Definition XMLState.h:147
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< Quaternion > QuaternionPtr
Definition Pose.h:234
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64