Commit a179f561 authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub

Merge pull request #1243 from jcarpent/devel

Clean Codegen and Autodiff packaging
parents 47ae2f83 853824c7
Pipeline #9855 passed with stage
in 318 minutes and 10 seconds
......@@ -114,25 +114,13 @@ IF(BUILD_WITH_AUTODIFF_SUPPORT)
# Check first CppADCodeGen
IF(BUILD_WITH_CODEGEN_SUPPORT)
ADD_PROJECT_DEPENDENCY(cppadcg 2.4.1 REQUIRED PKG_CONFIG_REQUIRES "cppadcg >= 2.4.1") # CppADCodeGen 2.4.1 is the first version to check the minimal version of CppAD
IF(CPPADCG_FOUND AND BUILD_WITH_CODEGEN_SUPPORT)
ADD_DEFINITIONS(-DPINOCCHIO_WITH_CPPADCG_SUPPORT)
PKG_CONFIG_APPEND_CFLAGS("-DPINOCCHIO_WITH_CPPADCG_SUPPORT")
ENDIF(CPPADCG_FOUND AND BUILD_WITH_CODEGEN_SUPPORT)
ENDIF(BUILD_WITH_CODEGEN_SUPPORT)
ADD_PROJECT_DEPENDENCY(cppad 20180000.0 REQUIRED PKG_CONFIG_REQUIRES "cppad >= 20180000.0")
ADD_DEFINITIONS(-DPINOCCHIO_WITH_CPPAD_SUPPORT)
PKG_CONFIG_APPEND_CFLAGS("-DPINOCCHIO_WITH_CPPAD_SUPPORT")
IF(NOT ${EIGEN3_VERSION} VERSION_GREATER "3.3.0")
ADD_DEFINITIONS(-DPINOCCHIO_CPPAD_REQUIRES_MATRIX_BASE_PLUGIN)
PKG_CONFIG_APPEND_CFLAGS("-DPINOCCHIO_CPPAD_REQUIRES_MATRIX_BASE_PLUGIN")
ENDIF(NOT ${EIGEN3_VERSION} VERSION_GREATER "3.3.0")
ENDIF(BUILD_WITH_AUTODIFF_SUPPORT)
IF(BUILD_WITH_CASADI_SUPPORT)
ADD_PROJECT_DEPENDENCY(casadi 3.4.5 REQUIRED PKG_CONFIG_REQUIRES "casadi >= 3.4.5")
ADD_DEFINITIONS(-DPINOCCHIO_WITH_CASADI_SUPPORT)
PKG_CONFIG_APPEND_CFLAGS("-DPINOCCHIO_WITH_CASADI_SUPPORT")
ENDIF(BUILD_WITH_CASADI_SUPPORT)
SET(BOOST_REQUIRED_COMPONENTS filesystem serialization system)
......
Subproject commit 865044fec87cd6ca80ef1d261ed08642dd28035c
Subproject commit 8025b5ef68117f2bea7c465b9866ae878e18a66a
......@@ -3,7 +3,7 @@
#
IF(CPPADCG_FOUND AND BUILD_WITH_CODEGEN_SUPPORT AND BUILD_WITH_URDF_SUPPORT)
INCLUDE_DIRECTORIES(${cppadcg_INCLUDE_DIR})
INCLUDE_DIRECTORIES(SYSTEM ${cppadcg_INCLUDE_DIR})
ADD_PINOCCHIO_CPP_EXAMPLE(codegen-crba)
SET_PROPERTY(TARGET example-cpp-codegen-crba PROPERTY CXX_STANDARD 11)
TARGET_LINK_LIBRARIES(example-cpp-codegen-crba PUBLIC ${CMAKE_DL_LIBS})
......
<?xml version="1.0"?>
<package format="3">
<name>pinocchio</name>
<version>2.4.5</version>
<version>2.4.6</version>
<description>A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives.</description>
<!-- The maintainer listed here is for the ROS release to receive emails for the buildfarm.
Please check the repository URL for full list of authors and maintainers. -->
......
//
// Copyright (c) 2016-2019 CNRS, INRIA
// Copyright (c) 2016-2020 CNRS, INRIA
//
#ifndef __pinocchio_aba_hxx__
#define __pinocchio_aba_hxx__
#ifdef PINOCCHIO_WITH_CPPAD_SUPPORT
#include "pinocchio/autodiff/cppad.hpp"
#endif
#include "pinocchio/spatial/act-on-set.hpp"
#include "pinocchio/multibody/visitor.hpp"
#include "pinocchio/algorithm/check.hpp"
......
......@@ -5,6 +5,8 @@
#ifndef __pinocchio_autodiff_casadi_hpp__
#define __pinocchio_autodiff_casadi_hpp__
#define PINOCCHIO_WITH_CASADI_SUPPORT
#include "pinocchio/math/fwd.hpp"
#include <casadi/casadi.hpp>
......
......@@ -2,19 +2,18 @@
// Copyright (c) 2018-2020 CNRS INRIA
//
#ifndef __pinocchio_autodiff_ccpad_hpp__
#define __pinocchio_autodiff_ccpad_hpp__
#ifndef __pinocchio_autodiff_cppad_hpp__
#define __pinocchio_autodiff_cppad_hpp__
#include "pinocchio/math/fwd.hpp"
#define PINOCCHIO_WITH_CPPAD_SUPPORT
// Do not include this file directly.
// Copy and use directly the intructions from <cppad/example/cppad_eigen.hpp>
// to avoid redifinition of EIGEN_MATRIXBASE_PLUGIN for Eigen 3.3.0 and later
//#include <cppad/example/cppad_eigen.hpp>
#ifdef PINOCCHIO_CPPAD_REQUIRES_MATRIX_BASE_PLUGIN
#define EIGEN_MATRIXBASE_PLUGIN <cppad/example/eigen_plugin.hpp>
#endif
#define EIGEN_MATRIXBASE_PLUGIN <pinocchio/autodiff/cppad/math/eigen_plugin.hpp>
#include <cppad/cppad.hpp>
#include <Eigen/Dense>
......@@ -178,4 +177,4 @@ namespace pinocchio
#include "pinocchio/autodiff/cppad/utils/static-if.hpp"
#include "pinocchio/autodiff/cppad/math/quaternion.hpp"
#endif // #ifndef __pinocchio_autodiff_ccpad_hpp__
#endif // #ifndef __pinocchio_autodiff_cppad_hpp__
#if !EIGEN_VERSION_AT_LEAST(3,3,3)
typedef Scalar value_type;
#endif
//
// Copyright (c) 2018 CNRS
// Copyright (c) 2018-2020 CNRS INRIA
//
#ifndef __pinocchio_utils_code_generator_base_hpp__
......@@ -10,8 +10,6 @@
#include "pinocchio/multibody/model.hpp"
#include "pinocchio/multibody/data.hpp"
#ifdef PINOCCHIO_WITH_CPPADCG_SUPPORT
namespace pinocchio
{
......@@ -178,6 +176,4 @@ namespace pinocchio
} // namespace pinocchio
#endif // PINOCCHIO_WITH_CPPADCG_SUPPORT
#endif // ifndef __pinocchio_utils_code_generator_base_hpp__
......@@ -5,6 +5,8 @@
#ifndef __pinocchio_codegen_ccpadcg_hpp__
#define __pinocchio_codegen_ccpadcg_hpp__
#define PINOCCHIO_WITH_CPPADCG_SUPPORT
#include "pinocchio/math/fwd.hpp"
#include <cmath>
......
......@@ -182,8 +182,8 @@ BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
ad_X.resize(2);
ad_Y.resize(2);
Eigen::Matrix2d x_test(-1,1);
Eigen::Matrix2d y_test = x_test.array().min(Scalar(0.));
Eigen::Vector2d x_test(-1,1);
Eigen::Vector2d y_test = x_test.array().min(Scalar(0.));
CppAD::Independent(ad_X);
//Function
......@@ -191,11 +191,11 @@ BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
CppAD::ADFun<Scalar> ad_fun(ad_X,ad_Y);
CPPAD_TESTVECTOR(Scalar) x((size_t)2);
Eigen::Map<Eigen::Matrix2d>(x.data(),2,1) = x_test;
Eigen::Map<Eigen::Vector2d>(x.data(),2,1) = x_test;
CPPAD_TESTVECTOR(Scalar) y = ad_fun.Forward(0,x);
BOOST_CHECK(Eigen::Map<Eigen::Matrix2d>(y.data(),2,1).isApprox(y_test));
BOOST_CHECK(Eigen::Map<Eigen::Vector2d>(y.data(),2,1).isApprox(y_test));
}
BOOST_AUTO_TEST_CASE(test_eigen_max)
......@@ -209,8 +209,8 @@ BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
ad_X.resize(2);
ad_Y.resize(2);
Eigen::Matrix2d x_test(-1,1);
Eigen::Matrix2d y_test = x_test.array().max(Scalar(0.));
Eigen::Vector2d x_test(-1,1);
Eigen::Vector2d y_test = x_test.array().max(Scalar(0.));
CppAD::Independent(ad_X);
//Function
......@@ -218,11 +218,11 @@ BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
CppAD::ADFun<Scalar> ad_fun(ad_X,ad_Y);
CPPAD_TESTVECTOR(Scalar) x((size_t)2);
Eigen::Map<Eigen::Matrix2d>(x.data(),2,1) = x_test;
Eigen::Map<Eigen::Vector2d>(x.data(),2,1) = x_test;
CPPAD_TESTVECTOR(Scalar) y = ad_fun.Forward(0,x);
BOOST_CHECK(Eigen::Map<Eigen::Matrix2d>(y.data(),2,1).isApprox(y_test));
BOOST_CHECK(Eigen::Map<Eigen::Vector2d>(y.data(),2,1).isApprox(y_test));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment