Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pinocchio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stack Of Tasks
pinocchio
Commits
931470e5
Commit
931470e5
authored
10 years ago
by
Nicolas Mansard
Committed by
Valenza Florian
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Complete version with substituion. timings around .25us for Uv, .5 for others.
parent
c5296506
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/algorithm/cholesky.hpp
+10
-3
10 additions, 3 deletions
src/algorithm/cholesky.hpp
unittest/cholesky.cpp
+37
-8
37 additions, 8 deletions
unittest/cholesky.cpp
with
47 additions
and
11 deletions
src/algorithm/cholesky.hpp
+
10
−
3
View file @
931470e5
...
...
@@ -67,14 +67,12 @@ namespace se3
template
<
typename
Mat
>
Mat
&
Uv
(
const
Model
&
model
,
Data
&
data
,
const
Data
&
data
,
Eigen
::
MatrixBase
<
Mat
>
&
v
)
{
assert
(
v
.
size
()
==
model
.
nv
);
EIGEN_STATIC_ASSERT_VECTOR_ONLY
(
Mat
);
const
Eigen
::
MatrixXd
&
U
=
data
.
U
;
const
Eigen
::
VectorXd
&
D
=
data
.
D
;
for
(
int
j
=
0
;
j
<
model
.
nv
;
++
j
)
v
[
j
]
+=
U
.
row
(
j
).
segment
(
j
+
1
,
data
.
nvSubtree_fromRow
[
j
]
-
1
)
...
...
@@ -197,6 +195,15 @@ namespace se3
return
v
.
derived
();
}
template
<
typename
Mat
>
Mat
&
solve
(
const
Model
&
model
,
Data
&
data
,
Eigen
::
MatrixBase
<
Mat
>
&
v
)
{
return
UtiDiv
(
model
,
data
,
Uiv
(
model
,
data
,
v
));
}
}
// namespace cholesky
}
// namespace se3
...
...
This diff is collapsed.
Click to expand it.
unittest/cholesky.cpp
+
37
−
8
View file @
931470e5
#ifdef NDEBUG
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
#include
"pinocchio/spatial/fwd.hpp"
#include
"pinocchio/spatial/se3.hpp"
#include
"pinocchio/multibody/joint.hpp"
...
...
@@ -30,6 +34,8 @@ void timings(const se3::Model & model, se3::Data& data, int flag = 1)
const
int
NBT
=
1
;
#endif
bool
verbose
=
flag
&
(
flag
-
1
);
// True is two or more binaries of the flag are 1.
if
(
flag
&
1
)
{
timer
.
tic
();
...
...
@@ -37,6 +43,7 @@ void timings(const se3::Model & model, se3::Data& data, int flag = 1)
{
se3
::
cholesky
::
decompose
(
model
,
data
);
}
if
(
verbose
)
std
::
cout
<<
"Decompose =
\t
"
;
timer
.
toc
(
std
::
cout
,
NBT
);
}
...
...
@@ -47,8 +54,31 @@ void timings(const se3::Model & model, se3::Data& data, int flag = 1)
{
Eigen
::
LDLT
<
Eigen
::
MatrixXd
>
Mchol
(
data
.
M
);
}
std
::
cout
<<
"
\t\t
"
;
timer
.
toc
(
std
::
cout
,
1000
);
if
(
verbose
)
std
::
cout
<<
"Eigen::LDLt =
\t
"
;
timer
.
toc
(
std
::
cout
,
NBT
);
}
if
(
flag
&
4
)
{
std
::
vector
<
Eigen
::
VectorXd
>
randvec
(
NBT
);
for
(
int
i
=
0
;
i
<
NBT
;
++
i
)
randvec
[
i
]
=
Eigen
::
VectorXd
::
Random
(
model
.
nv
);
Eigen
::
VectorXd
zero
=
Eigen
::
VectorXd
(
model
.
nv
);
Eigen
::
VectorXd
res
(
model
.
nv
);
timer
.
tic
();
SMOOTH
(
NBT
)
{
// se3::cholesky::Uv(model,data,randvec[_smooth]);
// se3::cholesky::Utv(model,data,randvec[_smooth]);
//se3::cholesky::DUtv(model,data,randvec[_smooth]);
// se3::cholesky::Uiv(model,data,randvec[_smooth]);
//se3::cholesky::Utiv(model,data,randvec[_smooth]);
se3
::
cholesky
::
UtiDiv
(
model
,
data
,
randvec
[
_smooth
]);
}
if
(
verbose
)
std
::
cout
<<
"Uv =
\t\t
"
;
timer
.
toc
(
std
::
cout
,
NBT
);
}
}
void
assertValues
(
const
se3
::
Model
&
model
,
se3
::
Data
&
data
)
...
...
@@ -72,9 +102,6 @@ void assertValues(const se3::Model & model, se3::Data& data)
Eigen
::
VectorXd
v
=
Eigen
::
VectorXd
::
Random
(
model
.
nv
);
std
::
cout
<<
"v = ["
<<
v
.
transpose
()
<<
"]';"
<<
std
::
endl
;
// Eigen::VectorXd UDv = v; se3::cholesky::UDv(model,data,UDv);
// std::cout << "UDv = [" << UDv.transpose() << "]';" << std::endl;
// assert( UDv.isApprox(U*D.asDiagonal()*v));
Eigen
::
VectorXd
Uv
=
v
;
se3
::
cholesky
::
Uv
(
model
,
data
,
Uv
);
assert
(
Uv
.
isApprox
(
U
*
v
));
...
...
@@ -90,7 +117,9 @@ void assertValues(const se3::Model & model, se3::Data& data)
assert
(
Utiv
.
isApprox
(
U
.
transpose
().
inverse
()
*
v
));
Eigen
::
VectorXd
UtiDiv
=
v
;
se3
::
cholesky
::
UtiDiv
(
model
,
data
,
UtiDiv
);
assert
(
UtiDiv
.
isApprox
(
U
.
transpose
().
inverse
()
*
D
.
asDiagonal
().
inverse
()
*
v
));
Eigen
::
VectorXd
Miv
=
v
;
se3
::
cholesky
::
solve
(
model
,
data
,
Miv
);
assert
(
Miv
.
isApprox
(
M
.
inverse
()
*
v
));
}
int
main
()
//int argc, const char ** argv)
...
...
@@ -106,8 +135,8 @@ int main()//int argc, const char ** argv)
SE3
::
Matrix3
I3
=
SE3
::
Matrix3
::
Identity
();
se3
::
Model
model
;
//
se3::buildModels::humanoidSimple(model,true);
se3
::
buildModels
::
humanoid2d
(
model
);
se3
::
buildModels
::
humanoidSimple
(
model
,
true
);
//
se3::buildModels::humanoid2d(model);
se3
::
Data
data
(
model
);
VectorXd
q
=
VectorXd
::
Zero
(
model
.
nq
);
...
...
@@ -117,7 +146,7 @@ int main()//int argc, const char ** argv)
#ifndef NDEBUG
assertValues
(
model
,
data
);
#else
timings
(
model
,
data
);
timings
(
model
,
data
,
1
|
4
);
#endif
return
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment