Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix malloc issue in CRBA #2126

Merged
merged 3 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix missing include for Boost >= 1.83 ([#2103](https://github.com/stack-of-tasks/pinocchio/pull/2103))
- Remove f-strings to fix install with python 2 ([#2110](https://github.com/stack-of-tasks/pinocchio/pull/2110))
- CMake: stop exporting CppAd/cppadcodegen & fetch submodule if not available ([#2112](https://github.com/stack-of-tasks/pinocchio/pull/2112))
- Fix malloc issue in CRBA algo ([#2126](https://github.com/stack-of-tasks/pinocchio/pull/2126))

## [2.6.21] - 2023-11-27

Expand Down
2 changes: 1 addition & 1 deletion include/pinocchio/algorithm/crba.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace pinocchio
jmodel.jointCols(data.Fcrb[i]) = data.Ycrb[i] * jdata.S();

/* M[i,SUBTREE] = S'*F[1:6,SUBTREE] */
data.M.block(jmodel.idx_v(),jmodel.idx_v(),jmodel.nv(),data.nvSubtree[i])
data.M.block(jmodel.idx_v(),jmodel.idx_v(),jmodel.nv(),data.nvSubtree[i]).noalias()
= jdata.S().transpose()*data.Fcrb[i].middleCols(jmodel.idx_v(),data.nvSubtree[i]);

const JointIndex & parent = model.parents[i];
Expand Down
23 changes: 23 additions & 0 deletions unittest/crba.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
*
*/

#ifndef EIGEN_RUNTIME_NO_MALLOC
#define EIGEN_RUNTIME_NO_MALLOC
#endif

#include "pinocchio/multibody/model.hpp"
#include "pinocchio/multibody/data.hpp"
#include "pinocchio/algorithm/crba.hpp"
Expand Down Expand Up @@ -158,5 +162,24 @@ BOOST_AUTO_TEST_CASE(test_minimal_crba)

}

#ifndef NDEBUG

BOOST_AUTO_TEST_CASE(test_crba_malloc)
{
using namespace pinocchio;
pinocchio::Model model;
pinocchio::buildModels::humanoidRandom(model);

model.addJoint(size_t(model.njoints-1), pinocchio::JointModelRevoluteUnaligned(SE3::Vector3::UnitX()), SE3::Random(), "revolute_unaligned");
pinocchio::Data data(model);

const Eigen::VectorXd q = pinocchio::neutral(model);
Eigen::internal::set_is_malloc_allowed(false);
crba(model, data, q);
Eigen::internal::set_is_malloc_allowed(true);
}

#endif

BOOST_AUTO_TEST_SUITE_END ()

Loading