-
Notifications
You must be signed in to change notification settings - Fork 0
/
Nao.cpp
58 lines (47 loc) · 1.59 KB
/
Nao.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
#include <iostream>
#include <Eigen/Dense>
#include <Eigen/Core>
#include <vector>
#include <cmath>
#include <cassert>
#include "coin-or/IpIpoptApplication.hpp"
#include "hs071_nlp.hpp"
#include "nao.hpp"
using namespace Ipopt;
int main(
int /*argv*/,
char** /*argc*/
)
{
// NaoRobot nao;
com_goal[0] = 20.15;
com_goal[1] = 13.4;
q_init << 0, -20, 0, 49, -29, 0, -20, 0, 49, -29, 0;
SmartPtr<TNLP> mynlp = new HS071_NLP();
SmartPtr<IpoptApplication> app = IpoptApplicationFactory();
app->Options()->SetStringValue("derivative_test", "first-order");
app->Options()->SetStringValue("gradient_approximation", "finite-difference-values");
app->Options()->SetStringValue("hessian_approximation", "limited-memory");
app->Options()->SetStringValue("jacobian_approximation", "finite-difference-values");
app->Options()->SetNumericValue("tol", 1e-2);
app->Options()->SetStringValue("mu_strategy", "adaptive");
app->Options()->SetStringValue("output_file", "ipopt.out");
ApplicationReturnStatus status;
status = app->Initialize();
if( status != Solve_Succeeded )
{
std::cout << std::endl << std::endl << "*** Error during initialization!" << std::endl;
return (int) status;
}
// Ask Ipopt to solve the problem
status = app->OptimizeTNLP(mynlp);
if( status == Solve_Succeeded )
{
std::cout << std::endl << std::endl << "*** The problem solved!" << std::endl;
}
else
{
std::cout << std::endl << std::endl << "*** The problem FAILED!" << std::endl;
}
return (int) status;
}