Skip to content

Commit 6f94e90

Browse files
fbaillyolivier-stasse
authored andcommitted
[python import fix] fixed import error of robot-util by modifiying src/CmakeLists
1 parent 19c9096 commit 6f94e90

File tree

4 files changed

+257
-137
lines changed

4 files changed

+257
-137
lines changed

include/sot/core/logger.hh

Lines changed: 135 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -79,145 +79,145 @@ namespace dynamicgraph {
7979
#define SEND_ERROR_STREAM_MSG(msg) SEND_MSG(msg,MSG_TYPE_ERROR_STREAM)
8080
#endif
8181

82-
/** Enum representing the different kind of messages.
83-
*/
84-
enum MsgType
85-
{
86-
MSG_TYPE_DEBUG =0,
87-
MSG_TYPE_INFO =1,
88-
MSG_TYPE_WARNING =2,
89-
MSG_TYPE_ERROR =3,
90-
MSG_TYPE_DEBUG_STREAM =4,
91-
MSG_TYPE_INFO_STREAM =5,
92-
MSG_TYPE_WARNING_STREAM =6,
93-
MSG_TYPE_ERROR_STREAM =7
94-
};
95-
96-
template<typename T>
97-
std::string toString(const T& v, const int precision=3, const int width=-1)
98-
{
99-
std::stringstream ss;
100-
if(width>precision)
101-
ss<<std::fixed<<std::setw(width)<<std::setprecision(precision)<<v;
102-
else
103-
ss<<std::fixed<<std::setprecision(precision)<<v;
104-
return ss.str();
105-
}
106-
107-
template<typename T>
108-
std::string toString(const std::vector<T>& v, const int precision=3, const int width=-1,
109-
const std::string separator=", ")
110-
{
111-
std::stringstream ss;
112-
if(width>precision)
113-
{
114-
for(int i=0; i<v.size()-1; i++)
115-
ss<<std::fixed<<std::setw(width)<<std::setprecision(precision)<<v[i]<<separator;
116-
ss<<std::fixed<<std::setw(width)<<std::setprecision(precision)<<v[v.size()-1];
117-
}
118-
else
119-
{
120-
for(int i=0; i<v.size()-1; i++)
121-
ss<<std::fixed<<std::setprecision(precision)<<v[i]<<separator;
122-
ss<<std::fixed<<std::setprecision(precision)<<v[v.size()-1];
123-
}
124-
125-
return ss.str();
126-
}
82+
/** Enum representing the different kind of messages.
83+
*/
84+
enum MsgType
85+
{
86+
MSG_TYPE_DEBUG =0,
87+
MSG_TYPE_INFO =1,
88+
MSG_TYPE_WARNING =2,
89+
MSG_TYPE_ERROR =3,
90+
MSG_TYPE_DEBUG_STREAM =4,
91+
MSG_TYPE_INFO_STREAM =5,
92+
MSG_TYPE_WARNING_STREAM =6,
93+
MSG_TYPE_ERROR_STREAM =7
94+
};
95+
96+
template<typename T>
97+
std::string toString(const T& v, const int precision=3, const int width=-1)
98+
{
99+
std::stringstream ss;
100+
if(width>precision)
101+
ss<<std::fixed<<std::setw(width)<<std::setprecision(precision)<<v;
102+
else
103+
ss<<std::fixed<<std::setprecision(precision)<<v;
104+
return ss.str();
105+
}
106+
107+
template<typename T>
108+
std::string toString(const std::vector<T>& v, const int precision=3, const int width=-1,
109+
const std::string separator=", ")
110+
{
111+
std::stringstream ss;
112+
if(width>precision)
113+
{
114+
for(int i=0; i<v.size()-1; i++)
115+
ss<<std::fixed<<std::setw(width)<<std::setprecision(precision)<<v[i]<<separator;
116+
ss<<std::fixed<<std::setw(width)<<std::setprecision(precision)<<v[v.size()-1];
117+
}
118+
else
119+
{
120+
for(int i=0; i<v.size()-1; i++)
121+
ss<<std::fixed<<std::setprecision(precision)<<v[i]<<separator;
122+
ss<<std::fixed<<std::setprecision(precision)<<v[v.size()-1];
123+
}
124+
125+
return ss.str();
126+
}
127127

128128
// template<typename T, int N>
129129
// std::string toString(const Eigen::Matrix<T, N, 1, 0, N, 1>& v, const std::string separator=", ",
130130
// const int precision=3, const int width=-1)
131-
template<typename T>
132-
std::string toString(const Eigen::MatrixBase<T>& v,
133-
const int precision=3, const int width=-1, const std::string separator=", ")
134-
{
135-
std::stringstream ss;
136-
if(width>precision)
137-
{
138-
for(int i=0; i<v.size()-1; i++)
139-
ss<<std::fixed<<std::setw(width)<<std::setprecision(precision)<<v[i]<<separator;
140-
ss<<std::fixed<<std::setw(width)<<std::setprecision(precision)<<v[v.size()-1];
141-
}
142-
else
143-
{
144-
for(int i=0; i<v.size()-1; i++)
145-
ss<<std::fixed<<std::setprecision(precision)<<v[i]<<separator;
146-
ss<<std::setprecision(precision)<<v[v.size()-1];
147-
}
148-
149-
return ss.str();
150-
}
151-
152-
enum LoggerVerbosity
153-
{
154-
VERBOSITY_ALL,
155-
VERBOSITY_INFO_WARNING_ERROR,
156-
VERBOSITY_WARNING_ERROR,
157-
VERBOSITY_ERROR,
158-
VERBOSITY_NONE
159-
};
160-
161-
/** A simple class for logging messages
162-
*/
163-
class Logger
164-
{
165-
public:
166-
167-
/** Constructor */
168-
Logger(double timeSample=0.001, double streamPrintPeriod=1.0);
169-
170-
/** Destructor */
171-
~Logger(){}
172-
173-
/** Method to be called at every control iteration
174-
* to decrement the internal Logger's counter. */
175-
void countdown();
176-
177-
/** Print the specified message on standard output if the verbosity level
178-
* allows it. The file name and the line number are used to identify
179-
* the point where sendMsg is called so that streaming messages are
180-
* printed only every streamPrintPeriod iterations.
181-
*/
182-
void sendMsg(std::string msg, MsgType type, const char* file="", int line=0);
183-
184-
/** Set the sampling time at which the method countdown()
185-
* is going to be called. */
186-
bool setTimeSample(double t);
187-
188-
/** Set the time period for printing of streaming messages. */
189-
bool setStreamPrintPeriod(double s);
190-
191-
/** Set the verbosity level of the logger. */
192-
void setVerbosity(LoggerVerbosity lv);
193-
194-
protected:
195-
LoggerVerbosity m_lv; /// verbosity of the logger
196-
double m_timeSample; /// specify the period of call of the countdown method
197-
double m_streamPrintPeriod; /// specify the time period of the stream prints
198-
double m_printCountdown; /// every time this is < 0 (i.e. every _streamPrintPeriod sec) print stuff
199-
200-
/** Pointer to the dynamic structure which holds the collection of streaming messages */
201-
std::map<std::string, double> m_stream_msg_counters;
202-
203-
bool isStreamMsg(MsgType m)
204-
{ return m==MSG_TYPE_ERROR_STREAM || m==MSG_TYPE_DEBUG_STREAM || m==MSG_TYPE_INFO_STREAM || m==MSG_TYPE_WARNING_STREAM; }
205-
206-
bool isDebugMsg(MsgType m)
207-
{ return m==MSG_TYPE_DEBUG_STREAM || m==MSG_TYPE_DEBUG; }
208-
209-
bool isInfoMsg(MsgType m)
210-
{ return m==MSG_TYPE_INFO_STREAM || m==MSG_TYPE_INFO; }
211-
212-
bool isWarningMsg(MsgType m)
213-
{ return m==MSG_TYPE_WARNING_STREAM || m==MSG_TYPE_WARNING; }
214-
215-
bool isErrorMsg(MsgType m)
216-
{ return m==MSG_TYPE_ERROR_STREAM || m==MSG_TYPE_ERROR; }
217-
};
218-
219-
/** Method to get the logger (singleton). */
220-
Logger& getLogger();
131+
template<typename T>
132+
std::string toString(const Eigen::MatrixBase<T>& v,
133+
const int precision=3, const int width=-1, const std::string separator=", ")
134+
{
135+
std::stringstream ss;
136+
if(width>precision)
137+
{
138+
for(int i=0; i<v.size()-1; i++)
139+
ss<<std::fixed<<std::setw(width)<<std::setprecision(precision)<<v[i]<<separator;
140+
ss<<std::fixed<<std::setw(width)<<std::setprecision(precision)<<v[v.size()-1];
141+
}
142+
else
143+
{
144+
for(int i=0; i<v.size()-1; i++)
145+
ss<<std::fixed<<std::setprecision(precision)<<v[i]<<separator;
146+
ss<<std::setprecision(precision)<<v[v.size()-1];
147+
}
148+
149+
return ss.str();
150+
}
151+
152+
enum LoggerVerbosity
153+
{
154+
VERBOSITY_ALL,
155+
VERBOSITY_INFO_WARNING_ERROR,
156+
VERBOSITY_WARNING_ERROR,
157+
VERBOSITY_ERROR,
158+
VERBOSITY_NONE
159+
};
160+
161+
/** A simple class for logging messages
162+
*/
163+
class Logger
164+
{
165+
public:
166+
167+
/** Constructor */
168+
Logger(double timeSample=0.001, double streamPrintPeriod=1.0);
169+
170+
/** Destructor */
171+
~Logger(){}
172+
173+
/** Method to be called at every control iteration
174+
* to decrement the internal Logger's counter. */
175+
void countdown();
176+
177+
/** Print the specified message on standard output if the verbosity level
178+
* allows it. The file name and the line number are used to identify
179+
* the point where sendMsg is called so that streaming messages are
180+
* printed only every streamPrintPeriod iterations.
181+
*/
182+
void sendMsg(std::string msg, MsgType type, const char* file="", int line=0);
183+
184+
/** Set the sampling time at which the method countdown()
185+
* is going to be called. */
186+
bool setTimeSample(double t);
187+
188+
/** Set the time period for printing of streaming messages. */
189+
bool setStreamPrintPeriod(double s);
190+
191+
/** Set the verbosity level of the logger. */
192+
void setVerbosity(LoggerVerbosity lv);
193+
194+
protected:
195+
LoggerVerbosity m_lv; /// verbosity of the logger
196+
double m_timeSample; /// specify the period of call of the countdown method
197+
double m_streamPrintPeriod; /// specify the time period of the stream prints
198+
double m_printCountdown; /// every time this is < 0 (i.e. every _streamPrintPeriod sec) print stuff
199+
200+
/** Pointer to the dynamic structure which holds the collection of streaming messages */
201+
std::map<std::string, double> m_stream_msg_counters;
202+
203+
bool isStreamMsg(MsgType m)
204+
{ return m==MSG_TYPE_ERROR_STREAM || m==MSG_TYPE_DEBUG_STREAM || m==MSG_TYPE_INFO_STREAM || m==MSG_TYPE_WARNING_STREAM; }
205+
206+
bool isDebugMsg(MsgType m)
207+
{ return m==MSG_TYPE_DEBUG_STREAM || m==MSG_TYPE_DEBUG; }
208+
209+
bool isInfoMsg(MsgType m)
210+
{ return m==MSG_TYPE_INFO_STREAM || m==MSG_TYPE_INFO; }
211+
212+
bool isWarningMsg(MsgType m)
213+
{ return m==MSG_TYPE_WARNING_STREAM || m==MSG_TYPE_WARNING; }
214+
215+
bool isErrorMsg(MsgType m)
216+
{ return m==MSG_TYPE_ERROR_STREAM || m==MSG_TYPE_ERROR; }
217+
};
218+
219+
/** Method to get the logger (singleton). */
220+
Logger& getLogger();
221221

222222
} // namespace sot
223223
} // namespace dynamicgraph

include/sot/core/robot-utils.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@
3838
/* --------------------------------------------------------------------- */
3939
#include <iostream>
4040
#include <dynamic-graph/linear-algebra.h>
41+
#include <sot/core/signal-helper.hh>
4142
#include <sot/core/matrix-geometry.hh>
4243
#include <map>
4344
#include "boost/assign.hpp"
44-
#include <sot/core/signal-helper.hh>
4545
#include <sot/core/logger.hh>
46+
4647
namespace dg = ::dynamicgraph;
4748
using namespace dg;
4849

src/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ SET(plugins
9595
control/control-gr
9696
control/control-pd
9797
98-
robot-utils
9998
)
10099
101100
# TODO
@@ -155,6 +154,9 @@ SET(${LIBRARY_NAME}_SOURCES
155154
tools/trajectory
156155
157156
matrix/matrix-svd
157+
158+
robot-utils
159+
logger
158160
)
159161
160162
ADD_LIBRARY(${LIBRARY_NAME}

0 commit comments

Comments
 (0)