MoveTableImpedanceControl.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::MoveTableImpedanceControlGroup
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 
27 
28 
29 using namespace armarx;
30 using namespace CoupledInteractionGroup;
31 
32 // DO NOT EDIT NEXT LINE
34 
35 
36 
38  XMLStateTemplate < MoveTableImpedanceControl > (stateData), MoveTableImpedanceControlGeneratedBase < MoveTableImpedanceControl > (stateData)
39 {
40 }
41 
43 {
44  CoupledInteractionGroupStatechartContext* context = getContext<CoupledInteractionGroupStatechartContext>();
45 
46 
47  Eigen::Vector3f zeroVelVec;
48  zeroVelVec << 0.0, 0.0, 0.0;
49  std::string leftTcpName = in.getLeftHandName();
50  std::string rightTcpName = in.getRightHandName();
51  //leftTcpName = std::string("Wrist 2 L");
52  //rightTcpName = std::string("Wrist 2 R");
53  //std::string leftTcpName("Wrist 2 L");
54  //std::string rightTcpName("Wrist 2 R");
55  DatafieldRefPtr forceRefLeft = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->getForceDatafield(leftTcpName));
56  DatafieldRefPtr torqueRefLeft = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->getTorqueDatafield(leftTcpName));
57  DatafieldRefPtr forceRefRight = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->getForceDatafield(rightTcpName));
58  DatafieldRefPtr torqueRefRight = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->getTorqueDatafield(rightTcpName));
59  forceRefLeft = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->createNulledDatafield(forceRefLeft));
60  forceRefRight = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->createNulledDatafield(forceRefRight));
61  torqueRefLeft = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->createNulledDatafield(torqueRefLeft));
62  torqueRefRight = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->createNulledDatafield(torqueRefRight));
63  FramedDirectionPtr curForceLeft = forceRefLeft->getDataField()->get<FramedDirection>();
64  curForceLeft = FramedDirection::ChangeFrame(context->getRobot(), *curForceLeft, "Armar3_Base");
65  FramedDirectionPtr curForceRight = forceRefRight->getDataField()->get<FramedDirection>();
66  curForceRight = FramedDirection::ChangeFrame(context->getRobot(), *curForceRight, "Armar3_Base");
67  FramedDirectionPtr curTorqueLeft = torqueRefLeft->getDataField()->get<FramedDirection>();
68  curTorqueLeft = FramedDirection::ChangeFrame(context->getRobot(), *curTorqueLeft, "Armar3_Base");
69  FramedDirectionPtr curTorqueRight = torqueRefRight->getDataField()->get<FramedDirection>();
70  curTorqueRight = FramedDirection::ChangeFrame(context->getRobot(), *curTorqueRight, "Armar3_Base");
71  Eigen::Matrix4f leftTcpPoseBase = context->getRobot()->getRobotNode(in.getLeftHandName())->getPoseInRootFrame();
72  Eigen::Matrix4f rightTcpPoseBase = context->getRobot()->getRobotNode(in.getRightHandName())->getPoseInRootFrame();
73 
74  Eigen::Vector3f desiredLeftRPY;
75  VirtualRobot::MathTools::eigen4f2rpy(leftTcpPoseBase, desiredLeftRPY);
76  Eigen::Vector3f desiredRightRPY;
77  VirtualRobot::MathTools::eigen4f2rpy(rightTcpPoseBase, desiredRightRPY);
78  local.setDesiredLeftTcpPose(FramedPose(leftTcpPoseBase, "Armar3_Base", "Armar3"));
79  local.setDesiredRightTcpPose(FramedPose(rightTcpPoseBase, "Armar3_Base", "Armar3"));
80  local.setDesiredLeftTcpOrientation(FramedDirection(desiredLeftRPY, "Armar3_Base", "Armar3"));
81  local.setDesiredRightTcpOrientation(FramedDirection(desiredRightRPY, "Armar3_Base", "Armar3"));
82  local.setCurrentLeftTcpOriVelocity(FramedDirection(zeroVelVec, "Armar3_Base", "Armar3"));
83  local.setCurrentLeftTcpPosVelocity(FramedDirection(zeroVelVec, "Armar3_Base", "Armar3"));
84  local.setCurrentRightTcpOriVelocity(FramedDirection(zeroVelVec, "Armar3_Base", "Armar3"));
85  local.setCurrentRightTcpPosVelocity(FramedDirection(zeroVelVec, "Armar3_Base", "Armar3"));
86  local.setCurrentPlatformVelocity(Vector3(zeroVelVec));
87  local.setTimestamp(TimestampVariant::nowPtr());
88  local.setinitialForcesReset(true);
89  local.setcounter(0);
90  int timeout = in.getTimeout();
91 
92  if (timeout > 0)
93  {
94  setTimeoutEvent(timeout, createEventTimeout());
95  }
96 
97 }
98 
99 
100 
102 {
103  CoupledInteractionGroupStatechartContext* context = getContext<CoupledInteractionGroupStatechartContext>();
104  //std::string leftTcpName("Wrist 2 L");
105  //std::string rightTcpName("Wrist 2 R");
106  std::string leftTcpName = in.getLeftHandName();
107  std::string rightTcpName = in.getRightHandName();
108  DatafieldRefPtr forceRefLeft = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->getForceDatafield(leftTcpName));
109  DatafieldRefPtr torqueRefLeft = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->getTorqueDatafield(leftTcpName));
110  DatafieldRefPtr forceRefRight = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->getForceDatafield(rightTcpName));
111  DatafieldRefPtr torqueRefRight = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->getTorqueDatafield(rightTcpName));
112  context->getForceTorqueUnitObserver()->removeFilteredDatafield(forceRefLeft);
113  context->getForceTorqueUnitObserver()->removeFilteredDatafield(forceRefRight);
114  context->getForceTorqueUnitObserver()->removeFilteredDatafield(torqueRefLeft);
115  context->getForceTorqueUnitObserver()->removeFilteredDatafield(torqueRefRight);
116 
117  // put your user code for the exit point here
118  // execution time should be short (<100ms)
119 
120 }
121 
122 // DO NOT EDIT NEXT FUNCTION
124 {
125  return "MoveTableImpedanceControl";
126 }
127 
128 // DO NOT EDIT NEXT FUNCTION
130 {
131  return XMLStateFactoryBasePtr(new MoveTableImpedanceControl(stateData));
132 }
133 
RemoteRobot.h
armarx::VariantType::FramedPose
const VariantTypeId FramedPose
Definition: FramedPose.h:37
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getForceTorqueUnitObserver
ForceTorqueUnitObserverInterfacePrx getForceTorqueUnitObserver()
Definition: CoupledInteractionGroupStatechartContext.h:161
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::CoupledInteractionGroup::MoveTableImpedanceControl
Definition: MoveTableImpedanceControl.h:34
armarx::CoupledInteractionGroup::MoveTableImpedanceControl::GetName
static std::string GetName()
Definition: MoveTableImpedanceControl.cpp:123
armarx::TimestampVariant::nowPtr
static TimestampVariantPtr nowPtr()
Definition: TimestampVariant.h:111
armarx::CoupledInteractionGroup::MoveTableImpedanceControl::onExit
void onExit() override
Definition: MoveTableImpedanceControl.cpp:101
armarx::CoupledInteractionGroup::MoveTableImpedanceControl::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: MoveTableImpedanceControl.cpp:129
IceInternal::Handle< DatafieldRef >
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getRobot
const VirtualRobot::RobotPtr getRobot()
Definition: CoupledInteractionGroupStatechartContext.h:101
armarx::CoupledInteractionGroup::MoveTableImpedanceControl::onEnter
void onEnter() override
Definition: MoveTableImpedanceControl.cpp:42
armarx::FramedDirection::ChangeFrame
static FramedDirectionPtr ChangeFrame(const VirtualRobot::RobotPtr &robot, const FramedDirection &framedVec, const std::string &newFrame)
Definition: FramedPose.cpp:86
MoveTableImpedanceControl.h
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:137
armarx::CoupledInteractionGroup::MoveTableImpedanceControl::MoveTableImpedanceControl
MoveTableImpedanceControl(XMLStateConstructorParams stateData)
Definition: MoveTableImpedanceControl.cpp:37
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::FramedDirection
FramedDirection is a 3 dimensional direction vector with a reference frame. The reference frame can b...
Definition: FramedPose.h:83
armarx::VariantType::FramedDirection
const VariantTypeId FramedDirection
Definition: FramedPose.h:38
memoryx::KBM::Vector3
Eigen::Vector3d Vector3
Definition: kbm.h:41
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext
Definition: CoupledInteractionGroupStatechartContext.h:88
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::CoupledInteractionGroup::MoveTableImpedanceControl::Registry
static SubClassRegistry Registry
Definition: MoveTableImpedanceControl.h:47