Skip to content

Commit fbe8683

Browse files
committed
Fix use of pinocchio::make_symmetric()
1 parent 7422af1 commit fbe8683

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

include/simple-mpc/math-util.hpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <Eigen/Core>
2+
3+
namespace simple_mpc
4+
{
5+
namespace math
6+
{
7+
8+
/// @note Backport from <pinocchio/math/matrix.hpp> in topic/simulation branch.
9+
template<typename Matrix>
10+
void make_symmetric(const Eigen::MatrixBase<Matrix> & mat, const int mode = Eigen::Upper)
11+
{
12+
if (mode == Eigen::Upper)
13+
{
14+
mat.const_cast_derived().template triangularView<Eigen::StrictlyLower>() =
15+
mat.transpose().template triangularView<Eigen::StrictlyLower>();
16+
}
17+
else if (mode == Eigen::Lower)
18+
{
19+
mat.const_cast_derived().template triangularView<Eigen::StrictlyUpper>() =
20+
mat.transpose().template triangularView<Eigen::StrictlyUpper>();
21+
}
22+
}
23+
24+
} // namespace math
25+
} // namespace simple_mpc

tests/robot_handler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <boost/test/unit_test.hpp>
33

44
#include "simple-mpc/fwd.hpp"
5+
#include "simple-mpc/math-util.hpp"
56
#include "simple-mpc/robot-handler.hpp"
67
#include "test_utils.cpp"
78
#include <pinocchio/algorithm/center-of-mass.hpp>
@@ -227,7 +228,7 @@ BOOST_AUTO_TEST_CASE(data_handler)
227228
pinocchio::computeJointJacobians(model, data);
228229
pinocchio::computeJointJacobiansTimeVariation(model, data, q, v);
229230
pinocchio::crba(model, data, q);
230-
pinocchio::make_symmetric(data.M);
231+
simple_mpc::math::make_symmetric(data.M);
231232
pinocchio::nonLinearEffects(model, data, q, v);
232233
pinocchio::dccrba(model, data, q, v);
233234

0 commit comments

Comments
 (0)