VelocityControllerHelper.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of ArmarX.
3
*
4
* Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5
* Karlsruhe Institute of Technology (KIT), all rights reserved.
6
*
7
* ArmarX is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License version 2 as
9
* published by the Free Software Foundation.
10
*
11
* ArmarX is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*
19
* @author Simon Ottenhaus (simon dot ottenhaus at kit dot edu)
20
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21
* GNU General Public License
22
*/
23
24
#include "
VelocityControllerHelper.h
"
25
26
#include <
ArmarXCore/core/time/TimeUtil.h
>
27
28
namespace
armarx
29
{
30
VelocityControllerHelper::VelocityControllerHelper
(
const
RobotUnitInterfacePrx
&
robotUnit
,
31
const
std::string& nodeSetName,
32
const
std::string&
controllerName
) :
33
robotUnit
(
robotUnit
),
controllerName
(
controllerName
)
34
{
35
config
=
new
NJointCartesianVelocityControllerWithRampConfig(
36
nodeSetName,
""
, CartesianSelectionMode::eAll, 500, 1, 2, 1, 2);
37
init
();
38
}
39
40
VelocityControllerHelper::VelocityControllerHelper
(
41
const
RobotUnitInterfacePrx
&
robotUnit
,
42
NJointCartesianVelocityControllerWithRampConfigPtr
config
,
43
const
std::string&
controllerName
) :
44
robotUnit
(
robotUnit
),
controllerName
(
controllerName
)
45
{
46
this->config =
config
;
47
init
();
48
}
49
50
void
51
VelocityControllerHelper::init
()
52
{
53
NJointControllerInterfacePrx ctrl =
robotUnit
->getNJointController(
controllerName
);
54
if
(ctrl)
55
{
56
controllerCreated
=
false
;
57
}
58
else
59
{
60
ctrl =
robotUnit
->createOrReplaceNJointController(
61
"NJointCartesianVelocityControllerWithRamp"
,
controllerName
,
config
);
62
controllerCreated
=
true
;
63
}
64
controller
= NJointCartesianVelocityControllerWithRampInterfacePrx::checkedCast(ctrl);
65
controller
->activateController();
66
}
67
68
void
69
VelocityControllerHelper::setTargetVelocity
(
const
Eigen::Vector6f
&
cv
)
70
{
71
controller
->setTargetVelocity(
cv
(0),
cv
(1),
cv
(2),
cv
(3),
cv
(4),
cv
(5));
72
}
73
74
void
75
VelocityControllerHelper::setNullSpaceControl
(
bool
enabled)
76
{
77
if
(enabled)
78
{
79
controller
->setJointLimitAvoidanceScale(
config
->jointLimitAvoidanceScale);
80
controller
->setKpJointLimitAvoidance(
config
->KpJointLimitAvoidance);
81
}
82
else
83
{
84
controller
->setJointLimitAvoidanceScale(0);
85
controller
->setKpJointLimitAvoidance(0);
86
}
87
}
88
89
void
90
VelocityControllerHelper::cleanup
()
91
{
92
if
(
controllerCreated
)
93
{
94
// delete controller only if it was created
95
controller
->deactivateAndDeleteController();
96
}
97
else
98
{
99
// if the controller existed, only deactivate it
100
controller
->deactivateController();
101
}
102
}
103
}
// namespace armarx
TimeUtil.h
VelocityControllerHelper.h
armarx::VelocityControllerHelper::init
void init()
Definition
VelocityControllerHelper.cpp:51
armarx::VelocityControllerHelper::setNullSpaceControl
void setNullSpaceControl(bool enabled)
Definition
VelocityControllerHelper.cpp:75
armarx::VelocityControllerHelper::robotUnit
RobotUnitInterfacePrx robotUnit
Definition
VelocityControllerHelper.h:58
armarx::VelocityControllerHelper::cleanup
void cleanup()
Definition
VelocityControllerHelper.cpp:90
armarx::VelocityControllerHelper::controllerName
std::string controllerName
Definition
VelocityControllerHelper.h:59
armarx::VelocityControllerHelper::VelocityControllerHelper
VelocityControllerHelper(const RobotUnitInterfacePrx &robotUnit, const std::string &nodeSetName, const std::string &controllerName)
Definition
VelocityControllerHelper.cpp:30
armarx::VelocityControllerHelper::controllerCreated
bool controllerCreated
Definition
VelocityControllerHelper.h:60
armarx::VelocityControllerHelper::setTargetVelocity
void setTargetVelocity(const Eigen::Vector6f &cv)
Definition
VelocityControllerHelper.cpp:69
armarx::VelocityControllerHelper::config
NJointCartesianVelocityControllerWithRampConfigPtr config
Definition
VelocityControllerHelper.h:56
Eigen::Vector6f
Matrix< float, 6, 1 > Vector6f
Definition
CartesianNaturalPositionController.h:40
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition
ArmarXTimeserver.cpp:28
armarx::RobotUnitInterfacePrx
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotUnitInterface > RobotUnitInterfacePrx
Definition
NJointControllerBase.h:85
controller
Definition
AddOperation.h:40
cv
Definition
helper.h:35
RobotAPI
libraries
RobotStatechartHelpers
VelocityControllerHelper.cpp
Generated by
1.13.2