CartesianVelocityControl.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
28#include <RobotAPI/interface/units/TCPControlUnit.h>
29
31
32using namespace armarx;
33using namespace MotionControlGroup;
34
35// DO NOT EDIT NEXT LINE
36CartesianVelocityControl::SubClassRegistry
37 CartesianVelocityControl::Registry(CartesianVelocityControl::GetName(),
39
42 CartesianVelocityControlGeneratedBase<CartesianVelocityControl>(stateData)
43{
44}
45
46void
48{
50 getContext<MotionControlGroupStatechartContext>();
51
52 std::string kinematicChain = in.getKinematicChainName();
53
54 if (!context->getRobot()->hasRobotNodeSet(kinematicChain))
55 {
56 ARMARX_WARNING << "Kinematic Chain '" << kinematicChain << "' not available" << flush;
57 emitFailure();
58 }
59
60 std::string endEffectorName =
61 context->getRobot()->getRobotNodeSet(kinematicChain)->getTCP()->getName();
62
63 FramedDirectionPtr orientationVelocity(new FramedDirection);
64 orientationVelocity->frame = endEffectorName;
65 orientationVelocity->x = orientationVelocity->y = orientationVelocity->z = 0;
66
67 FramedDirectionPtr positionVelocity(new FramedDirection);
68 positionVelocity->frame = endEffectorName;
69 positionVelocity->x = positionVelocity->y = positionVelocity->z = 0;
70
71 if (isInputParameterSet("TargetTcpOrientationVelocity"))
72 {
73 orientationVelocity = in.getTargetTcpOrientationVelocity();
74 }
75
76 if (isInputParameterSet("TargetTcpPositionVelocity"))
77 {
78 positionVelocity = in.getTargetTcpPositionVelocity();
79 }
80
81 context->getTCPControlUnit()->setCycleTime(in.getCycleTime());
82
83 // Call request without release to keep the velocities applied after the state is left. Calling release would stop the joints
84 // It is no problem to call request a second time in another unit.
85 context->getTCPControlUnit()->request();
86 context->getTCPControlUnit()->setTCPVelocity(
87 in.getKinematicChainName(), endEffectorName, positionVelocity, orientationVelocity);
88
89 // wait a custom amount of time until going to next state
90 setTimeoutEvent(in.getWaitTimeUntilTransition(), createEventSuccess());
91}
92
93void
97
98void
102
103// DO NOT EDIT NEXT FUNCTION
FramedDirection is a 3 dimensional direction vector with a reference frame.
Definition FramedPose.h:87
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_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.
IceInternal::Handle< FramedDirection > FramedDirectionPtr
Definition FramedPose.h:84
const LogSender::manipulator flush
Definition LogSender.h:251
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64