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 
27 
28 #include <RobotAPI/interface/units/TCPControlUnit.h>
29 
30 using namespace armarx;
31 using namespace MotionControlGroup;
32 
33 // DO NOT EDIT NEXT LINE
34 CartesianVelocityControl::SubClassRegistry CartesianVelocityControl::Registry(CartesianVelocityControl::GetName(), &CartesianVelocityControl::CreateInstance);
35 
36 
37 
40  CartesianVelocityControlGeneratedBase<CartesianVelocityControl>(stateData)
41 {
42 }
43 
45 {
46  MotionControlGroupStatechartContext* context = getContext<MotionControlGroupStatechartContext>();
47 
48  std::string kinematicChain = in.getKinematicChainName();
49 
50  if (!context->getRobot()->hasRobotNodeSet(kinematicChain))
51  {
52  ARMARX_WARNING << "Kinematic Chain '" << kinematicChain << "' not available" << flush;
53  emitFailure();
54  }
55 
56  std::string endEffectorName = context->getRobot()->getRobotNodeSet(kinematicChain)->getTCP()->getName();
57 
58  FramedDirectionPtr orientationVelocity(new FramedDirection);
59  orientationVelocity->frame = endEffectorName;
60  orientationVelocity->x = orientationVelocity->y = orientationVelocity->z = 0;
61 
62  FramedDirectionPtr positionVelocity(new FramedDirection);
63  positionVelocity->frame = endEffectorName;
64  positionVelocity->x = positionVelocity->y = positionVelocity->z = 0;
65 
66  if (isInputParameterSet("TargetTcpOrientationVelocity"))
67  {
68  orientationVelocity = in.getTargetTcpOrientationVelocity();
69  }
70 
71  if (isInputParameterSet("TargetTcpPositionVelocity"))
72  {
73  positionVelocity = in.getTargetTcpPositionVelocity();
74  }
75 
76  context->getTCPControlUnit()->setCycleTime(in.getCycleTime());
77 
78  // Call request without release to keep the velocities applied after the state is left. Calling release would stop the joints
79  // It is no problem to call request a second time in another unit.
80  context->getTCPControlUnit()->request();
81  context->getTCPControlUnit()->setTCPVelocity(in.getKinematicChainName(), endEffectorName, positionVelocity, orientationVelocity);
82 
83  // wait a custom amount of time until going to next state
84  setTimeoutEvent(in.getWaitTimeUntilTransition(), createEventSuccess());
85 }
86 
87 
89 {
90 }
91 
93 {
94 }
95 
96 
97 // DO NOT EDIT NEXT FUNCTION
99 {
100  return XMLStateFactoryBasePtr(new CartesianVelocityControl(stateData));
101 }
102 
armarx::MotionControlGroup::CartesianVelocityControl::onEnter
void onEnter() override
Definition: CartesianVelocityControl.cpp:44
armarx::MotionControlGroup::MotionControlGroupStatechartContext
Definition: MotionControlGroupStatechartContext.h:66
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::MotionControlGroup::CartesianVelocityControl::CartesianVelocityControl
CartesianVelocityControl(XMLStateConstructorParams stateData)
Definition: CartesianVelocityControl.cpp:38
armarx::MotionControlGroup::MotionControlGroupStatechartContext::getTCPControlUnit
TCPControlUnitInterfacePrx getTCPControlUnit()
Definition: MotionControlGroupStatechartContext.h:112
armarx::MotionControlGroup::CartesianVelocityControl::onBreak
void onBreak() override
Definition: CartesianVelocityControl.cpp:88
IceInternal::Handle< FramedDirection >
CartesianVelocityControl.h
armarx::MotionControlGroup::MotionControlGroupStatechartContext::getRobot
const std::shared_ptr< RemoteRobot > getRobot()
Definition: MotionControlGroupStatechartContext.h:79
armarx::MotionControlGroup::CartesianVelocityControl::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: CartesianVelocityControl.cpp:98
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:137
armarx::flush
const LogSender::manipulator flush
Definition: LogSender.h:251
armarx::MotionControlGroup::CartesianVelocityControl::Registry
static SubClassRegistry Registry
Definition: CartesianVelocityControl.h:45
MotionControlGroupStatechartContext.h
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
armarx::MotionControlGroup::CartesianVelocityControl::onExit
void onExit() override
Definition: CartesianVelocityControl.cpp:92
armarx::FramedDirection
FramedDirection is a 3 dimensional direction vector with a reference frame. The reference frame can b...
Definition: FramedPose.h:83
armarx::MotionControlGroup::CartesianVelocityControl
Definition: CartesianVelocityControl.h:32
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28