about summary refs log tree commit diff
path: root/pkgs/by-name/pi
diff options
context:
space:
mode:
authorWeijia Wang <9713184+wegank@users.noreply.github.com>2024-09-19 22:42:41 +0200
committerGitHub <noreply@github.com>2024-09-19 22:42:41 +0200
commitbcee243290e88e83572c0cf78372b0f96c8f1026 (patch)
tree2a0baaea0981838ed00cc4741a69d3f1fe0dee56 /pkgs/by-name/pi
parentc3c413a5ea4795d0ca7ef7e97ac30423bfb347d6 (diff)
parent5108a107b244c127ea2d1097a8322ff06aebaab5 (diff)
aligator: init at 0.8.0 (#342751)
Diffstat (limited to 'pkgs/by-name/pi')
-rw-r--r--pkgs/by-name/pi/pinocchio/package.nix119
1 files changed, 119 insertions, 0 deletions
diff --git a/pkgs/by-name/pi/pinocchio/package.nix b/pkgs/by-name/pi/pinocchio/package.nix
new file mode 100644
index 0000000000000..e754078a38052
--- /dev/null
+++ b/pkgs/by-name/pi/pinocchio/package.nix
@@ -0,0 +1,119 @@
+{
+  boost,
+  casadi,
+  casadiSupport ? true,
+  cmake,
+  collisionSupport ? true,
+  console-bridge,
+  doxygen,
+  eigen,
+  example-robot-data,
+  fetchFromGitHub,
+  hpp-fcl,
+  jrl-cmakemodules,
+  lib,
+  pkg-config,
+  pythonSupport ? false,
+  python3Packages,
+  stdenv,
+  urdfdom,
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "pinocchio";
+  version = "3.2.0";
+
+  src = fetchFromGitHub {
+    owner = "stack-of-tasks";
+    repo = "pinocchio";
+    rev = "v${finalAttrs.version}";
+    hash = "sha256-8V+n1TwFojXKOVkGG8k9aXVadt2NBFlZKba93L+NRNU=";
+  };
+
+  outputs = [
+    "out"
+    "doc"
+  ];
+
+  # test failure, ref https://github.com/stack-of-tasks/pinocchio/issues/2277
+  prePatch = lib.optionalString (stdenv.isLinux && stdenv.isAarch64) ''
+    substituteInPlace unittest/algorithm/utils/CMakeLists.txt \
+      --replace-fail "add_pinocchio_unit_test(force)" ""
+  '';
+
+  postPatch = ''
+    # example-robot-data models are used in checks.
+    # Upstream provide them as git submodule, but we can use our own version instead.
+    test -d models/example-robot-data && rmdir models/example-robot-data
+    ln -s ${example-robot-data.src} models/example-robot-data
+
+    # allow package:// uri use in examples
+    export ROS_PACKAGE_PATH=${example-robot-data}/share
+
+    # silence matplotlib warning
+    export MPLCONFIGDIR=$(mktemp -d)
+  '';
+
+  # CMAKE_BUILD_TYPE defaults to Release in this package,
+  # which enable -O3, which break some tests
+  # ref. https://github.com/stack-of-tasks/pinocchio/issues/2304#issuecomment-2231018300
+  postConfigure = ''
+    substituteInPlace CMakeCache.txt --replace-fail '-O3' '-O2'
+  '';
+
+  strictDeps = true;
+
+  nativeBuildInputs =
+    [
+      cmake
+      doxygen
+      pkg-config
+    ]
+    ++ lib.optionals pythonSupport [
+      python3Packages.python
+      python3Packages.pythonImportsCheckHook
+    ];
+
+  propagatedBuildInputs =
+    [
+      console-bridge
+      jrl-cmakemodules
+      urdfdom
+    ]
+    ++ lib.optionals (!pythonSupport) [
+      boost
+      eigen
+    ]
+    ++ lib.optionals (!pythonSupport && collisionSupport) [ hpp-fcl ]
+    ++ lib.optionals pythonSupport [
+      python3Packages.boost
+      python3Packages.eigenpy
+    ]
+    ++ lib.optionals (pythonSupport && collisionSupport) [ python3Packages.hpp-fcl ]
+    ++ lib.optionals (!pythonSupport && casadiSupport) [ casadi ]
+    ++ lib.optionals (pythonSupport && casadiSupport) [ python3Packages.casadi ];
+
+  checkInputs = lib.optionals (pythonSupport && casadiSupport) [ python3Packages.matplotlib ];
+
+  cmakeFlags = [
+    (lib.cmakeBool "BUILD_PYTHON_INTERFACE" pythonSupport)
+    (lib.cmakeBool "BUILD_WITH_LIBPYTHON" pythonSupport)
+    (lib.cmakeBool "BUILD_WITH_CASADI_SUPPORT" casadiSupport)
+    (lib.cmakeBool "BUILD_WITH_COLLISION_SUPPORT" collisionSupport)
+    (lib.cmakeBool "INSTALL_DOCUMENTATION" true)
+  ];
+
+  doCheck = true;
+  pythonImportsCheck = [ "pinocchio" ];
+
+  meta = {
+    description = "Fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives";
+    homepage = "https://github.com/stack-of-tasks/pinocchio";
+    license = lib.licenses.bsd2;
+    maintainers = with lib.maintainers; [
+      nim65s
+      wegank
+    ];
+    platforms = lib.platforms.unix;
+  };
+})