From bea4e06c3615c55336005de18ea07a9c012129d3 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Wed, 21 May 2025 10:44:17 +0200 Subject: [PATCH 01/33] nix: add flake --- .gitignore | 2 ++ flake.lock | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 41 +++++++++++++++++++++++++++++++++++++++++ readme.md | 13 +++++++++++-- 4 files changed, 105 insertions(+), 2 deletions(-) create mode 100755 flake.lock create mode 100755 flake.nix diff --git a/.gitignore b/.gitignore index 03a32ce..6aabfa5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ *build* *.user +*.code-workspace +result diff --git a/flake.lock b/flake.lock new file mode 100755 index 0000000..b71377f --- /dev/null +++ b/flake.lock @@ -0,0 +1,51 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1747744144, + "narHash": "sha256-W7lqHp0qZiENCDwUZ5EX/lNhxjMdNapFnbErcbnP11Q=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2795c506fe8fb7b03c36ccb51f75b6df0ab2553f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "odri-masterboard-sdk": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1747816647, + "narHash": "sha256-G0le82G+wRJR+r73Z7bxFsAj/nC4z7V2DrHzh7mSNR4=", + "ref": "nix", + "rev": "06b9e86069d255465824d4db7b6708914ce9b7c2", + "revCount": 569, + "submodules": true, + "type": "git", + "url": "https://github.com/gwennlbh/master-board" + }, + "original": { + "ref": "nix", + "submodules": true, + "type": "git", + "url": "https://github.com/gwennlbh/master-board" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "odri-masterboard-sdk": "odri-masterboard-sdk" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100755 index 0000000..c72a200 --- /dev/null +++ b/flake.nix @@ -0,0 +1,41 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + odri-masterboard-sdk = { + # FIXME update after https://github.com/open-dynamic-robot-initiative/master-board/pull/173 + url = "git+https://github.com/gwennlbh/master-board?submodules=1&ref=nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + { nixpkgs, odri-masterboard-sdk, ... }: + let + pkgs = nixpkgs.legacyPackages.x86_64-linux; + sdk = odri-masterboard-sdk.packages.x86_64-linux.sdk; + in + { + packages.x86_64-linux.default = + pkgs.stdenv.mkDerivation rec { + pname = "odri-control"; + version = "1.0.1"; + + src = builtins.path { + name = pname; + path = ./.; + }; + + nativeBuildInputs = + [ sdk ] + ++ (with pkgs; [ + cmake + yaml-cpp + eigen + python312Packages.eigenpy + python312Packages.boost + python312 + ]); + }; + }; +} diff --git a/readme.md b/readme.md index 6435129..6a53551 100644 --- a/readme.md +++ b/readme.md @@ -7,7 +7,9 @@ Common interface for controlling robots build with the odri master board. ### Installation -#### Download the package: +#### Using treep & colcon + +##### Download the package: We use `treep` to download the required packages. Make sure your ssh key is unlocked. Then @@ -20,7 +22,7 @@ treep --clone master-board treep --clone odri_control_interface ``` -#### Build the package +##### Build the package We use [colcon](https://github.com/machines-in-motion/machines-in-motion.github.io/wiki/use_colcon) to build this package: @@ -28,6 +30,13 @@ to build this package: cd mkdir -p ~/devel/workspace colcon build ``` + +#### Using Nix + +``` +nix build .?submodules=1 +``` + ### Usage: #### Demos/Examples From d74325dfea1cb02443aaf7e464f525f24df8bc7f Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Wed, 21 May 2025 10:59:09 +0200 Subject: [PATCH 02/33] nix: update sdk package name reference see 974fe4d9271f1e519f374cd488aae3e8c94b9660 --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index c72a200..6c09e94 100755 --- a/flake.nix +++ b/flake.nix @@ -13,7 +13,7 @@ { nixpkgs, odri-masterboard-sdk, ... }: let pkgs = nixpkgs.legacyPackages.x86_64-linux; - sdk = odri-masterboard-sdk.packages.x86_64-linux.sdk; + sdk = odri-masterboard-sdk.packages.x86_64-linux.default; in { packages.x86_64-linux.default = From 7e4022afee4b54a6e2100d6de7c9b161590ad2b1 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Wed, 21 May 2025 15:33:12 +0200 Subject: [PATCH 03/33] nix: don't use submodules see https://github.com/open-dynamic-robot-initiative/master-board/pull/173#issuecomment-2897856798 --- flake.lock | 10 ++++------ flake.nix | 2 +- readme.md | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/flake.lock b/flake.lock index b71377f..8a237e7 100755 --- a/flake.lock +++ b/flake.lock @@ -23,18 +23,16 @@ ] }, "locked": { - "lastModified": 1747816647, - "narHash": "sha256-G0le82G+wRJR+r73Z7bxFsAj/nC4z7V2DrHzh7mSNR4=", + "lastModified": 1747834160, + "narHash": "sha256-kGuOVVdsljajM9oj3/GxJqH4kFGmDtBobbXr8UzV2MU=", "ref": "nix", - "rev": "06b9e86069d255465824d4db7b6708914ce9b7c2", - "revCount": 569, - "submodules": true, + "rev": "3eeae6ac8e1a336384c30648a969216f65103030", + "revCount": 575, "type": "git", "url": "https://github.com/gwennlbh/master-board" }, "original": { "ref": "nix", - "submodules": true, "type": "git", "url": "https://github.com/gwennlbh/master-board" } diff --git a/flake.nix b/flake.nix index 6c09e94..dbfc8d1 100755 --- a/flake.nix +++ b/flake.nix @@ -4,7 +4,7 @@ odri-masterboard-sdk = { # FIXME update after https://github.com/open-dynamic-robot-initiative/master-board/pull/173 - url = "git+https://github.com/gwennlbh/master-board?submodules=1&ref=nix"; + url = "git+https://github.com/gwennlbh/master-board?ref=nix"; inputs.nixpkgs.follows = "nixpkgs"; }; }; diff --git a/readme.md b/readme.md index 6a53551..713c0c1 100644 --- a/readme.md +++ b/readme.md @@ -34,7 +34,7 @@ colcon build #### Using Nix ``` -nix build .?submodules=1 +nix build ``` ### Usage: From 641e48300df30af1144aba9b1bdee39569331cfb Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Wed, 21 May 2025 16:06:13 +0200 Subject: [PATCH 04/33] nix: update after d5d6105f8db1770cd07fdde300c4c008e36de818 on master-board --- flake.lock | 9 +++++---- flake.nix | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 8a237e7..f7c92a3 100755 --- a/flake.lock +++ b/flake.lock @@ -23,16 +23,17 @@ ] }, "locked": { - "lastModified": 1747834160, - "narHash": "sha256-kGuOVVdsljajM9oj3/GxJqH4kFGmDtBobbXr8UzV2MU=", + "lastModified": 1747835945, + "narHash": "sha256-QZwTtRTJEsEBVWFHtAaZgTYrxGEMWzUNp3hCiHEttqU=", "ref": "nix", - "rev": "3eeae6ac8e1a336384c30648a969216f65103030", - "revCount": 575, + "rev": "d5d6105f8db1770cd07fdde300c4c008e36de818", + "revCount": 576, "type": "git", "url": "https://github.com/gwennlbh/master-board" }, "original": { "ref": "nix", + "rev": "d5d6105f8db1770cd07fdde300c4c008e36de818", "type": "git", "url": "https://github.com/gwennlbh/master-board" } diff --git a/flake.nix b/flake.nix index dbfc8d1..07f6426 100755 --- a/flake.nix +++ b/flake.nix @@ -4,7 +4,7 @@ odri-masterboard-sdk = { # FIXME update after https://github.com/open-dynamic-robot-initiative/master-board/pull/173 - url = "git+https://github.com/gwennlbh/master-board?ref=nix"; + url = "git+https://github.com/gwennlbh/master-board?ref=nix&rev=d5d6105f8db1770cd07fdde300c4c008e36de818"; inputs.nixpkgs.follows = "nixpkgs"; }; }; From 7c703ac2e75516628e723ba51562dca6d14d47b4 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Wed, 21 May 2025 16:07:25 +0200 Subject: [PATCH 05/33] ci: add nix build --- .github/workflows/nix.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 .github/workflows/nix.yml diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100755 index 0000000..5b5f0d3 --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,11 @@ +name: CI - Nix + +on: [push, pull_request] + +jobs: + CI: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v30 + - run: nix build From 22da2e3d3ac55e999573f8d8dc5b16d21b2d785b Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Wed, 21 May 2025 17:12:07 +0200 Subject: [PATCH 06/33] ci: enable logs for nix build --- .github/workflows/nix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 5b5f0d3..04c0c74 100755 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -8,4 +8,4 @@ jobs: steps: - uses: actions/checkout@v4 - uses: cachix/install-nix-action@v30 - - run: nix build + - run: nix build -L From 1ca239e4b6afeba2c6176e46d293e4bb15139aec Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Wed, 21 May 2025 17:23:11 +0200 Subject: [PATCH 07/33] nix: get package version dynamically see https://github.com/Gepetto/nix-lib/pull/1 --- flake.nix | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/flake.nix b/flake.nix index 07f6426..4991384 100755 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,7 @@ { inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + utils.url = "github:Gepetto/nix-lib"; odri-masterboard-sdk = { # FIXME update after https://github.com/open-dynamic-robot-initiative/master-board/pull/173 @@ -10,32 +11,37 @@ }; outputs = - { nixpkgs, odri-masterboard-sdk, ... }: + { + nixpkgs, + utils, + odri-masterboard-sdk, + ... + }: let pkgs = nixpkgs.legacyPackages.x86_64-linux; sdk = odri-masterboard-sdk.packages.x86_64-linux.default; + rosVersion = utils.lib.rosVersion pkgs; in { - packages.x86_64-linux.default = - pkgs.stdenv.mkDerivation rec { - pname = "odri-control"; - version = "1.0.1"; - - src = builtins.path { - name = pname; - path = ./.; - }; + packages.x86_64-linux.default = pkgs.stdenv.mkDerivation rec { + pname = "odri-control"; + version = rosVersion ./package.xml; - nativeBuildInputs = - [ sdk ] - ++ (with pkgs; [ - cmake - yaml-cpp - eigen - python312Packages.eigenpy - python312Packages.boost - python312 - ]); + src = builtins.path { + name = pname; + path = ./.; }; + + nativeBuildInputs = + [ sdk ] + ++ (with pkgs; [ + cmake + yaml-cpp + eigen + python312Packages.eigenpy + python312Packages.boost + python312 + ]); + }; }; } From 5587444cb39c070426607c64295b085f3dc5a93a Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Thu, 22 May 2025 10:58:48 +0200 Subject: [PATCH 08/33] nix: update flake.lock --- flake.lock | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/flake.lock b/flake.lock index f7c92a3..07b9916 100755 --- a/flake.lock +++ b/flake.lock @@ -41,7 +41,23 @@ "root": { "inputs": { "nixpkgs": "nixpkgs", - "odri-masterboard-sdk": "odri-masterboard-sdk" + "odri-masterboard-sdk": "odri-masterboard-sdk", + "utils": "utils" + } + }, + "utils": { + "locked": { + "lastModified": 1747841438, + "narHash": "sha256-+Qsp1GQZFqXUU+QgPpq+GfwyfDMnclxcMXdDDfHEOeM=", + "owner": "Gepetto", + "repo": "nix-lib", + "rev": "f48e2ef19e6aa2c87612b714b07507c4adaa71e2", + "type": "github" + }, + "original": { + "owner": "Gepetto", + "repo": "nix-lib", + "type": "github" } } }, From c556f6e0e50054ddf89c110ee68d9ed8b304ae7d Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Thu, 22 May 2025 12:33:33 +0200 Subject: [PATCH 09/33] ci: enforce flake.lock correctness --- .github/workflows/nix.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 04c0c74..a8eb525 100755 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -9,3 +9,5 @@ jobs: - uses: actions/checkout@v4 - uses: cachix/install-nix-action@v30 - run: nix build -L + - name: Check if there are changes + uses: NathanielHill/fail-if-changes@v1.1.1 From ba65ab1b96bb62c217f709add2a50df832f671ee Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Thu, 22 May 2025 13:50:14 +0200 Subject: [PATCH 10/33] nix: set yaml-cpp as propagated build input --- flake.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 4991384..a1ce462 100755 --- a/flake.nix +++ b/flake.nix @@ -36,12 +36,13 @@ [ sdk ] ++ (with pkgs; [ cmake - yaml-cpp eigen python312Packages.eigenpy python312Packages.boost python312 ]); + + propagatedBuildInputs = with pkgs; [ yaml-cpp ]; }; }; } From 16d040922b5c1f91e547ddd65699488972f05d3f Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Mon, 26 May 2025 10:34:39 +0200 Subject: [PATCH 11/33] nix: use gepetto/nix and flake template Signed-off-by: Gwenn Le Bihan --- flake.lock | 378 +++++++++++++++++++++++++++++++++++++++++++++++++---- flake.nix | 82 ++++++------ 2 files changed, 400 insertions(+), 60 deletions(-) diff --git a/flake.lock b/flake.lock index 07b9916..ea7cf1c 100755 --- a/flake.lock +++ b/flake.lock @@ -1,48 +1,382 @@ { "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1743550720, + "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c621e8422220273271f52058f618c94e405bb0f5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gepetto": { + "inputs": { + "flake-parts": "flake-parts", + "nix-ros-overlay": "nix-ros-overlay", + "nix-system-graphics": "nix-system-graphics", + "nixpkgs": [ + "gepetto", + "nix-ros-overlay", + "nixpkgs" + ], + "src-agimus-controller": "src-agimus-controller", + "src-agimus-msgs": "src-agimus-msgs", + "src-colmpc": "src-colmpc", + "src-example-parallel-robots": "src-example-parallel-robots", + "src-franka-description": "src-franka-description", + "src-gepetto-viewer": "src-gepetto-viewer", + "src-odri-control-interface": "src-odri-control-interface", + "src-odri-masterboard-sdk": "src-odri-masterboard-sdk", + "src-toolbox-parallel-robots": "src-toolbox-parallel-robots", + "system-manager": "system-manager", + "systems": [ + "gepetto", + "nix-ros-overlay", + "flake-utils", + "systems" + ], + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1748340967, + "narHash": "sha256-yaAB8XkuJjey19R6srZENeAT7zqj85NohCim0BIYIgk=", + "owner": "gwennlbh", + "repo": "gepetto-nix", + "rev": "633fd840e58f14b505c04b739134fdf9d53c3672", + "type": "github" + }, + "original": { + "owner": "gwennlbh", + "ref": "odri", + "repo": "gepetto-nix", + "type": "github" + } + }, + "nix-ros-overlay": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1745796487, + "narHash": "sha256-xvre4xiezhPhU794dpjcHusVLBIfA4jPg9Kq439x4yY=", + "owner": "lopsided98", + "repo": "nix-ros-overlay", + "rev": "4072d6ed51d9053d2cc85c0ec4f69884cc99f392", + "type": "github" + }, + "original": { + "owner": "lopsided98", + "ref": "develop", + "repo": "nix-ros-overlay", + "type": "github" + } + }, + "nix-system-graphics": { + "inputs": { + "nixpkgs": [ + "gepetto", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737457219, + "narHash": "sha256-nX9dxoATDCSQgWw/iv6BngXDJEyHVYYEvHEVQ7Ig3fI=", + "owner": "soupglasses", + "repo": "nix-system-graphics", + "rev": "9c875e0c56cf2eb272b9102a4f3e24e4e31629fd", + "type": "github" + }, + "original": { + "owner": "soupglasses", + "repo": "nix-system-graphics", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1747744144, - "narHash": "sha256-W7lqHp0qZiENCDwUZ5EX/lNhxjMdNapFnbErcbnP11Q=", - "owner": "NixOS", + "lastModified": 1744849697, + "narHash": "sha256-S9hqvanPSeRu6R4cw0OhvH1rJ+4/s9xIban9C4ocM/0=", + "owner": "lopsided98", "repo": "nixpkgs", - "rev": "2795c506fe8fb7b03c36ccb51f75b6df0ab2553f", + "rev": "6318f538166fef9f5118d8d78b9b43a04bb049e4", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixos-unstable", + "owner": "lopsided98", + "ref": "nix-ros", "repo": "nixpkgs", "type": "github" } }, - "odri-masterboard-sdk": { + "nixpkgs-lib": { + "locked": { + "lastModified": 1743296961, + "narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { "inputs": { + "flake-parts": [ + "gepetto", + "flake-parts" + ], + "gepetto": "gepetto", + "nix-ros-overlay": [ + "gepetto", + "nix-ros-overlay" + ], "nixpkgs": [ + "gepetto", + "nixpkgs" + ], + "systems": [ + "gepetto", + "systems" + ], + "treefmt-nix": [ + "gepetto", + "treefmt-nix" + ], + "utils": "utils" + } + }, + "src-agimus-controller": { + "flake": false, + "locked": { + "lastModified": 1747904554, + "narHash": "sha256-IHA+1KrtMKIiBw3NaO3VuMk6h/JIPgNpb7vvu2FGrjk=", + "owner": "agimus-project", + "repo": "agimus_controller", + "rev": "92797f93c2a80d4e362ac687f1311a149748bb36", + "type": "github" + }, + "original": { + "owner": "agimus-project", + "repo": "agimus_controller", + "type": "github" + } + }, + "src-agimus-msgs": { + "flake": false, + "locked": { + "lastModified": 1747656482, + "narHash": "sha256-O2DCQeasbrihIveOHmkcK0u4XnVcig33t8n+NFj/PvY=", + "owner": "agimus-project", + "repo": "agimus_msgs", + "rev": "d067e515c59665883b99c5a0028d6f746d0053ab", + "type": "github" + }, + "original": { + "owner": "agimus-project", + "repo": "agimus_msgs", + "type": "github" + } + }, + "src-colmpc": { + "flake": false, + "locked": { + "lastModified": 1747745791, + "narHash": "sha256-git7hITsR58YpgLV1A7TLUvLdhhOxKPHkzY+MBGAIZo=", + "owner": "agimus-project", + "repo": "colmpc", + "rev": "eeb4ae19b487760fe1421a87fe9423202ee78ead", + "type": "github" + }, + "original": { + "owner": "agimus-project", + "repo": "colmpc", + "type": "github" + } + }, + "src-example-parallel-robots": { + "flake": false, + "locked": { + "lastModified": 1747686798, + "narHash": "sha256-UXtJkwoKXYTw90moFr5E1sHHhc1czdHuq2r3wxDIBAE=", + "owner": "gepetto", + "repo": "example-parallel-robots", + "rev": "56fefa6437a4554c81c3b5db7efdc91bea292fdc", + "type": "github" + }, + "original": { + "owner": "gepetto", + "repo": "example-parallel-robots", + "type": "github" + } + }, + "src-franka-description": { + "flake": false, + "locked": { + "lastModified": 1744552174, + "narHash": "sha256-VRPygvJgiJipQ5yB1qmf3UEbwnu2Z916TaGTBDeSGjw=", + "owner": "agimus-project", + "repo": "franka_description", + "rev": "16a77d0c364d6f137cb6d28e7a5f357a5da2fabe", + "type": "github" + }, + "original": { + "owner": "agimus-project", + "repo": "franka_description", + "type": "github" + } + }, + "src-gepetto-viewer": { + "flake": false, + "locked": { + "lastModified": 1745404179, + "narHash": "sha256-mxWRXw0Lh3PpuX8u72ytWVWPPt2Qb8eNJdBf9twweUQ=", + "owner": "Gepetto", + "repo": "gepetto-viewer", + "rev": "c23c86ea979b7591c38100f8667d3c3398626273", + "type": "github" + }, + "original": { + "owner": "Gepetto", + "ref": "devel", + "repo": "gepetto-viewer", + "type": "github" + } + }, + "src-odri-control-interface": { + "flake": false, + "locked": { + "lastModified": 1720196841, + "narHash": "sha256-sUMjSTXf7Re32Zle40vOH6dUrqhaYiGIg3LMIbHuy38=", + "owner": "open-dynamic-robot-initiative", + "repo": "odri_control_interface", + "rev": "24e5f86c92a519f303ad69e78728d6272d8a1c27", + "type": "github" + }, + "original": { + "owner": "open-dynamic-robot-initiative", + "repo": "odri_control_interface", + "type": "github" + } + }, + "src-odri-masterboard-sdk": { + "flake": false, + "locked": { + "lastModified": 1747757934, + "narHash": "sha256-Aace/p6K7r1HWav6b3FH0nUpf1vZxYROCs3P3qvucDo=", + "owner": "open-dynamic-robot-initiative", + "repo": "master-board", + "rev": "9388c843e569d5bd3cd836f442ddfef43c8a7528", + "type": "github" + }, + "original": { + "owner": "open-dynamic-robot-initiative", + "repo": "master-board", + "type": "github" + } + }, + "src-toolbox-parallel-robots": { + "flake": false, + "locked": { + "lastModified": 1747686858, + "narHash": "sha256-uX8U/plHRs2eQNRDlm6KU5EgHrIj33o7dO7cA6EM/Ek=", + "owner": "gepetto", + "repo": "toolbox-parallel-robots", + "rev": "f123c491d15cadad6133af353c50560fce2e678b", + "type": "github" + }, + "original": { + "owner": "gepetto", + "repo": "toolbox-parallel-robots", + "type": "github" + } + }, + "system-manager": { + "inputs": { + "nixpkgs": [ + "gepetto", "nixpkgs" ] }, "locked": { - "lastModified": 1747835945, - "narHash": "sha256-QZwTtRTJEsEBVWFHtAaZgTYrxGEMWzUNp3hCiHEttqU=", - "ref": "nix", - "rev": "d5d6105f8db1770cd07fdde300c4c008e36de818", - "revCount": 576, - "type": "git", - "url": "https://github.com/gwennlbh/master-board" + "lastModified": 1747903970, + "narHash": "sha256-PFpAdjeBLpoY7v1v0GUeFuBWhEOiA187l0b2lmg117A=", + "owner": "numtide", + "repo": "system-manager", + "rev": "94f1c8d9c562e96358dddddb8e276ba8ac16c9ae", + "type": "github" }, "original": { - "ref": "nix", - "rev": "d5d6105f8db1770cd07fdde300c4c008e36de818", - "type": "git", - "url": "https://github.com/gwennlbh/master-board" + "owner": "numtide", + "repo": "system-manager", + "type": "github" } }, - "root": { + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { "inputs": { - "nixpkgs": "nixpkgs", - "odri-masterboard-sdk": "odri-masterboard-sdk", - "utils": "utils" + "nixpkgs": [ + "gepetto", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1747912973, + "narHash": "sha256-XgxghfND8TDypxsMTPU2GQdtBEsHTEc3qWE6RVEk8O0=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "020cb423808365fa3f10ff4cb8c0a25df35065a3", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" } }, "utils": { diff --git a/flake.nix b/flake.nix index a1ce462..f9d954c 100755 --- a/flake.nix +++ b/flake.nix @@ -1,48 +1,54 @@ { + description = "odri-control-interface"; + inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + # TODO: drop `/module` after https://github.com/Gepetto/nix/pull/54 + gepetto.url = "github:gwennlbh/gepetto-nix/odri"; + flake-parts.follows = "gepetto/flake-parts"; + nixpkgs.follows = "gepetto/nixpkgs"; + nix-ros-overlay.follows = "gepetto/nix-ros-overlay"; + systems.follows = "gepetto/systems"; + treefmt-nix.follows = "gepetto/treefmt-nix"; utils.url = "github:Gepetto/nix-lib"; - - odri-masterboard-sdk = { - # FIXME update after https://github.com/open-dynamic-robot-initiative/master-board/pull/173 - url = "git+https://github.com/gwennlbh/master-board?ref=nix&rev=d5d6105f8db1770cd07fdde300c4c008e36de818"; - inputs.nixpkgs.follows = "nixpkgs"; - }; }; outputs = - { - nixpkgs, - utils, - odri-masterboard-sdk, - ... - }: - let - pkgs = nixpkgs.legacyPackages.x86_64-linux; - sdk = odri-masterboard-sdk.packages.x86_64-linux.default; - rosVersion = utils.lib.rosVersion pkgs; - in - { - packages.x86_64-linux.default = pkgs.stdenv.mkDerivation rec { - pname = "odri-control"; - version = rosVersion ./package.xml; + inputs: + inputs.flake-parts.lib.mkFlake { inherit inputs; } { + systems = import inputs.systems; + imports = [ inputs.gepetto.flakeModule ]; + perSystem = + { + lib, + pkgs, + self', + ... + }: + { + packages = { + default = self'.packages.odri-control-interface; + odri-control-interface = pkgs.odri-control-interface.overrideAttrs { + version = inputs.utils.lib.rosVersion pkgs ./package.xml; + src = lib.fileset.toSource { + root = ./.; + fileset = lib.fileset.unions [ + ./demos + ./include + ./src + ./srcpy + ./CMakeLists.txt + ./package.xml + ]; + }; + }; + }; - src = builtins.path { - name = pname; - path = ./.; + apps = { + testbench = { + type = "app"; + program = "${self'.packages.odri-control-interface}/bin/odri_control_interface_demo_testbench"; + }; + }; }; - - nativeBuildInputs = - [ sdk ] - ++ (with pkgs; [ - cmake - eigen - python312Packages.eigenpy - python312Packages.boost - python312 - ]); - - propagatedBuildInputs = with pkgs; [ yaml-cpp ]; - }; }; } From c026c2bf5ae273219aadd8dd040497262f50bd43 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Tue, 27 May 2025 14:46:34 +0200 Subject: [PATCH 12/33] factor out paths to demo config files Signed-off-by: Gwenn Le Bihan --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fcf8772..05e8846 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,12 +146,13 @@ endif(BUILD_PYTHON_INTERFACE) macro(create_demo source) set(demo_name ${PROJECT_NAME}_${source}) + set(DEMO_ROOT "${PROJECT_SOURCE_DIR}/demos") add_executable(${demo_name} demos/${source}.cpp) target_link_libraries(${demo_name} ${PROJECT_NAME}) target_compile_definitions( ${demo_name} - PUBLIC CONFIG_SOLO12_YAML="${PROJECT_SOURCE_DIR}/demos/config_solo12.yaml" - PUBLIC CONFIG_TESTBENCH_YAML="${PROJECT_SOURCE_DIR}/demos/config_testbench.yaml") + PUBLIC CONFIG_SOLO12_YAML="${DEMO_ROOT}/config_solo12.yaml" + PUBLIC CONFIG_TESTBENCH_YAML="${DEMO_ROOT}/config_testbench.yaml") install(TARGETS ${demo_name} DESTINATION bin) endmacro(create_demo source) From 53f94a01ad5cbba2131cc3ed3520d37b589d26c9 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Tue, 27 May 2025 17:13:13 +0200 Subject: [PATCH 13/33] bake demo configs into binary Signed-off-by: Gwenn Le Bihan --- CMakeLists.txt | 8 +++-- demos/demo_testbench.cpp | 2 +- include/odri_control_interface/utils.hpp | 1 + src/utils.cpp | 38 ++++++++++++++++++++---- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05e8846..663355f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,12 +147,16 @@ macro(create_demo source) set(demo_name ${PROJECT_NAME}_${source}) set(DEMO_ROOT "${PROJECT_SOURCE_DIR}/demos") + file(READ "${DEMO_ROOT}/config_solo12.yaml" DEMO_CONFIG_SOLO12) + file(READ "${DEMO_ROOT}/config_testbench.yaml" DEMO_CONFIG_TESTBENCH) + message(STATUS "Demo config for solo12: ${DEMO_CONFIG_SOLO12}") + message(STATUS "Demo config for testbench: ${DEMO_CONFIG_TESTBENCH}") add_executable(${demo_name} demos/${source}.cpp) target_link_libraries(${demo_name} ${PROJECT_NAME}) target_compile_definitions( ${demo_name} - PUBLIC CONFIG_SOLO12_YAML="${DEMO_ROOT}/config_solo12.yaml" - PUBLIC CONFIG_TESTBENCH_YAML="${DEMO_ROOT}/config_testbench.yaml") + PUBLIC CONFIG_SOLO12_YAML="${DEMO_CONFIG_SOLO12}" + PUBLIC CONFIG_TESTBENCH_YAML="${DEMO_CONFIG_TESTBENCH}") install(TARGETS ${demo_name} DESTINATION bin) endmacro(create_demo source) diff --git a/demos/demo_testbench.cpp b/demos/demo_testbench.cpp index 09f3c7c..180387b 100644 --- a/demos/demo_testbench.cpp +++ b/demos/demo_testbench.cpp @@ -15,7 +15,7 @@ int main() nice(-20); // Give the process a high priority. // Define the robot from a yaml file. - auto robot = RobotFromYamlFile(CONFIG_TESTBENCH_YAML); + auto robot = RobotFromYamlString(CONFIG_TESTBENCH_YAML, "" ); // Store initial position data. Vector2d des_pos(3.1415 * 0.5, - 3.1415 * 0.5); diff --git a/include/odri_control_interface/utils.hpp b/include/odri_control_interface/utils.hpp index 1bf4622..df5c7d5 100644 --- a/include/odri_control_interface/utils.hpp +++ b/include/odri_control_interface/utils.hpp @@ -19,6 +19,7 @@ namespace odri_control_interface std::shared_ptr RobotFromYamlFile(const std::string& if_name, const std::string& file_path); std::shared_ptr RobotFromYamlFile(const std::string& file_path); +std::shared_ptr RobotFromYamlString(const std::string& contents, const std::string& file_path); std::shared_ptr JointCalibratorFromYamlFile( const std::string& file_path, std::shared_ptr joints); std::shared_ptr CreateMasterBoardInterface( diff --git a/src/utils.cpp b/src/utils.cpp index 1e407cb..ef38f47 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -252,12 +252,9 @@ std::shared_ptr JointCalibratorFromYaml( joint_calibrator["dt"].as()); } -std::shared_ptr RobotFromYamlFile(const std::string& if_name, - const std::string& file_path) -{ - assert_file_exists(file_path); - YAML::Node param = YAML::LoadFile(file_path); - +std::shared_ptr RobotFromYamlNode(const YAML::Node& param, + const std::string& if_name, + const std::string& file_path) { // Parse the robot part. assert_yaml_parsing(param, file_path, "robot"); const YAML::Node& robot_node = param["robot"]; @@ -284,6 +281,34 @@ std::shared_ptr RobotFromYamlFile(const std::string& if_name, return std::make_shared(robot_if, joints, imu, calibrator); } +std::shared_ptr RobotFromYamlNode( + const YAML::Node& param, const std::string& file_path) { + + // Get the robot interface name. + assert_yaml_parsing(param, file_path, "robot"); + assert_yaml_parsing(param["robot"], "robot", "interface"); + std::string if_name = param["robot"]["interface"].as(); + + return RobotFromYamlNode(param, if_name, file_path); +} + +std::shared_ptr RobotFromYamlFile(const std::string& if_name, + const std::string& file_path) +{ + assert_file_exists(file_path); + YAML::Node param = YAML::LoadFile(file_path); + return RobotFromYamlNode(param, if_name, file_path); +} + +std::shared_ptr RobotFromYamlString( + const std::string& file_contents, + const std::string& file_path +) { + YAML::Node param = YAML::Load(file_contents); + return RobotFromYamlNode(param, file_path); +} + + std::shared_ptr RobotFromYamlFile(const std::string& file_path) { assert_file_exists(file_path); @@ -297,6 +322,7 @@ std::shared_ptr RobotFromYamlFile(const std::string& file_path) return RobotFromYamlFile(if_name, file_path); } + std::shared_ptr JointCalibratorFromYamlFile( const std::string& file_path, std::shared_ptr joints) { From 214ab9c2d167933160dca106027b9e9b8952cd5f Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Tue, 27 May 2025 17:13:16 +0200 Subject: [PATCH 14/33] Revert "bake demo configs into binary" This reverts commit 6706d9f100343dceadabef055142ebfc4e993ad3. Turns out that having #s in the file contents prevent -D from working... thanks C++ > WARNING: Preprocessor definitions containing '#' may not be passed on the compiler command line because many compilers do not support it. > odri-control-interface> CMake is dropping a preprocessor definition: CONFIG_TESTBENCH_YAML="robot: > odri-control-interface> interface: enp2s0 so we'll keep the files as is i guess. --- CMakeLists.txt | 8 ++--- demos/demo_testbench.cpp | 2 +- include/odri_control_interface/utils.hpp | 1 - src/utils.cpp | 38 ++++-------------------- 4 files changed, 9 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 663355f..05e8846 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,16 +147,12 @@ macro(create_demo source) set(demo_name ${PROJECT_NAME}_${source}) set(DEMO_ROOT "${PROJECT_SOURCE_DIR}/demos") - file(READ "${DEMO_ROOT}/config_solo12.yaml" DEMO_CONFIG_SOLO12) - file(READ "${DEMO_ROOT}/config_testbench.yaml" DEMO_CONFIG_TESTBENCH) - message(STATUS "Demo config for solo12: ${DEMO_CONFIG_SOLO12}") - message(STATUS "Demo config for testbench: ${DEMO_CONFIG_TESTBENCH}") add_executable(${demo_name} demos/${source}.cpp) target_link_libraries(${demo_name} ${PROJECT_NAME}) target_compile_definitions( ${demo_name} - PUBLIC CONFIG_SOLO12_YAML="${DEMO_CONFIG_SOLO12}" - PUBLIC CONFIG_TESTBENCH_YAML="${DEMO_CONFIG_TESTBENCH}") + PUBLIC CONFIG_SOLO12_YAML="${DEMO_ROOT}/config_solo12.yaml" + PUBLIC CONFIG_TESTBENCH_YAML="${DEMO_ROOT}/config_testbench.yaml") install(TARGETS ${demo_name} DESTINATION bin) endmacro(create_demo source) diff --git a/demos/demo_testbench.cpp b/demos/demo_testbench.cpp index 180387b..09f3c7c 100644 --- a/demos/demo_testbench.cpp +++ b/demos/demo_testbench.cpp @@ -15,7 +15,7 @@ int main() nice(-20); // Give the process a high priority. // Define the robot from a yaml file. - auto robot = RobotFromYamlString(CONFIG_TESTBENCH_YAML, "" ); + auto robot = RobotFromYamlFile(CONFIG_TESTBENCH_YAML); // Store initial position data. Vector2d des_pos(3.1415 * 0.5, - 3.1415 * 0.5); diff --git a/include/odri_control_interface/utils.hpp b/include/odri_control_interface/utils.hpp index df5c7d5..1bf4622 100644 --- a/include/odri_control_interface/utils.hpp +++ b/include/odri_control_interface/utils.hpp @@ -19,7 +19,6 @@ namespace odri_control_interface std::shared_ptr RobotFromYamlFile(const std::string& if_name, const std::string& file_path); std::shared_ptr RobotFromYamlFile(const std::string& file_path); -std::shared_ptr RobotFromYamlString(const std::string& contents, const std::string& file_path); std::shared_ptr JointCalibratorFromYamlFile( const std::string& file_path, std::shared_ptr joints); std::shared_ptr CreateMasterBoardInterface( diff --git a/src/utils.cpp b/src/utils.cpp index ef38f47..1e407cb 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -252,9 +252,12 @@ std::shared_ptr JointCalibratorFromYaml( joint_calibrator["dt"].as()); } -std::shared_ptr RobotFromYamlNode(const YAML::Node& param, - const std::string& if_name, - const std::string& file_path) { +std::shared_ptr RobotFromYamlFile(const std::string& if_name, + const std::string& file_path) +{ + assert_file_exists(file_path); + YAML::Node param = YAML::LoadFile(file_path); + // Parse the robot part. assert_yaml_parsing(param, file_path, "robot"); const YAML::Node& robot_node = param["robot"]; @@ -281,34 +284,6 @@ std::shared_ptr RobotFromYamlNode(const YAML::Node& param, return std::make_shared(robot_if, joints, imu, calibrator); } -std::shared_ptr RobotFromYamlNode( - const YAML::Node& param, const std::string& file_path) { - - // Get the robot interface name. - assert_yaml_parsing(param, file_path, "robot"); - assert_yaml_parsing(param["robot"], "robot", "interface"); - std::string if_name = param["robot"]["interface"].as(); - - return RobotFromYamlNode(param, if_name, file_path); -} - -std::shared_ptr RobotFromYamlFile(const std::string& if_name, - const std::string& file_path) -{ - assert_file_exists(file_path); - YAML::Node param = YAML::LoadFile(file_path); - return RobotFromYamlNode(param, if_name, file_path); -} - -std::shared_ptr RobotFromYamlString( - const std::string& file_contents, - const std::string& file_path -) { - YAML::Node param = YAML::Load(file_contents); - return RobotFromYamlNode(param, file_path); -} - - std::shared_ptr RobotFromYamlFile(const std::string& file_path) { assert_file_exists(file_path); @@ -322,7 +297,6 @@ std::shared_ptr RobotFromYamlFile(const std::string& file_path) return RobotFromYamlFile(if_name, file_path); } - std::shared_ptr JointCalibratorFromYamlFile( const std::string& file_path, std::shared_ptr joints) { From af04179a89b1bdd742c70c9810650e6a4e30b454 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Wed, 28 May 2025 11:21:31 +0200 Subject: [PATCH 15/33] git: gitignore a bunch of things Signed-off-by: Gwenn Le Bihan --- .gitignore | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 6aabfa5..0df71c3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,12 @@ *.user *.code-workspace result +.vscode/c_cpp_properties.json +CMakeFiles +include/odri/control/interface/*.hh +CMakeCache.txt +CMakeDoxyfile.in +CMakeDoxygenDefaults.cmake +DartConfiguration.tcl +config.h +config.log From 1089c8aec3db17892c0c4dba0c186b0efbdefaac Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Wed, 28 May 2025 11:21:54 +0200 Subject: [PATCH 16/33] nix: update flake lock Signed-off-by: Gwenn Le Bihan --- flake.lock | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index ea7cf1c..4b5942c 100755 --- a/flake.lock +++ b/flake.lock @@ -65,11 +65,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1748340967, - "narHash": "sha256-yaAB8XkuJjey19R6srZENeAT7zqj85NohCim0BIYIgk=", + "lastModified": 1748432718, + "narHash": "sha256-1JDGv9uEda9hfdtxkAOYnZFwcWmgml+Dxj8Orx3etMA=", "owner": "gwennlbh", "repo": "gepetto-nix", - "rev": "633fd840e58f14b505c04b739134fdf9d53c3672", + "rev": "946ecdbc7a8a87e028cfdb344ec472157317360a", "type": "github" }, "original": { @@ -212,11 +212,11 @@ "src-colmpc": { "flake": false, "locked": { - "lastModified": 1747745791, - "narHash": "sha256-git7hITsR58YpgLV1A7TLUvLdhhOxKPHkzY+MBGAIZo=", + "lastModified": 1748282597, + "narHash": "sha256-m15hIbykq4T27TCbWhlzv6MOvOMcEUoP7J6COaGIEwE=", "owner": "agimus-project", "repo": "colmpc", - "rev": "eeb4ae19b487760fe1421a87fe9423202ee78ead", + "rev": "17c82fa0d6db53494da9f9e6af4266c342715dbf", "type": "github" }, "original": { @@ -277,15 +277,16 @@ "src-odri-control-interface": { "flake": false, "locked": { - "lastModified": 1720196841, - "narHash": "sha256-sUMjSTXf7Re32Zle40vOH6dUrqhaYiGIg3LMIbHuy38=", - "owner": "open-dynamic-robot-initiative", + "lastModified": 1748350018, + "narHash": "sha256-I/+0grgW5FyaiuTaw1hNPKuyW/87idFTM+y9fXyJypg=", + "owner": "gwennlbh", "repo": "odri_control_interface", - "rev": "24e5f86c92a519f303ad69e78728d6272d8a1c27", + "rev": "67604595c7859f920dd89ae5e647f70e53b6190f", "type": "github" }, "original": { - "owner": "open-dynamic-robot-initiative", + "owner": "gwennlbh", + "ref": "nix", "repo": "odri_control_interface", "type": "github" } @@ -330,11 +331,11 @@ ] }, "locked": { - "lastModified": 1747903970, - "narHash": "sha256-PFpAdjeBLpoY7v1v0GUeFuBWhEOiA187l0b2lmg117A=", + "lastModified": 1748252092, + "narHash": "sha256-6nL55wvV7SthEXaXDiQo8xxkxQLAVcNBU21YJ7GJLm8=", "owner": "numtide", "repo": "system-manager", - "rev": "94f1c8d9c562e96358dddddb8e276ba8ac16c9ae", + "rev": "c6850451ef769fd03d0ad5474f928b916aa23775", "type": "github" }, "original": { @@ -366,11 +367,11 @@ ] }, "locked": { - "lastModified": 1747912973, - "narHash": "sha256-XgxghfND8TDypxsMTPU2GQdtBEsHTEc3qWE6RVEk8O0=", + "lastModified": 1748243702, + "narHash": "sha256-9YzfeN8CB6SzNPyPm2XjRRqSixDopTapaRsnTpXUEY8=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "020cb423808365fa3f10ff4cb8c0a25df35065a3", + "rev": "1f3f7b784643d488ba4bf315638b2b0a4c5fb007", "type": "github" }, "original": { @@ -381,11 +382,11 @@ }, "utils": { "locked": { - "lastModified": 1747841438, - "narHash": "sha256-+Qsp1GQZFqXUU+QgPpq+GfwyfDMnclxcMXdDDfHEOeM=", + "lastModified": 1748363541, + "narHash": "sha256-bDV63Oo+CQqB9joTf+G8hbxPgLjHBzCcmkiOT360/XQ=", "owner": "Gepetto", "repo": "nix-lib", - "rev": "f48e2ef19e6aa2c87612b714b07507c4adaa71e2", + "rev": "eacf43e7f58944507d1be011c25af268aa9048e9", "type": "github" }, "original": { From 62b8661d2d2815471926ca3df75473f2da195936 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Wed, 28 May 2025 13:48:19 +0200 Subject: [PATCH 17/33] nix: add solo12 app to flake Signed-off-by: Gwenn Le Bihan --- flake.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flake.nix b/flake.nix index f9d954c..13215d5 100755 --- a/flake.nix +++ b/flake.nix @@ -48,6 +48,10 @@ type = "app"; program = "${self'.packages.odri-control-interface}/bin/odri_control_interface_demo_testbench"; }; + solo12 = { + type = "app"; + program = "${self'.packages.odri-control-interface}/bin/odri_control_interface_demo_solo12"; + }; }; }; }; From 61f89f573c367d7eb03167ebc009d0fb5218c428 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Wed, 28 May 2025 13:50:59 +0200 Subject: [PATCH 18/33] nix: fmt Signed-off-by: Gwenn Le Bihan --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 13215d5..4c38bbb 100755 --- a/flake.nix +++ b/flake.nix @@ -33,7 +33,7 @@ root = ./.; fileset = lib.fileset.unions [ ./demos - ./include + ./include ./src ./srcpy ./CMakeLists.txt From 307c7e64722b1e6616749f95fc887e22283d1518 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Wed, 28 May 2025 13:51:07 +0200 Subject: [PATCH 19/33] ci: run nix flake check instead of nix build Signed-off-by: Gwenn Le Bihan --- .github/workflows/nix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index a8eb525..571fb67 100755 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -8,6 +8,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: cachix/install-nix-action@v30 - - run: nix build -L + - run: nix flake check -L - name: Check if there are changes uses: NathanielHill/fail-if-changes@v1.1.1 From 1a3dde81985659fcdeaf338db5161f846fa1caff Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Wed, 28 May 2025 15:58:07 +0200 Subject: [PATCH 20/33] fix demo config paths handling Signed-off-by: Gwenn Le Bihan --- CMakeLists.txt | 4 +++- flake.lock | 35 ++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05e8846..66c1e79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,7 +146,9 @@ endif(BUILD_PYTHON_INTERFACE) macro(create_demo source) set(demo_name ${PROJECT_NAME}_${source}) - set(DEMO_ROOT "${PROJECT_SOURCE_DIR}/demos") + string(REPLACE "demo_" "" device "${source}") + set(DEMO_ROOT "${CMAKE_INSTALL_PREFIX}/demos") + file(COPY "${PROJECT_SOURCE_DIR}/demos/config_${device}.yaml" DESTINATION "${DEMO_ROOT}") add_executable(${demo_name} demos/${source}.cpp) target_link_libraries(${demo_name} ${PROJECT_NAME}) target_compile_definitions( diff --git a/flake.lock b/flake.lock index 4b5942c..0f17d2f 100755 --- a/flake.lock +++ b/flake.lock @@ -65,11 +65,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1748432718, - "narHash": "sha256-1JDGv9uEda9hfdtxkAOYnZFwcWmgml+Dxj8Orx3etMA=", + "lastModified": 1748440781, + "narHash": "sha256-+1oXBqVyFPkQ8qp9Bpj/4m74lARDLUYnZeG9c8wwnZw=", "owner": "gwennlbh", "repo": "gepetto-nix", - "rev": "946ecdbc7a8a87e028cfdb344ec472157317360a", + "rev": "92f2d8e713d3881cf1e6f8e9470cf6104ac864a0", "type": "github" }, "original": { @@ -180,11 +180,11 @@ "src-agimus-controller": { "flake": false, "locked": { - "lastModified": 1747904554, - "narHash": "sha256-IHA+1KrtMKIiBw3NaO3VuMk6h/JIPgNpb7vvu2FGrjk=", + "lastModified": 1748356703, + "narHash": "sha256-6zfD0802BtdXI4koWp/ZI8WOI9LXXmMBTPPIU1+MjpA=", "owner": "agimus-project", "repo": "agimus_controller", - "rev": "92797f93c2a80d4e362ac687f1311a149748bb36", + "rev": "5e9e2c225c2937d9b72feaf7aae51b4833b27488", "type": "github" }, "original": { @@ -212,11 +212,11 @@ "src-colmpc": { "flake": false, "locked": { - "lastModified": 1748282597, - "narHash": "sha256-m15hIbykq4T27TCbWhlzv6MOvOMcEUoP7J6COaGIEwE=", + "lastModified": 1748425695, + "narHash": "sha256-Eku/uorPx/ToApoIIGD9LgBT6vrFetm2ZFFmE/iUa+I=", "owner": "agimus-project", "repo": "colmpc", - "rev": "17c82fa0d6db53494da9f9e6af4266c342715dbf", + "rev": "b26daa44ba0069bf5849d8ac716d3dd5090fd482", "type": "github" }, "original": { @@ -277,11 +277,11 @@ "src-odri-control-interface": { "flake": false, "locked": { - "lastModified": 1748350018, - "narHash": "sha256-I/+0grgW5FyaiuTaw1hNPKuyW/87idFTM+y9fXyJypg=", + "lastModified": 1748433067, + "narHash": "sha256-gAwwUU2Upzc3KCRu0JOacw6cv9yMwOKJ/QNxMtxAZQg=", "owner": "gwennlbh", "repo": "odri_control_interface", - "rev": "67604595c7859f920dd89ae5e647f70e53b6190f", + "rev": "4f4cc7350bb43d17023fdb405d953c942d0e4c47", "type": "github" }, "original": { @@ -294,15 +294,16 @@ "src-odri-masterboard-sdk": { "flake": false, "locked": { - "lastModified": 1747757934, - "narHash": "sha256-Aace/p6K7r1HWav6b3FH0nUpf1vZxYROCs3P3qvucDo=", - "owner": "open-dynamic-robot-initiative", + "lastModified": 1748437437, + "narHash": "sha256-eWw3gTLq3rWtMzVLffwKODAP3XGO4GwZF7CLzAr1umA=", + "owner": "gwennlbh", "repo": "master-board", - "rev": "9388c843e569d5bd3cd836f442ddfef43c8a7528", + "rev": "4521b8627f032fa606ade0024c24b65098e8e7e0", "type": "github" }, "original": { - "owner": "open-dynamic-robot-initiative", + "owner": "gwennlbh", + "ref": "nix", "repo": "master-board", "type": "github" } From 0e800d18d473b00395ca805e021371d822d9ad82 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Mon, 2 Jun 2025 14:39:56 +0200 Subject: [PATCH 21/33] nix: add a devshell to run demos/ .py scripts Signed-off-by: Gwenn Le Bihan --- flake.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/flake.nix b/flake.nix index 4c38bbb..88d37fc 100755 --- a/flake.nix +++ b/flake.nix @@ -53,6 +53,19 @@ program = "${self'.packages.odri-control-interface}/bin/odri_control_interface_demo_solo12"; }; }; + devShells.default = pkgs.mkShell { + buildInputs = [ + self'.packages.odri-control-interface + pkgs.odri-masterboard-sdk + pkgs.python3Packages.python + pkgs.python3Packages.numpy + ]; + shellHook = '' + controlSitePackages=`echo ${self'.packages.odri-control-interface}/lib/python*/site-packages | head -n 1` + masterboardSitePackages=`echo ${pkgs.odri-masterboard-sdk}/lib/python*/site-packages | head -n 1` + export PYTHONPATH="$controlSitePackages:$masterboardSitePackages:$PYTHONPATH" + ''; + }; }; }; } From 8a90dca333b5178187c024e48dab98c9328deb95 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Tue, 3 Jun 2025 15:34:15 +0200 Subject: [PATCH 22/33] nix: reference gepetto/nix instead of my fork Signed-off-by: Gwenn Le Bihan --- flake.lock | 52 ++++++++++++++++++++++++++-------------------------- flake.nix | 4 ++-- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/flake.lock b/flake.lock index 0f17d2f..9507242 100755 --- a/flake.lock +++ b/flake.lock @@ -65,17 +65,17 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1748440781, - "narHash": "sha256-+1oXBqVyFPkQ8qp9Bpj/4m74lARDLUYnZeG9c8wwnZw=", - "owner": "gwennlbh", - "repo": "gepetto-nix", - "rev": "92f2d8e713d3881cf1e6f8e9470cf6104ac864a0", + "lastModified": 1748959317, + "narHash": "sha256-rNdZlsmzyLACqo4UAi3v+64mq8p7XNjUaovaCu6yIsY=", + "owner": "gepetto", + "repo": "nix", + "rev": "90cc507c64489d197d0c7c862617c0766cfd7fb2", "type": "github" }, "original": { - "owner": "gwennlbh", - "ref": "odri", - "repo": "gepetto-nix", + "owner": "gepetto", + "ref": "module", + "repo": "nix", "type": "github" } }, @@ -180,11 +180,11 @@ "src-agimus-controller": { "flake": false, "locked": { - "lastModified": 1748356703, - "narHash": "sha256-6zfD0802BtdXI4koWp/ZI8WOI9LXXmMBTPPIU1+MjpA=", + "lastModified": 1747904554, + "narHash": "sha256-IHA+1KrtMKIiBw3NaO3VuMk6h/JIPgNpb7vvu2FGrjk=", "owner": "agimus-project", "repo": "agimus_controller", - "rev": "5e9e2c225c2937d9b72feaf7aae51b4833b27488", + "rev": "92797f93c2a80d4e362ac687f1311a149748bb36", "type": "github" }, "original": { @@ -212,11 +212,11 @@ "src-colmpc": { "flake": false, "locked": { - "lastModified": 1748425695, - "narHash": "sha256-Eku/uorPx/ToApoIIGD9LgBT6vrFetm2ZFFmE/iUa+I=", + "lastModified": 1747745791, + "narHash": "sha256-git7hITsR58YpgLV1A7TLUvLdhhOxKPHkzY+MBGAIZo=", "owner": "agimus-project", "repo": "colmpc", - "rev": "b26daa44ba0069bf5849d8ac716d3dd5090fd482", + "rev": "eeb4ae19b487760fe1421a87fe9423202ee78ead", "type": "github" }, "original": { @@ -277,11 +277,11 @@ "src-odri-control-interface": { "flake": false, "locked": { - "lastModified": 1748433067, - "narHash": "sha256-gAwwUU2Upzc3KCRu0JOacw6cv9yMwOKJ/QNxMtxAZQg=", + "lastModified": 1748957655, + "narHash": "sha256-YhZ8yzgUiN/ZeU/j1cGUEnKycjSD9WOJjMbkqmr+cag=", "owner": "gwennlbh", "repo": "odri_control_interface", - "rev": "4f4cc7350bb43d17023fdb405d953c942d0e4c47", + "rev": "6cfbb67f0d2764d84bdeb91dcf7698bf67799e03", "type": "github" }, "original": { @@ -294,11 +294,11 @@ "src-odri-masterboard-sdk": { "flake": false, "locked": { - "lastModified": 1748437437, - "narHash": "sha256-eWw3gTLq3rWtMzVLffwKODAP3XGO4GwZF7CLzAr1umA=", + "lastModified": 1748957693, + "narHash": "sha256-Z1u12eXOw7mabincVOTmmlVCNPbQubuVMyqQ+INSqww=", "owner": "gwennlbh", "repo": "master-board", - "rev": "4521b8627f032fa606ade0024c24b65098e8e7e0", + "rev": "75eadd8649f0a13248d6e8a0913213ca80c52ea3", "type": "github" }, "original": { @@ -332,11 +332,11 @@ ] }, "locked": { - "lastModified": 1748252092, - "narHash": "sha256-6nL55wvV7SthEXaXDiQo8xxkxQLAVcNBU21YJ7GJLm8=", + "lastModified": 1747903970, + "narHash": "sha256-PFpAdjeBLpoY7v1v0GUeFuBWhEOiA187l0b2lmg117A=", "owner": "numtide", "repo": "system-manager", - "rev": "c6850451ef769fd03d0ad5474f928b916aa23775", + "rev": "94f1c8d9c562e96358dddddb8e276ba8ac16c9ae", "type": "github" }, "original": { @@ -368,11 +368,11 @@ ] }, "locked": { - "lastModified": 1748243702, - "narHash": "sha256-9YzfeN8CB6SzNPyPm2XjRRqSixDopTapaRsnTpXUEY8=", + "lastModified": 1747912973, + "narHash": "sha256-XgxghfND8TDypxsMTPU2GQdtBEsHTEc3qWE6RVEk8O0=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "1f3f7b784643d488ba4bf315638b2b0a4c5fb007", + "rev": "020cb423808365fa3f10ff4cb8c0a25df35065a3", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 88d37fc..ff6cd83 100755 --- a/flake.nix +++ b/flake.nix @@ -3,7 +3,7 @@ inputs = { # TODO: drop `/module` after https://github.com/Gepetto/nix/pull/54 - gepetto.url = "github:gwennlbh/gepetto-nix/odri"; + gepetto.url = "github:gepetto/nix/module"; flake-parts.follows = "gepetto/flake-parts"; nixpkgs.follows = "gepetto/nixpkgs"; nix-ros-overlay.follows = "gepetto/nix-ros-overlay"; @@ -53,7 +53,7 @@ program = "${self'.packages.odri-control-interface}/bin/odri_control_interface_demo_solo12"; }; }; - devShells.default = pkgs.mkShell { + devShells.python = pkgs.mkShell { buildInputs = [ self'.packages.odri-control-interface pkgs.odri-masterboard-sdk From 4b8ec150c62bab84249618295ee7c0b3cc0383a3 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Tue, 3 Jun 2025 16:20:23 +0200 Subject: [PATCH 23/33] use PYTHONPATH instead of a shellhook Signed-off-by: Gwenn Le Bihan --- flake.nix | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index ff6cd83..0896324 100755 --- a/flake.nix +++ b/flake.nix @@ -60,11 +60,10 @@ pkgs.python3Packages.python pkgs.python3Packages.numpy ]; - shellHook = '' - controlSitePackages=`echo ${self'.packages.odri-control-interface}/lib/python*/site-packages | head -n 1` - masterboardSitePackages=`echo ${pkgs.odri-masterboard-sdk}/lib/python*/site-packages | head -n 1` - export PYTHONPATH="$controlSitePackages:$masterboardSitePackages:$PYTHONPATH" - ''; + PYTHONPATH = lib.concatMapStringsSep ":" (p: "${p}/${pkgs.python3.sitePackages}") [ + self'.packages.odri_control_interface + pkgs.odri_master_board_sdk + ]; }; }; }; From d8ac4923f6c5ae24ca52491b7639c91cf692f397 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Tue, 3 Jun 2025 16:23:05 +0200 Subject: [PATCH 24/33] ci: use gepetto cachix Signed-off-by: Gwenn Le Bihan --- .github/workflows/nix.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 571fb67..8c0b2b6 100755 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -8,6 +8,10 @@ jobs: steps: - uses: actions/checkout@v4 - uses: cachix/install-nix-action@v30 + - uses: cachix/cachix-action@v15 + with: + name: gepetto + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - run: nix flake check -L - name: Check if there are changes uses: NathanielHill/fail-if-changes@v1.1.1 From c1862383126881dd8dd353de5fb788a93ffe7bc9 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Tue, 3 Jun 2025 16:23:16 +0200 Subject: [PATCH 25/33] gitignore: revert cmake-related ignores Signed-off-by: Gwenn Le Bihan --- .gitignore | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.gitignore b/.gitignore index 0df71c3..7d082dd 100644 --- a/.gitignore +++ b/.gitignore @@ -6,11 +6,3 @@ *.code-workspace result .vscode/c_cpp_properties.json -CMakeFiles -include/odri/control/interface/*.hh -CMakeCache.txt -CMakeDoxyfile.in -CMakeDoxygenDefaults.cmake -DartConfiguration.tcl -config.h -config.log From bdd68a066cf2c0d5a3da81075419a36d327b1662 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Tue, 3 Jun 2025 16:23:36 +0200 Subject: [PATCH 26/33] nix: tidy up flake apps' program decls Signed-off-by: Gwenn Le Bihan --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 0896324..a1d4504 100755 --- a/flake.nix +++ b/flake.nix @@ -46,11 +46,11 @@ apps = { testbench = { type = "app"; - program = "${self'.packages.odri-control-interface}/bin/odri_control_interface_demo_testbench"; + program = lib.getExe' self'.packages.odri-control-interface "/bin/odri_control_interface_demo_testbench"; }; solo12 = { type = "app"; - program = "${self'.packages.odri-control-interface}/bin/odri_control_interface_demo_solo12"; + program = lib.getExe' self'.packages.odri-control-interface "/bin/odri_control_interface_demo_solo12"; }; }; devShells.python = pkgs.mkShell { From ef06648ee53059d37d2d776f58172ad1d634f856 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Wed, 4 Jun 2025 10:20:26 +0200 Subject: [PATCH 27/33] ci: run on macos too Signed-off-by: Gwenn Le Bihan --- .github/workflows/nix.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 8c0b2b6..53d2cf6 100755 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -4,7 +4,12 @@ on: [push, pull_request] jobs: CI: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + + runs-on: ${{ matrix.os }} + name: CI (${{ matrix.os }}) steps: - uses: actions/checkout@v4 - uses: cachix/install-nix-action@v30 From 242499834e7dc2f13614321f2069df01ec98469b Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Wed, 4 Jun 2025 10:29:08 +0200 Subject: [PATCH 28/33] nix: fix pname for PYTHONPATH Signed-off-by: Gwenn Le Bihan --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index a1d4504..9882b94 100755 --- a/flake.nix +++ b/flake.nix @@ -61,8 +61,8 @@ pkgs.python3Packages.numpy ]; PYTHONPATH = lib.concatMapStringsSep ":" (p: "${p}/${pkgs.python3.sitePackages}") [ - self'.packages.odri_control_interface - pkgs.odri_master_board_sdk + self'.packages.odri-control-interface + pkgs.odri-masterboard-sdk ]; }; }; From bc6321f56eed15d9b3733d2d3574b72751c356b8 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Wed, 4 Jun 2025 10:39:35 +0200 Subject: [PATCH 29/33] ci: only prevent lockfile changes on ubuntu github action does not support macos Signed-off-by: Gwenn Le Bihan --- .github/workflows/nix.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 53d2cf6..de20a36 100755 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -19,4 +19,5 @@ jobs: authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - run: nix flake check -L - name: Check if there are changes + if: ${{ matrix.os == 'ubuntu-latest' }} uses: NathanielHill/fail-if-changes@v1.1.1 From 36e6bb260f39aab47b5b0a4f672e8782c6c85b2a Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Thu, 5 Jun 2025 15:41:40 +0200 Subject: [PATCH 30/33] ci: dedupe job creation Co-authored-by: Guilhem Saurel --- .github/workflows/nix.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index de20a36..e7c7303 100755 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -1,6 +1,12 @@ name: CI - Nix -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: CI: From 884d94c5abd02c82f6d6362ad048e16018323218 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Thu, 5 Jun 2025 15:42:38 +0200 Subject: [PATCH 31/33] nix: fix path to apps' program Co-authored-by: Guilhem Saurel --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 9882b94..a9028e7 100755 --- a/flake.nix +++ b/flake.nix @@ -46,11 +46,11 @@ apps = { testbench = { type = "app"; - program = lib.getExe' self'.packages.odri-control-interface "/bin/odri_control_interface_demo_testbench"; + program = lib.getExe' self'.packages.odri-control-interface "odri_control_interface_demo_testbench"; }; solo12 = { type = "app"; - program = lib.getExe' self'.packages.odri-control-interface "/bin/odri_control_interface_demo_solo12"; + program = lib.getExe' self'.packages.odri-control-interface "odri_control_interface_demo_solo12"; }; }; devShells.python = pkgs.mkShell { From 9d9ff5fc5c34916145af16f36c6dbffb5378ee74 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Thu, 5 Jun 2025 16:05:22 +0200 Subject: [PATCH 32/33] maybe fix demo testbench Signed-off-by: Gwenn Le Bihan --- demos/demo_testbech_joint_calibrator.py | 49 ++++++++++++++++--------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/demos/demo_testbech_joint_calibrator.py b/demos/demo_testbech_joint_calibrator.py index ff19773..0da3738 100644 --- a/demos/demo_testbech_joint_calibrator.py +++ b/demos/demo_testbech_joint_calibrator.py @@ -72,19 +72,6 @@ imu = oci.IMU(robot_if) -robot = oci.Robot(robot_if, joints, imu) -robot.start() -robot.wait_until_ready() - -# As the data is returned by reference, it's enough -# to get hold of the data one. It will update after -# each call to `robot.parse_sensor_data`. -imu_attitude = imu.attitude_euler -positions = joints.positions -velocities = joints.velocities - -des_pos = np.zeros(12) - # Setup the calibration method joint_offsets = np.array( [ @@ -100,15 +87,41 @@ 0.0, 0.0, 0.0, - ] -) + ], + dtype=np.float64, +).reshape(-1, 1) + sdir = oci.CalibrationMethod.positive + +zero_offsets = np.zeros(12, dtype=np.int32).reshape(-1, 1) +some_other_array = np.zeros(12, dtype=np.float64).reshape(-1, 1) + joint_calibrator = oci.JointCalibrator( - joints, 12 * [sdir], joint_offsets, - np.zeros(12, dtype=int), np.zeros(12), - 5.0 / 20.0, 0.05 / 20.0, 2.0, 0.001 + joints, + 12 * [sdir], + joint_offsets, + zero_offsets, + some_other_array, + 5.0 / 20.0, + 0.05 / 20.0, + 2.0, + 0.001, ) +robot = oci.Robot(robot_if, joints, imu, joint_calibrator) +robot.start() +robot.wait_until_ready() + +# As the data is returned by reference, it's enough +# to get hold of the data one. It will update after +# each call to `robot.parse_sensor_data`. +imu_attitude = imu.attitude_euler +positions = joints.positions +velocities = joints.velocities + +des_pos = np.zeros(12) + + c = 0 dt = 0.001 calibration_done = False From 1137873714fd326fd3ab86cc5632bae72f965866 Mon Sep 17 00:00:00 2001 From: Gwenn Le Bihan Date: Thu, 5 Jun 2025 17:46:54 +0200 Subject: [PATCH 33/33] add python testbench demo Signed-off-by: Gwenn Le Bihan --- demos/demo_testbench.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 demos/demo_testbench.py diff --git a/demos/demo_testbench.py b/demos/demo_testbench.py new file mode 100755 index 0000000..1c1f6f6 --- /dev/null +++ b/demos/demo_testbench.py @@ -0,0 +1,35 @@ +import numpy as np + +np.set_printoptions(suppress=True, precision=2) + +import libodri_control_interface_pywrap as oci + +robot = oci.robot_from_yaml_file("config_testbench.yaml") + +des_pos = np.array([np.pi / 2, -np.pi / 2]) + +robot.initialize(des_pos) + +kp, kd = 0.125, 0.0025 +c = 0 +while not robot.is_timeout: + robot.parse_sensor_data() + + positions = robot.joints.positions + velocities = robot.joints.velocities + + # Compute the PD control on the zero position. + torques = kp * (des_pos - positions) - kd * velocities + + robot.joints.set_torques(torques) + robot.send_command_and_wait_end_of_cycle(0.001) + + c += 1 + + if c % 1000 == 0: + print("joint pos: ", positions) + print("joint vel: ", velocities) + print("torques: ", torques) + robot.robot_interface.PrintStats() + +print("timeout detected")