-
Notifications
You must be signed in to change notification settings - Fork 14
/
ConfigurationSelectorHumanoidGait.cpp
64 lines (49 loc) · 1.19 KB
/
ConfigurationSelectorHumanoidGait.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
#include "ConfigurationSelector.hpp"
#include <cmath>
#include <kdl/utilities/utility.h>
using namespace roboticslab;
bool ConfigurationSelectorHumanoidGait::findOptimalConfiguration(const KDL::JntArray & qGuess)
{
if (qGuess.rows() != 6)
{
return false;
}
for (int i = 0; i < configs.size(); i++)
{
if (configs[i].isValid() && !applyConstraints(configs[i]))
{
configs[i].invalidate();
}
}
return ConfigurationSelectorLeastOverallAngularDisplacement::findOptimalConfiguration(qGuess);
}
bool ConfigurationSelectorHumanoidGait::applyConstraints(const Configuration & config)
{
const KDL::JntArray & q = *config.retrievePose();
if (std::abs(q(0)) > KDL::PI / 2)
{
return false;
}
if (std::abs(q(1)) > KDL::PI / 2)
{
return false;
}
if (std::abs(q(2)) > KDL::PI / 2)
{
return false;
}
if (q(3) < 0.0)
{
return false;
}
if (std::abs(q(4)) > KDL::PI / 2)
{
return false;
}
if (std::abs(q(5)) > KDL::PI / 2)
{
return false;
}
return true;
}