MoveTableAdmittanceControl.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::MoveTableAdmittanceControlGroup
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 < MoveTableAdmittanceControl > (stateData), MoveTableAdmittanceControlGeneratedBase < MoveTableAdmittanceControl > (stateData)
39 {
40 }
41 
43 {
44  CoupledInteractionGroupStatechartContext* context = getContext<CoupledInteractionGroupStatechartContext>();
45 
46  Eigen::Vector3f zeroVelVec;
47  zeroVelVec << 0.0, 0.0, 0.0;
48  //std::string leftTcpName("Wrist 2 L");
49  //std::string rightTcpName("Wrist 2 R");
50  std::string leftTcpName = in.getLeftHandName();
51  std::string rightTcpName = in.getRightHandName();
52  //leftTcpName = std::string("Wrist 2 L");
53  //rightTcpName = std::string("Wrist 2 R");
54  DatafieldRefPtr forceRefLeft = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->getForceDatafield(leftTcpName));
55  DatafieldRefPtr torqueRefLeft = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->getTorqueDatafield(leftTcpName));
56  DatafieldRefPtr forceRefRight = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->getForceDatafield(rightTcpName));
57  DatafieldRefPtr torqueRefRight = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->getTorqueDatafield(rightTcpName));
58  forceRefLeft = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->createNulledDatafield(forceRefLeft));
59  forceRefRight = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->createNulledDatafield(forceRefRight));
60  torqueRefLeft = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->createNulledDatafield(torqueRefLeft));
61  torqueRefRight = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->createNulledDatafield(torqueRefRight));
62  FramedDirectionPtr curForceLeft = forceRefLeft->getDataField()->get<FramedDirection>();
63  curForceLeft = FramedDirection::ChangeFrame(context->getRobot(), *curForceLeft, "Armar3_Base");
64  FramedDirectionPtr curForceRight = forceRefRight->getDataField()->get<FramedDirection>();
65  curForceRight = FramedDirection::ChangeFrame(context->getRobot(), *curForceRight, "Armar3_Base");
66  FramedDirectionPtr curTorqueLeft = torqueRefLeft->getDataField()->get<FramedDirection>();
67  curTorqueLeft = FramedDirection::ChangeFrame(context->getRobot(), *curTorqueLeft, "Armar3_Base");
68  FramedDirectionPtr curTorqueRight = torqueRefRight->getDataField()->get<FramedDirection>();
69  curTorqueRight = FramedDirection::ChangeFrame(context->getRobot(), *curTorqueRight, "Armar3_Base");
70 
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 
79  Eigen::Vector3f platformPose;
80  armarx::ChannelRefPtr poseRef = context->getChannelRef(context->getPlatformUnitObserverName(), "platformPose");
81  platformPose(0) = poseRef->getDataField("positionX")->getFloat();
82  platformPose(1) = poseRef->getDataField("positionY")->getFloat();
83  platformPose(2) = poseRef->getDataField("rotation")->getFloat();
84  local.setInitialPlatformPose(Vector3(platformPose));
85  local.setDesiredLeftTcpPose(FramedPose(leftTcpPoseBase, "Armar3_Base", "Armar3"));
86  local.setDesiredRightTcpPose(FramedPose(rightTcpPoseBase, "Armar3_Base", "Armar3"));
87  local.setDesiredLeftTcpOrientation(FramedDirection(desiredLeftRPY, "Armar3_Base", "Armar3"));
88  local.setDesiredRightTcpOrientation(FramedDirection(desiredRightRPY, "Armar3_Base", "Armar3"));
89  local.setCurrentLeftTcpOriVelocity(FramedDirection(zeroVelVec, "Armar3_Base", "Armar3"));
90  local.setCurrentLeftTcpPosVelocity(FramedDirection(zeroVelVec, "Armar3_Base", "Armar3"));
91  local.setCurrentRightTcpOriVelocity(FramedDirection(zeroVelVec, "Armar3_Base", "Armar3"));
92  local.setCurrentRightTcpPosVelocity(FramedDirection(zeroVelVec, "Armar3_Base", "Armar3"));
93  local.setCurrentPlatformVelocity(Vector3(zeroVelVec));
94  local.setTimestamp(TimestampVariant::nowPtr());
95  local.setinitialForcesReset(true);
96  local.setcounter(0);
97 }
98 
99 
101 {
102  CoupledInteractionGroupStatechartContext* context = getContext<CoupledInteractionGroupStatechartContext>();
103  //std::string leftTcpName("Wrist 2 L");
104  //std::string rightTcpName("Wrist 2 R");
105  std::string leftTcpName = in.getLeftHandName();
106  std::string rightTcpName = in.getRightHandName();
107  DatafieldRefPtr forceRefLeft = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->getForceDatafield(leftTcpName));
108  DatafieldRefPtr torqueRefLeft = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->getTorqueDatafield(leftTcpName));
109  DatafieldRefPtr forceRefRight = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->getForceDatafield(rightTcpName));
110  DatafieldRefPtr torqueRefRight = DatafieldRefPtr::dynamicCast(context->getForceTorqueUnitObserver()->getTorqueDatafield(rightTcpName));
111  context->getForceTorqueUnitObserver()->removeFilteredDatafield(forceRefLeft);
112  context->getForceTorqueUnitObserver()->removeFilteredDatafield(forceRefRight);
113  context->getForceTorqueUnitObserver()->removeFilteredDatafield(torqueRefLeft);
114  context->getForceTorqueUnitObserver()->removeFilteredDatafield(torqueRefRight);
115 
116  // put your user code for the exit point here
117  // execution time should be short (<100ms)
118 
119 }
120 
121 // DO NOT EDIT NEXT FUNCTION
123 {
124  return "MoveTableAdmittanceControl";
125 }
126 
127 // DO NOT EDIT NEXT FUNCTION
129 {
130  return XMLStateFactoryBasePtr(new MoveTableAdmittanceControl(stateData));
131 }
132 
RemoteRobot.h
armarx::VariantType::FramedPose
const VariantTypeId FramedPose
Definition: FramedPose.h:37
armarx::CoupledInteractionGroup::MoveTableAdmittanceControl::onEnter
void onEnter() override
Definition: MoveTableAdmittanceControl.cpp:42
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getForceTorqueUnitObserver
ForceTorqueUnitObserverInterfacePrx getForceTorqueUnitObserver()
Definition: CoupledInteractionGroupStatechartContext.h:161
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::CoupledInteractionGroup::MoveTableAdmittanceControl::GetName
static std::string GetName()
Definition: MoveTableAdmittanceControl.cpp:122
armarx::StatechartContext::getChannelRef
ChannelRefPtr getChannelRef(const std::string &observerName, const std::string &channelName) override
Definition: StatechartContext.cpp:142
armarx::TimestampVariant::nowPtr
static TimestampVariantPtr nowPtr()
Definition: TimestampVariant.h:111
IceInternal::Handle< DatafieldRef >
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getRobot
const VirtualRobot::RobotPtr getRobot()
Definition: CoupledInteractionGroupStatechartContext.h:101
armarx::FramedDirection::ChangeFrame
static FramedDirectionPtr ChangeFrame(const VirtualRobot::RobotPtr &robot, const FramedDirection &framedVec, const std::string &newFrame)
Definition: FramedPose.cpp:86
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getPlatformUnitObserverName
std::string getPlatformUnitObserverName()
Definition: CoupledInteractionGroupStatechartContext.h:152
armarx::CoupledInteractionGroup::MoveTableAdmittanceControl::Registry
static SubClassRegistry Registry
Definition: MoveTableAdmittanceControl.h:48
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:137
armarx::CoupledInteractionGroup::MoveTableAdmittanceControl
Definition: MoveTableAdmittanceControl.h:34
armarx::CoupledInteractionGroup::MoveTableAdmittanceControl::onExit
void onExit() override
Definition: MoveTableAdmittanceControl.cpp:100
armarx::CoupledInteractionGroup::MoveTableAdmittanceControl::MoveTableAdmittanceControl
MoveTableAdmittanceControl(XMLStateConstructorParams stateData)
Definition: MoveTableAdmittanceControl.cpp:37
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
MoveTableAdmittanceControl.h
armarx::CoupledInteractionGroup::MoveTableAdmittanceControl::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: MoveTableAdmittanceControl.cpp:128
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::channels::PlatformUnitObserver::platformPose
const PlatformUnitDatafieldCreator platformPose("platformPose")
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