CartesianPositionControl.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::MotionControlGroup
19 * @author Peter Kaiser ( peter dot kaiser at kit dot edu )
20 * @date 2014
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
26#include <VirtualRobot/RobotNodeSet.h>
27
29
31
32using namespace armarx;
33using namespace MotionControlGroup;
34
35// DO NOT EDIT NEXT LINE
36CartesianPositionControl::SubClassRegistry
37 CartesianPositionControl::Registry(CartesianPositionControl::GetName(),
39
42 CartesianPositionControlGeneratedBase<CartesianPositionControl>(stateData)
43{
44}
45
46void
48{
49 // Create and install timeout condition
50 int timeout = in.getTimeout();
51
52 if (timeout > 0)
53 {
54 setTimeoutEvent(timeout, createEventTimeout());
55 }
56
57 // Check if position and orientation are given in the same frame
58 if (isInputParameterSet("TcpTargetPosition") && isInputParameterSet("TcpTargetOrientation"))
59 {
60 if (in.getTcpTargetPosition()->frame != in.getTcpTargetOrientation()->frame)
61 {
62 ARMARX_WARNING << "Frame mismatch between target position and target orientation"
63 << flush;
64 emitFailure();
65 }
66 }
67
68 // Check if at least one type of target is given
69 if (!isInputParameterSet("TcpTargetPosition") && !isInputParameterSet("TcpTargetOrientation"))
70 {
71 ARMARX_WARNING << "Neither position target nor orientation target given for IK" << flush;
72 emitFailure();
73 }
74}
75
76void
80
81void
83{
84 if (in.isTcpTargetPositionSet())
85 {
87 getContext<MotionControlGroupStatechartContext>();
88
89 auto robot = context->getRobot()->clone();
90 Eigen::Vector3f target = in.getTcpTargetPosition()->toRootEigen(robot);
91 Eigen::Vector3f currentTcpPosition = robot->getRobotNodeSet(in.getKinematicChainName())
92 ->getTCP()
93 ->getPoseInRootFrame()
94 .block<3, 1>(0, 3);
95
96 ARMARX_IMPORTANT << "Remaining error: " << (currentTcpPosition - target).norm()
97 << ", current TCP position: " << currentTcpPosition
98 << ", target: " << target << "(in root frame)";
99 }
100}
101
102// DO NOT EDIT NEXT FUNCTION
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
custom implementation of the StatechartContext for a statechart
Class for legacy to stay compatible with old statecharts.
Definition XMLState.h:147
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
This file offers overloads of toIce() and fromIce() functions for STL container types.
const LogSender::manipulator flush
Definition LogSender.h:251
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64
double norm(const Point &a)
Definition point.hpp:102