ZeroForceControl.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 Mirko Waechter ( mirko dot waechter 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 <RobotSkillTemplates/statecharts/ForceControlGroup/ForceControlGroupStatechartContext.generated.h>
26 
27 #include "ZeroForceControl.h"
28 
29 #include <VirtualRobot/Robot.h>
30 #include <VirtualRobot/RobotNodeSet.h>
31 
32 using namespace armarx;
33 using namespace ForceControlGroup;
34 
35 // DO NOT EDIT NEXT LINE
36 ZeroForceControl::SubClassRegistry ZeroForceControl::Registry(ZeroForceControl::GetName(), &ZeroForceControl::CreateInstance);
37 
38 
39 
41  XMLStateTemplate<ZeroForceControl>(stateData), ZeroForceControlGeneratedBase<ZeroForceControl>(stateData)
42 {
43 }
44 
46 {
47  ForceControlGroupStatechartContext* c = getContext<ForceControlGroupStatechartContext>();
48  c->getTCPControlUnit()->request();
49  // put your user code for the enter-point here
50  // execution time should be short (<100ms)
51  std::string tcpName;
52 
53  if (in.istcpNameSet())
54  {
55  tcpName = in.gettcpName();
56  }
57  else
58  {
59  tcpName = c->getRobot()->getRobotNodeSet(in.getrobotNodeSetName())->getTCP()->getName();
60  }
61 
62  DatafieldRefPtr forceRef = DatafieldRefPtr::dynamicCast(c->getForceTorqueObserver()->getForceDatafield(tcpName));
63  DatafieldRefPtr torqueRef = DatafieldRefPtr::dynamicCast(c->getForceTorqueObserver()->getTorqueDatafield(tcpName));
64  local.setforceRef(DatafieldRefPtr::dynamicCast(c->getForceTorqueObserver()->createNulledDatafield(forceRef)));
65  local.settorqueRef(DatafieldRefPtr::dynamicCast(c->getForceTorqueObserver()->createNulledDatafield(torqueRef)));
66  local.setstartVelocity(new FramedDirection(Eigen::Vector3f::Zero(), tcpName, c->getRobot()->getName()));
67 
68 }
69 
71 {
72  // put your user code for the exit point here
73  // execution time should be short (<100ms)
74  ForceControlGroupStatechartContext* c = getContext<ForceControlGroupStatechartContext>();
75  c->getTCPControlUnit()->release();
76  c->getForceTorqueObserver()->removeFilteredDatafield(local.getforceRef());
77 
78 }
79 
80 
81 // DO NOT EDIT NEXT FUNCTION
83 {
84  return XMLStateFactoryBasePtr(new ZeroForceControl(stateData));
85 }
86 
ZeroForceControl.h
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::ForceControlGroup::ZeroForceControl::ZeroForceControl
ZeroForceControl(XMLStateConstructorParams stateData)
Definition: ZeroForceControl.cpp:40
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::ForceControlGroup::ZeroForceControl
Definition: ZeroForceControl.h:31
IceInternal::Handle< DatafieldRef >
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:137
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
armarx::ForceControlGroup::ZeroForceControl::onExit
void onExit() override
Definition: ZeroForceControl.cpp:70
armarx::VariantType::FramedDirection
const VariantTypeId FramedDirection
Definition: FramedPose.h:38
armarx::ForceControlGroup::ZeroForceControl::Registry
static SubClassRegistry Registry
Definition: ZeroForceControl.h:43
armarx::ForceControlGroup::ZeroForceControl::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: ZeroForceControl.cpp:82
armarx::ForceControlGroup::ZeroForceControl::onEnter
void onEnter() override
Definition: ZeroForceControl.cpp:45
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28