Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
dynamic-graph
Commits
870c6a6d
Commit
870c6a6d
authored
Aug 24, 2020
by
Guilhem Saurel
Browse files
Format
parent
764bbda2
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/dynamic-graph/command-bind.h
View file @
870c6a6d
...
...
@@ -433,8 +433,9 @@ makeCommandReturnType0(E &entity, ReturnType (E::*function)(void),
}
template
<
typename
ReturnType
>
inline
std
::
string
docCommandReturnType0
(
const
std
::
string
&
doc
,
const
std
::
string
&
/* return_type */
)
{
inline
std
::
string
docCommandReturnType0
(
const
std
::
string
&
doc
,
const
std
::
string
&
/* return_type */
)
{
return
std
::
string
(
"
\n
"
)
+
doc
+
"
\n\n
No input.
\n
"
+
typeid
(
ReturnType
).
name
()
+
" return.
\n\n
"
;
}
...
...
include/dynamic-graph/signal-caster.h
View file @
870c6a6d
...
...
@@ -12,92 +12,94 @@
#include
"dynamic-graph/exception-signal.h"
#include
<dynamic-graph/dynamic-graph-api.h>
#include
<dynamic-graph/linear-algebra.h>
#include
<dynamic-graph/eigen-io.h>
#include
<dynamic-graph/linear-algebra.h>
namespace
dynamicgraph
{
/// Inherit from this class if you want to keep default implementation for some
/// functions.
template
<
typename
T
>
struct
signal_io_base
{
/// serialize a signal value.
inline
static
void
disp
(
const
T
&
value
,
std
::
ostream
&
os
)
{
os
<<
value
;
}
/// deserialize a signal value.
inline
static
T
cast
(
std
::
istringstream
&
is
)
{
T
inst
;
is
>>
inst
;
if
(
is
.
fail
())
{
throw
ExceptionSignal
(
ExceptionSignal
::
GENERIC
,
"failed to serialize "
+
is
.
str
());
/// serialize a signal value.
inline
static
void
disp
(
const
T
&
value
,
std
::
ostream
&
os
)
{
os
<<
value
;
}
/// deserialize a signal value.
inline
static
T
cast
(
std
::
istringstream
&
is
)
{
T
inst
;
is
>>
inst
;
if
(
is
.
fail
())
{
throw
ExceptionSignal
(
ExceptionSignal
::
GENERIC
,
"failed to serialize "
+
is
.
str
());
}
return
inst
;
}
return
inst
;
}
/// write a signal value to log file
inline
static
void
trace
(
const
T
&
value
,
std
::
ostream
&
os
)
{
os
<<
value
;
}
/// write a signal value to log file
inline
static
void
trace
(
const
T
&
value
,
std
::
ostream
&
os
)
{
os
<<
value
;
}
};
/// Inherit from this class if tracing is not implemented for a given type.
template
<
typename
T
>
struct
signal_io_unimplemented
{
inline
static
void
disp
(
const
T
&
,
std
::
ostream
&
)
{
throw
std
::
logic_error
(
"this disp is not implemented."
);
}
inline
static
T
cast
(
std
::
istringstream
&
)
{
throw
std
::
logic_error
(
"this cast is not implemented."
);
}
inline
static
void
trace
(
const
T
&
,
std
::
ostream
&
)
{
throw
std
::
logic_error
(
"this trace is not implemented."
);
}
inline
static
void
disp
(
const
T
&
,
std
::
ostream
&
)
{
throw
std
::
logic_error
(
"this disp is not implemented."
);
}
inline
static
T
cast
(
std
::
istringstream
&
)
{
throw
std
::
logic_error
(
"this cast is not implemented."
);
}
inline
static
void
trace
(
const
T
&
,
std
::
ostream
&
)
{
throw
std
::
logic_error
(
"this trace is not implemented."
);
}
};
/// Class used for I/O operations in Signal<T,Time>
template
<
typename
T
>
struct
signal_io
:
signal_io_base
<
T
>
{};
/// Template specialization of signal_disp for Eigen objects
template
<
typename
_Scalar
,
int
_Rows
,
int
_Cols
,
int
_Options
,
int
_MaxRows
,
int
_MaxCols
>
struct
signal_io
<
Eigen
::
Matrix
<
_Scalar
,
_Rows
,
_Cols
,
_Options
,
_MaxRows
,
_MaxCols
>
>
:
signal_io_base
<
Eigen
::
Matrix
<
_Scalar
,
_Rows
,
_Cols
,
_Options
,
_MaxRows
,
_MaxCols
>
>
{
typedef
Eigen
::
Matrix
<
_Scalar
,
_Rows
,
_Cols
,
_Options
,
_MaxRows
,
_MaxCols
>
matrix_type
;
inline
static
void
disp
(
const
matrix_type
&
value
,
std
::
ostream
&
os
)
{
static
const
Eigen
::
IOFormat
row_format
(
Eigen
::
StreamPrecision
,
Eigen
::
DontAlignCols
,
" "
,
" "
,
""
,
""
,
""
,
""
);
os
<<
value
.
format
(
row_format
);
}
inline
static
void
trace
(
const
matrix_type
&
value
,
std
::
ostream
&
os
)
{
static
const
Eigen
::
IOFormat
row_format
(
Eigen
::
StreamPrecision
,
Eigen
::
DontAlignCols
,
"
\t
"
,
"
\t
"
,
""
,
""
,
""
,
""
);
os
<<
value
.
format
(
row_format
);
}
template
<
typename
_Scalar
,
int
_Rows
,
int
_Cols
,
int
_Options
,
int
_MaxRows
,
int
_MaxCols
>
struct
signal_io
<
Eigen
::
Matrix
<
_Scalar
,
_Rows
,
_Cols
,
_Options
,
_MaxRows
,
_MaxCols
>>
:
signal_io_base
<
Eigen
::
Matrix
<
_Scalar
,
_Rows
,
_Cols
,
_Options
,
_MaxRows
,
_MaxCols
>>
{
typedef
Eigen
::
Matrix
<
_Scalar
,
_Rows
,
_Cols
,
_Options
,
_MaxRows
,
_MaxCols
>
matrix_type
;
inline
static
void
disp
(
const
matrix_type
&
value
,
std
::
ostream
&
os
)
{
static
const
Eigen
::
IOFormat
row_format
(
Eigen
::
StreamPrecision
,
Eigen
::
DontAlignCols
,
" "
,
" "
,
""
,
""
,
""
,
""
);
os
<<
value
.
format
(
row_format
);
}
inline
static
void
trace
(
const
matrix_type
&
value
,
std
::
ostream
&
os
)
{
static
const
Eigen
::
IOFormat
row_format
(
Eigen
::
StreamPrecision
,
Eigen
::
DontAlignCols
,
"
\t
"
,
"
\t
"
,
""
,
""
,
""
,
""
);
os
<<
value
.
format
(
row_format
);
}
};
/// Template specialization of signal_io for Eigen quaternion objects
template
<
typename
_Scalar
,
int
_Options
>
struct
signal_io
<
Eigen
::
Quaternion
<
_Scalar
,
_Options
>
>
:
signal_io_base
<
Eigen
::
Quaternion
<
_Scalar
,
_Options
>
>
{
typedef
Eigen
::
Quaternion
<
_Scalar
,
_Options
>
quat_type
;
typedef
Eigen
::
Matrix
<
_Scalar
,
4
,
1
,
_Options
>
matrix_type
;
inline
static
void
disp
(
const
quat_type
&
value
,
std
::
ostream
&
os
)
{
signal_io
<
matrix_type
>::
disp
(
value
.
coeffs
(),
os
);
}
inline
static
quat_type
cast
(
std
::
istringstream
&
is
)
{
return
quat_type
(
signal_io
<
matrix_type
>::
cast
(
is
));
}
inline
static
void
trace
(
const
quat_type
&
value
,
std
::
ostream
&
os
)
{
signal_io
<
matrix_type
>::
trace
(
value
.
coeffs
(),
os
);
}
template
<
typename
_Scalar
,
int
_Options
>
struct
signal_io
<
Eigen
::
Quaternion
<
_Scalar
,
_Options
>>
:
signal_io_base
<
Eigen
::
Quaternion
<
_Scalar
,
_Options
>>
{
typedef
Eigen
::
Quaternion
<
_Scalar
,
_Options
>
quat_type
;
typedef
Eigen
::
Matrix
<
_Scalar
,
4
,
1
,
_Options
>
matrix_type
;
inline
static
void
disp
(
const
quat_type
&
value
,
std
::
ostream
&
os
)
{
signal_io
<
matrix_type
>::
disp
(
value
.
coeffs
(),
os
);
}
inline
static
quat_type
cast
(
std
::
istringstream
&
is
)
{
return
quat_type
(
signal_io
<
matrix_type
>::
cast
(
is
));
}
inline
static
void
trace
(
const
quat_type
&
value
,
std
::
ostream
&
os
)
{
signal_io
<
matrix_type
>::
trace
(
value
.
coeffs
(),
os
);
}
};
/// Template specialization of signal_io for std::string.
/// Do not print '\n' at the end.
template
<
>
struct
signal_io
<
std
::
string
>
:
signal_io_base
<
std
::
string
>
{
inline
static
std
::
string
cast
(
std
::
istringstream
&
iss
)
{
return
iss
.
str
();
}
template
<
>
struct
signal_io
<
std
::
string
>
:
signal_io_base
<
std
::
string
>
{
inline
static
std
::
string
cast
(
std
::
istringstream
&
iss
)
{
return
iss
.
str
();
}
};
/// Template specialization of signal_io for double
...
...
@@ -113,24 +115,24 @@ inline static std::string cast (std::istringstream &iss) { return iss.str(); }
/// (the strings used are the one produces by displaying special
/// values on a stream).
template
<
>
struct
signal_io
<
double
>
:
signal_io_base
<
double
>
{
inline
static
double
cast
(
std
::
istringstream
&
iss
)
{
std
::
string
tmp
(
iss
.
str
());
if
(
tmp
==
"nan"
)
return
std
::
numeric_limits
<
double
>::
quiet_NaN
();
else
if
(
tmp
==
"inf"
||
tmp
==
"+inf"
)
return
std
::
numeric_limits
<
double
>::
infinity
();
else
if
(
tmp
==
"-inf"
)
return
-
1.
*
std
::
numeric_limits
<
double
>::
infinity
();
try
{
return
boost
::
lexical_cast
<
double
>
(
tmp
);
}
catch
(
boost
::
bad_lexical_cast
&
)
{
boost
::
format
fmt
(
"failed to serialize %s (to double)"
);
fmt
%
tmp
;
throw
ExceptionSignal
(
ExceptionSignal
::
GENERIC
,
fmt
.
str
());
inline
static
double
cast
(
std
::
istringstream
&
iss
)
{
std
::
string
tmp
(
iss
.
str
());
if
(
tmp
==
"nan"
)
return
std
::
numeric_limits
<
double
>::
quiet_NaN
();
else
if
(
tmp
==
"inf"
||
tmp
==
"+inf"
)
return
std
::
numeric_limits
<
double
>::
infinity
();
else
if
(
tmp
==
"-inf"
)
return
-
1.
*
std
::
numeric_limits
<
double
>::
infinity
();
try
{
return
boost
::
lexical_cast
<
double
>
(
tmp
);
}
catch
(
boost
::
bad_lexical_cast
&
)
{
boost
::
format
fmt
(
"failed to serialize %s (to double)"
);
fmt
%
tmp
;
throw
ExceptionSignal
(
ExceptionSignal
::
GENERIC
,
fmt
.
str
());
}
}
}
};
}
// end of namespace dynamicgraph.
...
...
src/mt/process-list.cpp
View file @
870c6a6d
...
...
@@ -141,7 +141,7 @@ void System::readProcStat() {
if
(
!
init_
)
{
/// The number of CPU has been detected by going through /proc/stat.
vCPUData_
.
resize
(
cpuNb_
+
1
);
for
(
unsigned
long
i
=
0
;
i
<
(
unsigned
long
)
cpuNb_
;
i
++
)
for
(
unsigned
long
i
=
0
;
i
<
(
unsigned
long
)
cpuNb_
;
i
++
)
vCPUData_
[
i
].
cpu_id_
=
(
int
)
i
;
}
aif
.
close
();
...
...
tests/debug-tracer.cpp
View file @
870c6a6d
...
...
@@ -42,7 +42,8 @@ struct MyEntity : public dynamicgraph::Entity {
"MyEntity("
+
name
+
")::input(double)::out2double"
)
{
signalRegistration
(
m_sigdSIN
<<
m_sigdTimeDepSOUT
<<
m_sigVTimeDepSOUT
<<
m_sigdTwoTimeDepSOUT
);
signalRegistration
(
m_sigdSIN
<<
m_sigdTimeDepSOUT
<<
m_sigVTimeDepSOUT
<<
m_sigdTwoTimeDepSOUT
);
}
virtual
void
display
(
std
::
ostream
&
os
)
const
{
...
...
@@ -60,7 +61,7 @@ struct MyEntity : public dynamicgraph::Entity {
Vector
&
updateVector
(
Vector
&
res
,
const
int
&
inTime
)
{
const
double
&
aDouble
=
m_sigdSIN
(
inTime
);
res
.
resize
(
2
);
res
<<
aDouble
,
2
*
aDouble
;
res
<<
aDouble
,
2
*
aDouble
;
return
res
;
}
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment