A sparse MPC solver for walking motion generation.
oruw_log.h
Go to the documentation of this file.
1 /**
2  * @file
3  * @author Alexander Sherikov
4  * @date 03.01.2012 19:17:44 MSK
5  */
6 
7 
8 #ifndef ORUW_LOG_H
9 #define ORUW_LOG_H
10 
11 /**
12  * Enable logging.
13  */
14 #define ORUW_LOG_ENABLE
15 
16 
17 #ifdef ORUW_LOG_ENABLE
18 #include <cstdio>
19 #include <qi/log.hpp>
20 
21 #include "nao_igm.h"
22 #include "smpc_solver.h"
23 #include "WMG.h"
24 #include "joints_sensors_id.h"
25 #include "walk_parameters.h"
26 
27 
28 class oruw_log
29 {
30  public:
31  oruw_log ();
32  ~oruw_log ();
33 
34  void logJointValues (const jointState&, const jointState&);
35  void logCoM (smpc_parameters&, nao_igm&);
36  void logFeet (nao_igm& nao);
37  void logSolverInfo (smpc::solver *, int);
38 
39 
40  FILE *FJointsLog;
41  FILE *FCoMLog;
42  FILE *FFeetLog;
43  FILE *FMessages;
44 };
45 
46 
48 
49 
50 #define ORUW_LOG_IS_OPEN (oruw_log_instance != NULL)
51 #define ORUW_LOG_OPEN oruw_log_instance = new oruw_log();
52 
53 #define ORUW_LOG_CLOSE \
54  if ORUW_LOG_IS_OPEN {delete oruw_log_instance; oruw_log_instance = NULL;}
55 
56 #define ORUW_LOG_JOINTS(sensors,actuators) \
57  if ORUW_LOG_IS_OPEN {oruw_log_instance->logJointValues(sensors,actuators);}
58 
59 #define ORUW_LOG_COM(mpc,nao) \
60  if ORUW_LOG_IS_OPEN {oruw_log_instance->logCoM(mpc,nao);}
61 
62 #define ORUW_LOG_FEET(nao) \
63  if ORUW_LOG_IS_OPEN {oruw_log_instance->logFeet(nao);}
64 
65 #define ORUW_LOG_MESSAGE(...) \
66  if ORUW_LOG_IS_OPEN {fprintf(oruw_log_instance->FMessages, __VA_ARGS__);}
67 
68 #define ORUW_LOG_SOLVER_INFO \
69  if ORUW_LOG_IS_OPEN {oruw_log_instance->logSolverInfo(solver, wp.mpc_solver_type);}
70 
71 #define ORUW_LOG_STEPS(wmg) \
72  if ORUW_LOG_IS_OPEN {wmg.FS2file("oru_steps_m.log", false);}
73 
74 
75 #else // ORUW_LOG_ENABLE
76 
77 
78 #define ORUW_LOG_OPEN
79 #define ORUW_LOG_CLOSE
80 #define ORUW_LOG_JOINTS(sensors,actuators)
81 #define ORUW_LOG_COM(mpc,nao)
82 #define ORUW_LOG_FEET(nao)
83 #define ORUW_LOG_MESSAGE(...)
84 #define ORUW_LOG_STEPS(wmg)
85 #define ORUW_LOG_SOLVER_INFO
86 
87 
88 #endif // ORUW_LOG_ENABLE
89 
90 #endif // ORUW_LOG_H
FILE * FJointsLog
Definition: oruw_log.h:40
void logJointValues(const jointState &, const jointState &)
Definition: oruw_log.cpp:33
FILE * FCoMLog
Definition: oruw_log.h:41
oruw_log * oruw_log_instance
Definition: oruw_log.cpp:12
FILE * FFeetLog
Definition: oruw_log.h:42
void logCoM(smpc_parameters &, nao_igm &)
Definition: oruw_log.cpp:52
void logSolverInfo(smpc::solver *, int)
Definition: oruw_log.cpp:88
FILE * FMessages
Definition: oruw_log.h:43
void logFeet(nao_igm &nao)
Definition: oruw_log.cpp:66
~oruw_log()
Definition: oruw_log.cpp:24
oruw_log()
Definition: oruw_log.cpp:15