Skip to content

Commit

Permalink
adding the FD derivatives using finite-diff
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamsingh91 committed Apr 17, 2024
1 parent 2bc3b5e commit 2e36d21
Show file tree
Hide file tree
Showing 21 changed files with 3,227 additions and 5 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ OPTION(BUILD_WITH_URDF_SUPPORT "Build the library with the URDF format support"
OPTION(BUILD_WITH_COLLISION_SUPPORT "Build the library with the collision support (required HPP-FCL)" OFF)
OPTION(BUILD_WITH_AUTODIFF_SUPPORT "Build the library with the automatic differentiation support (via CppAD)" ON)
OPTION(BUILD_WITH_CASADI_SUPPORT "Build the library with the support of CASADI" ON)
OPTION(BUILD_WITH_CODEGEN_SUPPORT "Build the library with the support of code generation (via CppADCodeGen)" ON)
OPTION(BUILD_WITH_CODEGEN_SUPPORT "Build the library with the support of code generation (via CppADCodeGen)" OFF)
OPTION(BUILD_WITH_OPENMP_SUPPORT "Build the library with the OpenMP support" OFF)
cmake_dependent_option(LINK_PYTHON_INTERFACE_TO_OPENMP "Link OpenMP to the Python interface" ON
"BUILD_PYTHON_INTERFACE;BUILD_WITH_OPENMP_SUPPORT" OFF)
Expand Down Expand Up @@ -120,10 +120,10 @@ ENDIF(BUILD_WITH_URDF_SUPPORT)
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
ADD_PROJECT_DEPENDENCY(cppadcg PKG_CONFIG_REQUIRES "cppadcg >= 2.4.1") # CppADCodeGen 2.4.1 is the first version to check the minimal version of CppAD
ENDIF(BUILD_WITH_CODEGEN_SUPPORT)

ADD_PROJECT_DEPENDENCY(cppad 20180000.0 REQUIRED PKG_CONFIG_REQUIRES "cppad >= 20180000.0")
ADD_PROJECT_DEPENDENCY(cppad PKG_CONFIG_REQUIRES "cppad >= 20180000.0")
ENDIF(BUILD_WITH_AUTODIFF_SUPPORT)

IF(BUILD_WITH_CASADI_SUPPORT)
Expand Down
Empty file added benchmark.txt
Empty file.
Binary file added benchmark/AD_mdof_v3_g
Binary file not shown.
6 changes: 4 additions & 2 deletions benchmark/AD_mdof_v4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This version compares the CPU Runtime for
#include "pinocchio/parsers/sample-models.hpp"
#include "pinocchio/container/aligned-vector.hpp"
#include "pinocchio/algorithm/rnea-derivatives-SO.hpp"
#include "pinocchio/algorithm/rnea-second-order-derivatives.hpp"
#include "pinocchio/codegen/code-generator-algo.hpp"
// #include "pinocchio/algorithm/aza_so_v2.hpp"
#include "pinocchio/algorithm/ID_FO_AZA.hpp"
Expand All @@ -37,6 +38,7 @@ This version compares the CPU Runtime for
#include "pinocchio/utils/tensor_utils.hpp"
// #include "pinocchio/algorithm/aba_v2.hpp"
#include "pinocchio/algorithm/aba-derivatives-faster.hpp"
#include "pinocchio/algorithm/aba-derivatives.hpp"

using namespace std;
using namespace pinocchio;
Expand Down Expand Up @@ -276,10 +278,10 @@ int main(int argc, const char* argv[])
timer.tic();
SMOOTH(NBT_SO)
{
pinocchio::computeABADerivativesFaster(
pinocchio::computeABADerivatives(
model, data, qs[_smooth], qdots[_smooth], taus[_smooth], daba_dq, daba_dv, daba_dtau);

computeRNEADerivativesSO(model, data, qs[_smooth], qdots[_smooth], qddots[_smooth], dtau2_dq_ana, dtau2_dv_ana,
ComputeRNEASecondOrderDerivatives(model, data, qs[_smooth], qdots[_smooth], qddots[_smooth], dtau2_dq_ana, dtau2_dv_ana,
dtau2_dqv_ana, M_FO);

Minv = daba_dtau;
Expand Down
Binary file added benchmark/AD_mdof_v4_g
Binary file not shown.
Loading

0 comments on commit 2e36d21

Please sign in to comment.