Skip to content
GitLab
Menu
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
pinocchio
Commits
f4a92f39
Unverified
Commit
f4a92f39
authored
Feb 07, 2020
by
Justin Carpentier
Committed by
GitHub
Feb 07, 2020
Browse files
Merge pull request #1060 from proyan/devel
Minor fixes in code-gen benchmark and code-gen
parents
0f221d87
4aa6ff00
Changes
6
Hide whitespace changes
Inline
Side-by-side
benchmark/timings-cg.cpp
View file @
f4a92f39
...
...
@@ -38,8 +38,7 @@ int main(int argc, const char ** argv)
#endif
pinocchio
::
Model
model
;
std
::
string
filename
=
PINOCCHIO_SOURCE_DIR
"/models/simple_humanoid.urdf"
;
std
::
string
filename
=
PINOCCHIO_MODEL_DIR
+
std
::
string
(
"/simple_humanoid.urdf"
);
if
(
argc
>
1
)
filename
=
argv
[
1
];
bool
with_ff
=
true
;
...
...
src/codegen/code-generator-algo.hpp
View file @
f4a92f39
...
...
@@ -25,7 +25,7 @@ namespace pinocchio
typedef
typename
Base
::
Scalar
Scalar
;
typedef
typename
Base
::
Model
Model
;
typedef
typename
Base
::
ADCon
g
igVectorType
ADCon
g
igVectorType
;
typedef
typename
Base
::
ADCon
f
igVectorType
ADCon
f
igVectorType
;
typedef
typename
Base
::
ADTangentVectorType
ADTangentVectorType
;
typedef
typename
Base
::
MatrixXs
MatrixXs
;
typedef
typename
Base
::
VectorXs
VectorXs
;
...
...
@@ -35,7 +35,7 @@ namespace pinocchio
const
std
::
string
&
library_name
=
"cg_rnea_eval"
)
:
Base
(
model
,
model
.
nq
+
2
*
model
.
nv
,
model
.
nv
,
function_name
,
library_name
)
{
ad_q
=
ADCon
g
igVectorType
(
model
.
nq
);
ad_q
=
neutral
(
model
);
ad_q
=
ADCon
f
igVectorType
(
model
.
nq
);
ad_q
=
neutral
(
ad_
model
);
ad_v
=
ADTangentVectorType
(
model
.
nv
);
ad_v
.
setZero
();
ad_a
=
ADTangentVectorType
(
model
.
nv
);
ad_a
.
setZero
();
x
=
VectorXs
::
Zero
(
Base
::
getInputDimension
());
...
...
@@ -113,7 +113,7 @@ namespace pinocchio
VectorXs
x
;
VectorXs
res
;
ADCon
g
igVectorType
ad_q
,
ad_q_plus
;
ADCon
f
igVectorType
ad_q
,
ad_q_plus
;
ADTangentVectorType
ad_dq
,
ad_v
,
ad_a
;
};
...
...
@@ -124,7 +124,7 @@ namespace pinocchio
typedef
typename
Base
::
Scalar
Scalar
;
typedef
typename
Base
::
Model
Model
;
typedef
typename
Base
::
ADCon
g
igVectorType
ADCon
g
igVectorType
;
typedef
typename
Base
::
ADCon
f
igVectorType
ADCon
f
igVectorType
;
typedef
typename
Base
::
ADTangentVectorType
ADTangentVectorType
;
typedef
typename
Base
::
MatrixXs
MatrixXs
;
typedef
typename
Base
::
VectorXs
VectorXs
;
...
...
@@ -134,7 +134,7 @@ namespace pinocchio
const
std
::
string
&
library_name
=
"cg_aba_eval"
)
:
Base
(
model
,
model
.
nq
+
2
*
model
.
nv
,
model
.
nv
,
function_name
,
library_name
)
{
ad_q
=
ADCon
g
igVectorType
(
model
.
nq
);
ad_q
=
neutral
(
model
);
ad_q
=
ADCon
f
igVectorType
(
model
.
nq
);
ad_q
=
neutral
(
ad_
model
);
ad_v
=
ADTangentVectorType
(
model
.
nv
);
ad_v
.
setZero
();
ad_tau
=
ADTangentVectorType
(
model
.
nv
);
ad_tau
.
setZero
();
x
=
VectorXs
::
Zero
(
Base
::
getInputDimension
());
...
...
@@ -144,7 +144,7 @@ namespace pinocchio
da_dv
=
MatrixXs
::
Zero
(
model
.
nv
,
model
.
nv
);
da_dtau
=
MatrixXs
::
Zero
(
model
.
nv
,
model
.
nv
);
}
void
buildMap
()
{
CppAD
::
Independent
(
ad_X
);
...
...
@@ -212,7 +212,7 @@ namespace pinocchio
VectorXs
x
;
VectorXs
res
;
ADCon
g
igVectorType
ad_q
,
ad_q_plus
;
ADCon
f
igVectorType
ad_q
,
ad_q_plus
;
ADTangentVectorType
ad_dq
,
ad_v
,
ad_tau
;
};
...
...
@@ -223,7 +223,7 @@ namespace pinocchio
typedef
typename
Base
::
Scalar
Scalar
;
typedef
typename
Base
::
Model
Model
;
typedef
typename
Base
::
ADCon
g
igVectorType
ADCon
g
igVectorType
;
typedef
typename
Base
::
ADCon
f
igVectorType
ADCon
f
igVectorType
;
typedef
typename
Base
::
ADTangentVectorType
ADTangentVectorType
;
typedef
typename
Base
::
MatrixXs
MatrixXs
;
typedef
typename
Base
::
VectorXs
VectorXs
;
...
...
@@ -233,7 +233,7 @@ namespace pinocchio
const
std
::
string
&
library_name
=
"cg_crba_eval"
)
:
Base
(
model
,
model
.
nq
,(
model
.
nv
*
(
model
.
nv
+
1
))
/
2
,
function_name
,
library_name
)
{
ad_q
=
ADCon
g
igVectorType
(
model
.
nq
);
ad_q
=
neutral
(
model
);
ad_q
=
ADCon
f
igVectorType
(
model
.
nq
);
ad_q
=
neutral
(
ad_
model
);
x
=
VectorXs
::
Zero
(
Base
::
getInputDimension
());
res
=
VectorXs
::
Zero
(
Base
::
getOutputDimension
());
...
...
@@ -302,7 +302,7 @@ namespace pinocchio
VectorXs
x
;
VectorXs
res
;
ADCon
g
igVectorType
ad_q
;
ADCon
f
igVectorType
ad_q
;
};
template
<
typename
_Scalar
>
...
...
@@ -312,7 +312,7 @@ namespace pinocchio
typedef
typename
Base
::
Scalar
Scalar
;
typedef
typename
Base
::
Model
Model
;
typedef
typename
Base
::
ADCon
g
igVectorType
ADCon
g
igVectorType
;
typedef
typename
Base
::
ADCon
f
igVectorType
ADCon
f
igVectorType
;
typedef
typename
Base
::
ADTangentVectorType
ADTangentVectorType
;
typedef
typename
Base
::
MatrixXs
MatrixXs
;
typedef
typename
Base
::
VectorXs
VectorXs
;
...
...
@@ -322,7 +322,7 @@ namespace pinocchio
const
std
::
string
&
library_name
=
"cg_minv_eval"
)
:
Base
(
model
,
model
.
nq
,(
model
.
nv
*
(
model
.
nv
+
1
))
/
2
,
function_name
,
library_name
)
{
ad_q
=
ADCon
g
igVectorType
(
model
.
nq
);
ad_q
=
neutral
(
model
);
ad_q
=
ADCon
f
igVectorType
(
model
.
nq
);
ad_q
=
neutral
(
ad_
model
);
x
=
VectorXs
::
Zero
(
Base
::
getInputDimension
());
res
=
VectorXs
::
Zero
(
Base
::
getOutputDimension
());
...
...
@@ -388,7 +388,7 @@ namespace pinocchio
VectorXs
x
;
VectorXs
res
;
ADCon
g
igVectorType
ad_q
;
ADCon
f
igVectorType
ad_q
;
};
template
<
typename
_Scalar
>
...
...
@@ -398,7 +398,7 @@ namespace pinocchio
typedef
typename
Base
::
Scalar
Scalar
;
typedef
typename
Base
::
Model
Model
;
typedef
typename
Base
::
ADCon
g
igVectorType
ADCon
g
igVectorType
;
typedef
typename
Base
::
ADCon
f
igVectorType
ADCon
f
igVectorType
;
typedef
typename
Base
::
ADTangentVectorType
ADTangentVectorType
;
typedef
typename
Base
::
MatrixXs
MatrixXs
;
typedef
typename
PINOCCHIO_EIGEN_PLAIN_ROW_MAJOR_TYPE
(
MatrixXs
)
RowMatrixXs
;
...
...
@@ -413,7 +413,7 @@ namespace pinocchio
const
std
::
string
&
library_name
=
"cg_partial_rnea_eval"
)
:
Base
(
model
,
model
.
nq
+
2
*
model
.
nv
,
3
*
model
.
nv
*
model
.
nv
,
function_name
,
library_name
)
{
ad_q
=
ADCon
g
igVectorType
(
model
.
nq
);
ad_q
=
neutral
(
model
);
ad_q
=
ADCon
f
igVectorType
(
model
.
nq
);
ad_q
=
neutral
(
ad_
model
);
ad_v
=
ADTangentVectorType
(
model
.
nv
);
ad_v
.
setZero
();
ad_a
=
ADTangentVectorType
(
model
.
nv
);
ad_a
.
setZero
();
...
...
@@ -496,7 +496,7 @@ namespace pinocchio
ADMatrixXs
ad_dtau_dq
,
ad_dtau_dv
,
ad_dtau_da
;
MatrixXs
dtau_dq
,
dtau_dv
,
dtau_da
;
ADCon
g
igVectorType
ad_q
;
ADCon
f
igVectorType
ad_q
;
ADTangentVectorType
ad_v
,
ad_a
;
};
...
...
@@ -507,7 +507,7 @@ namespace pinocchio
typedef
typename
Base
::
Scalar
Scalar
;
typedef
typename
Base
::
Model
Model
;
typedef
typename
Base
::
ADCon
g
igVectorType
ADCon
g
igVectorType
;
typedef
typename
Base
::
ADCon
f
igVectorType
ADCon
f
igVectorType
;
typedef
typename
Base
::
ADTangentVectorType
ADTangentVectorType
;
typedef
typename
Base
::
MatrixXs
MatrixXs
;
typedef
typename
PINOCCHIO_EIGEN_PLAIN_ROW_MAJOR_TYPE
(
MatrixXs
)
RowMatrixXs
;
...
...
@@ -522,7 +522,7 @@ namespace pinocchio
const
std
::
string
&
library_name
=
"cg_partial_aba_eval"
)
:
Base
(
model
,
model
.
nq
+
2
*
model
.
nv
,
3
*
model
.
nv
*
model
.
nv
,
function_name
,
library_name
)
{
ad_q
=
ADCon
g
igVectorType
(
model
.
nq
);
ad_q
=
neutral
(
model
);
ad_q
=
ADCon
f
igVectorType
(
model
.
nq
);
ad_q
=
neutral
(
ad_
model
);
ad_v
=
ADTangentVectorType
(
model
.
nv
);
ad_v
.
setZero
();
ad_tau
=
ADTangentVectorType
(
model
.
nv
);
ad_tau
.
setZero
();
...
...
@@ -605,7 +605,7 @@ namespace pinocchio
ADMatrixXs
ad_dddq_dq
,
ad_dddq_dv
,
ad_dddq_dtau
;
MatrixXs
dddq_dq
,
dddq_dv
,
dddq_dtau
;
ADCon
g
igVectorType
ad_q
;
ADCon
f
igVectorType
ad_q
;
ADTangentVectorType
ad_v
,
ad_tau
;
};
...
...
src/codegen/code-generator-base.hpp
View file @
f4a92f39
...
...
@@ -36,10 +36,10 @@ namespace pinocchio
typedef
Eigen
::
Matrix
<
Scalar
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
,
Options
|
Eigen
::
RowMajor
>
RowMatrixXs
;
typedef
Eigen
::
Matrix
<
ADScalar
,
Eigen
::
Dynamic
,
1
,
Options
>
ADVectorXs
;
typedef
typename
Model
::
ConfigVectorType
Con
g
igVectorType
;
typedef
typename
Model
::
ConfigVectorType
Con
f
igVectorType
;
typedef
typename
Model
::
TangentVectorType
TangentVectorType
;
typedef
typename
ADModel
::
ConfigVectorType
ADCon
g
igVectorType
;
typedef
typename
ADModel
::
ConfigVectorType
ADCon
f
igVectorType
;
typedef
typename
ADModel
::
TangentVectorType
ADTangentVectorType
;
typedef
CppAD
::
ADFun
<
CGScalar
>
ADFun
;
...
...
@@ -161,7 +161,7 @@ namespace pinocchio
ADVectorXs
ad_X
,
ad_Y
;
ADFun
ad_fun
;
ADCon
g
igVectorType
ad_q
,
ad_q_plus
;
ADCon
f
igVectorType
ad_q
,
ad_q_plus
;
ADTangentVectorType
ad_dq
,
ad_v
,
ad_a
;
VectorXs
y
;
...
...
unittest/cppad-algo-derivatives.cpp
View file @
f4a92f39
...
...
@@ -49,9 +49,9 @@ BOOST_AUTO_TEST_CASE(test_rnea_derivatives)
ADData
ad_data
(
ad_model
);
// Sample random configuration
typedef
Model
::
ConfigVectorType
Con
g
igVectorType
;
typedef
Model
::
ConfigVectorType
Con
f
igVectorType
;
typedef
Model
::
TangentVectorType
TangentVectorType
;
Con
g
igVectorType
q
(
model
.
nq
);
Con
f
igVectorType
q
(
model
.
nq
);
q
=
pinocchio
::
randomConfiguration
(
model
);
TangentVectorType
v
(
TangentVectorType
::
Random
(
model
.
nv
));
...
...
@@ -69,10 +69,10 @@ BOOST_AUTO_TEST_CASE(test_rnea_derivatives)
rnea_partial_da
.
triangularView
<
Eigen
::
StrictlyLower
>
()
=
rnea_partial_da
.
transpose
().
triangularView
<
Eigen
::
StrictlyLower
>
();
typedef
ADModel
::
ConfigVectorType
ADCon
g
igVectorType
;
typedef
ADModel
::
ConfigVectorType
ADCon
f
igVectorType
;
typedef
ADModel
::
TangentVectorType
ADTangentVectorType
;
ADCon
g
igVectorType
ad_q
=
q
.
cast
<
ADScalar
>
();
ADCon
f
igVectorType
ad_q
=
q
.
cast
<
ADScalar
>
();
ADTangentVectorType
ad_dq
=
ADTangentVectorType
::
Zero
(
model
.
nv
);
ADTangentVectorType
ad_v
=
v
.
cast
<
ADScalar
>
();
ADTangentVectorType
ad_a
=
a
.
cast
<
ADScalar
>
();
...
...
@@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(test_rnea_derivatives)
// dtau_dq
{
CppAD
::
Independent
(
ad_dq
);
ADCon
g
igVectorType
ad_q_plus
=
pinocchio
::
integrate
(
ad_model
,
ad_q
,
ad_dq
);
ADCon
f
igVectorType
ad_q_plus
=
pinocchio
::
integrate
(
ad_model
,
ad_q
,
ad_dq
);
pinocchio
::
rnea
(
ad_model
,
ad_data
,
ad_q_plus
,
ad_v
,
ad_a
);
VectorXAD
Y
(
model
.
nv
);
...
...
@@ -175,9 +175,9 @@ BOOST_AUTO_TEST_CASE(test_aba_derivatives)
ADData
ad_data
(
ad_model
);
// Sample random configuration
typedef
Model
::
ConfigVectorType
Con
g
igVectorType
;
typedef
Model
::
ConfigVectorType
Con
f
igVectorType
;
typedef
Model
::
TangentVectorType
TangentVectorType
;
Con
g
igVectorType
q
(
model
.
nq
);
Con
f
igVectorType
q
(
model
.
nq
);
q
=
pinocchio
::
randomConfiguration
(
model
);
TangentVectorType
v
(
TangentVectorType
::
Random
(
model
.
nv
));
...
...
@@ -195,10 +195,10 @@ BOOST_AUTO_TEST_CASE(test_aba_derivatives)
aba_partial_dtau
.
triangularView
<
Eigen
::
StrictlyLower
>
()
=
aba_partial_dtau
.
transpose
().
triangularView
<
Eigen
::
StrictlyLower
>
();
typedef
ADModel
::
ConfigVectorType
ADCon
g
igVectorType
;
typedef
ADModel
::
ConfigVectorType
ADCon
f
igVectorType
;
typedef
ADModel
::
TangentVectorType
ADTangentVectorType
;
ADCon
g
igVectorType
ad_q
=
q
.
cast
<
ADScalar
>
();
ADCon
f
igVectorType
ad_q
=
q
.
cast
<
ADScalar
>
();
ADTangentVectorType
ad_dq
=
ADTangentVectorType
::
Zero
(
model
.
nv
);
ADTangentVectorType
ad_v
=
v
.
cast
<
ADScalar
>
();
ADTangentVectorType
ad_tau
=
tau
.
cast
<
ADScalar
>
();
...
...
@@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE(test_aba_derivatives)
// dddq_dq
{
CppAD
::
Independent
(
ad_dq
);
ADCon
g
igVectorType
ad_q_plus
=
pinocchio
::
integrate
(
ad_model
,
ad_q
,
ad_dq
);
ADCon
f
igVectorType
ad_q_plus
=
pinocchio
::
integrate
(
ad_model
,
ad_q
,
ad_dq
);
pinocchio
::
aba
(
ad_model
,
ad_data
,
ad_q_plus
,
ad_v
,
ad_tau
);
VectorXAD
Y
(
model
.
nv
);
...
...
unittest/cppad-algo.cpp
View file @
f4a92f39
...
...
@@ -47,18 +47,18 @@ BOOST_AUTO_TEST_CASE(test_mass_matrix)
ADData
ad_data
(
ad_model
);
// Sample random configuration
typedef
Model
::
ConfigVectorType
Con
g
igVectorType
;
typedef
Model
::
ConfigVectorType
Con
f
igVectorType
;
typedef
Model
::
TangentVectorType
TangentVectorType
;
Con
g
igVectorType
q
(
model
.
nq
);
Con
f
igVectorType
q
(
model
.
nq
);
q
=
pinocchio
::
randomConfiguration
(
model
);
TangentVectorType
v
(
TangentVectorType
::
Random
(
model
.
nv
));
TangentVectorType
a
(
TangentVectorType
::
Random
(
model
.
nv
));
typedef
ADModel
::
ConfigVectorType
ADCon
g
igVectorType
;
typedef
ADModel
::
ConfigVectorType
ADCon
f
igVectorType
;
typedef
ADModel
::
TangentVectorType
ADTangentVectorType
;
ADCon
g
igVectorType
ad_q
=
q
.
cast
<
ADScalar
>
();
ADCon
f
igVectorType
ad_q
=
q
.
cast
<
ADScalar
>
();
ADTangentVectorType
ad_v
=
v
.
cast
<
ADScalar
>
();
ADTangentVectorType
ad_a
=
a
.
cast
<
ADScalar
>
();
...
...
@@ -145,18 +145,18 @@ BOOST_AUTO_TEST_CASE(test_kinematics_jacobian)
ADData
ad_data
(
ad_model
);
// Sample random configuration
typedef
Model
::
ConfigVectorType
Con
g
igVectorType
;
typedef
Model
::
ConfigVectorType
Con
f
igVectorType
;
typedef
Model
::
TangentVectorType
TangentVectorType
;
Con
g
igVectorType
q
(
model
.
nq
);
Con
f
igVectorType
q
(
model
.
nq
);
q
=
pinocchio
::
randomConfiguration
(
model
);
TangentVectorType
v
(
TangentVectorType
::
Random
(
model
.
nv
));
TangentVectorType
a
(
TangentVectorType
::
Random
(
model
.
nv
));
typedef
ADModel
::
ConfigVectorType
ADCon
g
igVectorType
;
typedef
ADModel
::
ConfigVectorType
ADCon
f
igVectorType
;
typedef
ADModel
::
TangentVectorType
ADTangentVectorType
;
ADCon
g
igVectorType
ad_q
=
q
.
cast
<
ADScalar
>
();
ADCon
f
igVectorType
ad_q
=
q
.
cast
<
ADScalar
>
();
ADTangentVectorType
ad_v
=
v
.
cast
<
ADScalar
>
();
ADTangentVectorType
ad_a
=
a
.
cast
<
ADScalar
>
();
...
...
unittest/cppadcg-algo.cpp
View file @
f4a92f39
...
...
@@ -47,18 +47,18 @@ BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
ADData
ad_data
(
ad_model
);
// Sample random configuration
typedef
Model
::
ConfigVectorType
Con
g
igVectorType
;
typedef
Model
::
ConfigVectorType
Con
f
igVectorType
;
typedef
Model
::
TangentVectorType
TangentVectorType
;
Con
g
igVectorType
q
(
model
.
nq
);
Con
f
igVectorType
q
(
model
.
nq
);
q
=
pinocchio
::
randomConfiguration
(
model
);
TangentVectorType
v
(
TangentVectorType
::
Random
(
model
.
nv
));
TangentVectorType
a
(
TangentVectorType
::
Random
(
model
.
nv
));
typedef
ADModel
::
ConfigVectorType
ADCon
g
igVectorType
;
typedef
ADModel
::
ConfigVectorType
ADCon
f
igVectorType
;
typedef
ADModel
::
TangentVectorType
ADTangentVectorType
;
ADCon
g
igVectorType
ad_q
=
q
.
cast
<
ADScalar
>
();
ADCon
f
igVectorType
ad_q
=
q
.
cast
<
ADScalar
>
();
ADTangentVectorType
ad_v
=
v
.
cast
<
ADScalar
>
();
ADTangentVectorType
ad_a
=
a
.
cast
<
ADScalar
>
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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