5 #define EIGEN_RUNTIME_NO_MALLOC
7 #include <dynamic-graph/factory.h>
10 #include <sot/core/debug.hh>
15 #define ODEBUG(x) std::cout << x << std::endl
19 #define ODEBUG3(x) std::cout << x << std::endl
21 #define DBGFILE "/tmp/debug-ddp_actuator_solver.dat"
23 #define RESETDEBUG5() \
25 std::ofstream DebugFile; \
26 DebugFile.open(DBGFILE, std::ofstream::out); \
29 #define ODEBUG5FULL(x) \
31 std::ofstream DebugFile; \
32 DebugFile.open(DBGFILE, std::ofstream::app); \
33 DebugFile << __FILE__ << ":" << __FUNCTION__ << "(#" << __LINE__ \
34 << "):" << x << std::endl; \
39 std::ofstream DebugFile; \
40 DebugFile.open(DBGFILE, std::ofstream::app); \
41 DebugFile << x << std::endl; \
46 #define ODEBUG4FULL(x)
55 using namespace dynamicgraph::command;
56 using namespace Eigen;
68 CONSTRUCT_SIGNAL_IN(pos_motor_measure,
dynamicgraph::Vector),
69 CONSTRUCT_SIGNAL_IN(pos_joint_measure,
dynamicgraph::Vector),
74 CONSTRUCT_SIGNAL_OUT(tau,
dynamicgraph::Vector, m_pos_desSIN),
76 m_solver(m_model, m_cost, DISABLE_FULLDDP, DISABLE_QPBOX),
90 docCommandVoid4(
"Initialize the DDP solver.",
"Control timestep [s].",
91 "Size of the preview window (in nb of samples)",
92 "Max. nb. of iterations",
"Stopping criteria")));
99 const dynamicgraph::Vector &pos_des = m_pos_desSIN(iter);
101 const dynamicgraph::Vector &pos_joint_measure = m_pos_joint_measureSIN(iter);
103 const dynamicgraph::Vector &dx_measure = m_dx_measureSIN(iter);
105 const dynamicgraph::Vector &temp_measure = m_temp_measureSIN(iter);
107 const dynamicgraph::Vector &tau_measure = m_tau_measureSIN(iter);
109 const dynamicgraph::Vector &tau_des = m_tau_desSIN(iter);
111 DDPSolver<double, 5, 1>::stateVec_t xinit, xDes;
114 xinit << pos_joint_measure(0), dx_measure(0), temp_measure(0), tau_measure(0),
118 xDes << pos_des, 0.0, 25.0, tau_des, 25.0;
125 DDPSolver<double, 5, 1> m_solver(model, cost, 0, 0);
127 m_solver.FirstInitSolver(xinit, xDes, m_T, m_dt, m_iterMax, m_stopCrit);
131 m_solver.solveTrajectory();
135 DDPSolver<double, 5, 1>::traj lastTraj;
136 lastTraj = m_solver.getLastSolvedTrajectory();
137 ODEBUG5(
"getLastSolvedTrajectory");
139 DDPSolver<double, 5, 1>::commandVecTab_t uList;
140 uList = lastTraj.uList;
145 s << 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
146 0.0, 0.0, 0.0, uList[0], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
155 const double &stopCriteria) {
166 <<
" stopCriteria: " <<
m_stopCrit << std::endl;