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
32using namespace armarx;
33using namespace ForceControlGroup;
34
35// DO NOT EDIT NEXT LINE
36ZeroForceControl::SubClassRegistry ZeroForceControl::Registry(ZeroForceControl::GetName(),
38
41 ZeroForceControlGeneratedBase<ZeroForceControl>(stateData)
42{
43}
44
45void
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
75void
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
constexpr T c
ZeroForceControl(XMLStateConstructorParams stateData)
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
FramedDirection is a 3 dimensional direction vector with a reference frame.
Definition FramedPose.h:87
Class for legacy to stay compatible with old statecharts.
Definition XMLState.h:147
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< DatafieldRef > DatafieldRefPtr
Definition Observer.h:43
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64