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,
const
std::string& nodeSetName,
const
std::string& controllerName)
31
: robotUnit(robotUnit), controllerName(controllerName)
32
{
33
config
=
new
NJointCartesianVelocityControllerWithRampConfig(nodeSetName,
""
,
CartesianSelectionMode::eAll
, 500, 1, 2, 1, 2);
34
init
();
35
}
36
37
VelocityControllerHelper::VelocityControllerHelper
(
const
RobotUnitInterfacePrx
& robotUnit, NJointCartesianVelocityControllerWithRampConfigPtr config,
const
std::string& controllerName)
38
: robotUnit(robotUnit), controllerName(controllerName)
39
{
40
this->config =
config
;
41
init
();
42
}
43
44
void
VelocityControllerHelper::init
()
45
{
46
NJointControllerInterfacePrx ctrl =
robotUnit
->getNJointController(
controllerName
);
47
if
(ctrl)
48
{
49
controllerCreated
=
false
;
50
}
51
else
52
{
53
ctrl =
robotUnit
->createOrReplaceNJointController(
"NJointCartesianVelocityControllerWithRamp"
,
controllerName
,
config
);
54
controllerCreated
=
true
;
55
}
56
controller
= NJointCartesianVelocityControllerWithRampInterfacePrx::checkedCast(ctrl);
57
controller
->activateController();
58
}
59
60
void
VelocityControllerHelper::setTargetVelocity
(
const
Eigen::Vector6f
&
cv
)
61
{
62
controller
->setTargetVelocity(
cv
(0),
cv
(1),
cv
(2),
cv
(3),
cv
(4),
cv
(5));
63
}
64
65
void
VelocityControllerHelper::setNullSpaceControl
(
bool
enabled
)
66
{
67
if
(
enabled
)
68
{
69
controller
->setJointLimitAvoidanceScale(
config
->jointLimitAvoidanceScale);
70
controller
->setKpJointLimitAvoidance(
config
->KpJointLimitAvoidance);
71
}
72
else
73
{
74
controller
->setJointLimitAvoidanceScale(0);
75
controller
->setKpJointLimitAvoidance(0);
76
}
77
}
78
79
void
VelocityControllerHelper::cleanup
()
80
{
81
if
(
controllerCreated
)
82
{
83
// delete controller only if it was created
84
controller
->deactivateAndDeleteController();
85
}
86
else
87
{
88
// if the controller existed, only deactivate it
89
controller
->deactivateController();
90
}
91
}
92
}
armarx::VelocityControllerHelper::controllerCreated
bool controllerCreated
Definition:
VelocityControllerHelper.h:56
armarx::VelocityControllerHelper::config
NJointCartesianVelocityControllerWithRampConfigPtr config
Definition:
VelocityControllerHelper.h:52
armarx::VelocityControllerHelper::controllerName
std::string controllerName
Definition:
VelocityControllerHelper.h:55
VelocityControllerHelper.h
controller
Definition:
AddOperation.h:39
enabled
std::atomic< bool > * enabled
Definition:
RemoteGuiWidgetController.cpp:75
armarx::VelocityControllerHelper::VelocityControllerHelper
VelocityControllerHelper(const RobotUnitInterfacePrx &robotUnit, const std::string &nodeSetName, const std::string &controllerName)
Definition:
VelocityControllerHelper.cpp:30
armarx::VelocityControllerHelper::init
void init()
Definition:
VelocityControllerHelper.cpp:44
armarx::NJointTaskSpaceDMPControllerMode::eAll
@ eAll
Definition:
ControllerInterface.ice:38
TimeUtil.h
armarx::VelocityControllerHelper::setNullSpaceControl
void setNullSpaceControl(bool enabled)
Definition:
VelocityControllerHelper.cpp:65
IceInternal::ProxyHandle<::IceProxy::armarx::RobotUnitInterface >
Eigen::Matrix< float, 6, 1 >
cv
Definition:
helper.h:35
armarx::VelocityControllerHelper::setTargetVelocity
void setTargetVelocity(const Eigen::Vector6f &cv)
Definition:
VelocityControllerHelper.cpp:60
armarx::VelocityControllerHelper::cleanup
void cleanup()
Definition:
VelocityControllerHelper.cpp:79
armarx::VelocityControllerHelper::robotUnit
RobotUnitInterfacePrx robotUnit
Definition:
VelocityControllerHelper.h:54
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition:
ArmarXTimeserver.cpp:28
RobotAPI
libraries
RobotStatechartHelpers
VelocityControllerHelper.cpp
Generated on Sat Oct 12 2024 09:14:11 for armarx_documentation by
1.8.17