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