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

Pinocchio v3 compatibility #1253

Merged
merged 9 commits into from
May 31, 2024
3 changes: 2 additions & 1 deletion .github/workflows/conda/conda-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ dependencies:
- eigenpy
- hpp-fcl
- urdfdom
- cppad
# last cppadcodegen is not compatible with cppad 20240000
- cppad<=20230000
- cppadcodegen
- pinocchio
- ipopt
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ if(UNIX)
target_link_libraries(${PROJECT_NAME} pinocchio::pinocchio)
target_link_libraries(${PROJECT_NAME} Boost::filesystem Boost::system
Boost::serialization)
target_compile_definitions(
${PROJECT_NAME} PUBLIC PINOCCHIO_ENABLE_COMPATIBILITY_WITH_VERSION_2)

if(BUILD_WITH_MULTITHREADS)
target_link_libraries(${PROJECT_NAME} OpenMP::OpenMP_CXX)
Expand Down
13 changes: 10 additions & 3 deletions unittest/bindings/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,16 @@ def calc(self, data, x, u=None):
data.cost = data.activation.a_value

def calcDiff(self, data, x, u=None):
data.residual.Rx[:] = self.state.Jdiff(
self.xref, x, crocoddyl.Jcomponent.second
)[0]
# The old code was looking like this.
# But, the std::vector<Eigen::MatrixXd> returned by Jdiff is destroyed
# before the assignment.
# To avoid this issue, we store the std::vector in a variable.
# data.residual.Rx[:] = self.state.Jdiff(
# self.xref, x, crocoddyl.Jcomponent.second
# )[0]

diff = self.state.Jdiff(self.xref, x, crocoddyl.Jcomponent.second)
data.residual.Rx[:] = diff[0]
nim65s marked this conversation as resolved.
Show resolved Hide resolved
self.activation.calcDiff(data.activation, data.residual.r)
data.Lx[:] = np.dot(data.residual.Rx.T, data.activation.Ar)
data.Lxx[:, :] = np.dot(
Expand Down
4 changes: 2 additions & 2 deletions unittest/factory/residual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ ResidualModelFactory::create(ResidualModelTypes::Type residual_type,
geometry->addGeometryObject(pinocchio::GeometryObject(
"frame", frame_index,
state->get_pinocchio()->frames[frame_index].parent,
CollisionGeometryPtr(new hpp::fcl::Sphere(0)), frame_SE3));
std::make_shared<hpp::fcl::Sphere>(0), frame_SE3));
pinocchio::GeomIndex ig_obs =
geometry->addGeometryObject(pinocchio::GeometryObject(
"obs", state->get_pinocchio()->getFrameId("universe"),
state->get_pinocchio()
->frames[state->get_pinocchio()->getFrameId("universe")]
.parent,
CollisionGeometryPtr(new hpp::fcl::Sphere(0)), frame_SE3_obstacle));
std::make_shared<hpp::fcl::Sphere>(0), frame_SE3_obstacle));
geometry->addCollisionPair(pinocchio::CollisionPair(ig_frame, ig_obs));
#endif // PINOCCHIO_WITH_HPP_FCL
if (nu == std::numeric_limits<std::size_t>::max()) {
Expand Down
Loading