From 2c9de7057db6ec58b66dff702e4a46c7a492c380 Mon Sep 17 00:00:00 2001 From: Trim Bresilla Date: Thu, 22 Oct 2026 14:54:53 +0200 Subject: [PATCH] Add Nix ROS development environment and Oslo commands --- .env.lua | 3 ++ .gitignore | 5 +++ .make.lua | 46 ++++++++++++++++++++++++ flake.lock | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 43 +++++++++++++++++++++++ 5 files changed, 198 insertions(+) create mode 100644 .env.lua create mode 100644 .make.lua create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.env.lua b/.env.lua new file mode 100644 index 0000000..45fad06 --- /dev/null +++ b/.env.lua @@ -0,0 +1,3 @@ +-- This experiment stays on RAMM; it has no sync hooks. +local root = oslo.direnv.dir() or oslo.sys.pwd() +oslo.direnv.nix_develop { flake = "path:" .. root } diff --git a/.gitignore b/.gitignore index c734d55..e607755 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,8 @@ inventory.yaml.bak persist.json calibration*.yaml camera_calibration/ + +/.logs/ +/config/ +/state/ +/captures/ diff --git a/.make.lua b/.make.lua new file mode 100644 index 0000000..390ca0b --- /dev/null +++ b/.make.lua @@ -0,0 +1,46 @@ +local make = oslo.make + +-- Invoke ROS tools in this project's Nix environment; no shell wrapper needed. +local function ros(...) + local argv = { "nix", "develop", "path:.", "--accept-flake-config", "--command" } + for _, value in ipairs({ ... }) do argv[#argv + 1] = value end + return oslo.run(argv) +end + +make.recipe { + name = "build", + desc = "Build Vixel with ROS 2 Lyrical", + run = function() + assert(ros("colcon", "build", "--symlink-install", "--parallel-workers", "2", + "--cmake-args", "-DCMAKE_BUILD_TYPE=Release", "-DBUILD_TESTING=ON").ok, + "Vixel build failed") + end, +} + +make.recipe { + name = "test", + desc = "Run Vixel tests and show their results", + run = function() + local tests = ros("colcon", "test", "--return-code-on-test-failure") + local results = ros("colcon", "test-result", "--verbose") + assert(tests.ok and results.ok, "Vixel tests failed; see the results above") + end, +} + +make.recipe { + name = "run", + desc = "Launch Vixel and its dashboard on localhost:8080", + run = function() + local vision = oslo.run { + "systemctl", "--user", "is-active", "--quiet", "smartweg-vision.service", + capture = true, + } + assert(not vision.ok, + "Stop the camera GUI first: systemctl --user stop smartweg-vision.service") + local root = oslo.sys.pwd() + assert(ros("ros2", "launch", "vixel", "cameras_launch.py", + "machine_file:=" .. root .. "/config/machine.yaml", + "inventory_file:=" .. root .. "/state/inventory.yaml", + "web_preview:=true", "web_port:=8080").ok, "Vixel launch failed") + end, +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..885f26f --- /dev/null +++ b/flake.lock @@ -0,0 +1,101 @@ +{ + "nodes": { + "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" + } + }, + "nix-ros-overlay": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rosdistro": "rosdistro" + }, + "locked": { + "lastModified": 1789758058, + "narHash": "sha256-c+AUIcYBXX/5oU2+xpVyg/UjsTTS/CJXIprnWKdy1mE=", + "owner": "lopsided98", + "repo": "nix-ros-overlay", + "rev": "814d97b0b7236c0834fc079effa55acabb269926", + "type": "github" + }, + "original": { + "owner": "lopsided98", + "ref": "master", + "repo": "nix-ros-overlay", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1785828668, + "narHash": "sha256-8fsyqeO+mJqvIzeO4xIpgJe/f7MTbbVTEC6RT6WSXNs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e72e4f299401a3689d4b3d5fc6496b11db7064eb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nix-ros-overlay": "nix-ros-overlay", + "nixpkgs": [ + "nix-ros-overlay", + "nixpkgs" + ] + } + }, + "rosdistro": { + "flake": false, + "locked": { + "lastModified": 1789112009, + "narHash": "sha256-RzYgfUnQ6ABdcqnz8ziHY8e9j5E0MwyhYiyDSU3KrHU=", + "owner": "ros", + "repo": "rosdistro", + "rev": "984f1f74889ad6145b7808e876e64037e7681c31", + "type": "github" + }, + "original": { + "owner": "ros", + "repo": "rosdistro", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..5605f75 --- /dev/null +++ b/flake.nix @@ -0,0 +1,43 @@ +{ + description = "RAMM-only Vixel experiment with ROS 2 Lyrical"; + inputs = { + nix-ros-overlay.url = "github:lopsided98/nix-ros-overlay/master"; + nixpkgs.follows = "nix-ros-overlay/nixpkgs"; + }; + outputs = { self, nixpkgs, nix-ros-overlay }: + let + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; overlays = [ nix-ros-overlay.overlays.default ]; }; + ros = pkgs.rosPackages.lyrical; + rosEnv = ros.buildEnv { + underlay = true; + paths = with ros; [ ros-core ament-cmake ament-cmake-core ament-cmake-gtest ament-cmake-python + rosidl-default-generators rosidl-default-runtime camera-info-manager cv-bridge + rclcpp rclcpp-action rclpy sensor-msgs std-msgs geometry-msgs action-msgs + builtin-interfaces tf2-ros tf2-ros-py launch launch-ros ros2launch ]; + }; + in { + devShells.${system}.default = pkgs.mkShell { + packages = [ rosEnv pkgs.colcon pkgs.cmake pkgs.ninja pkgs.pkg-config + pkgs.aravis pkgs.glib pkgs.libxml2 pkgs.zlib pkgs.libusb1 pkgs.yaml-cpp pkgs.nlohmann_json pkgs.opencv + pkgs.meson pkgs.git pkgs.nodejs pkgs.linuxptp pkgs.ethtool pkgs.iproute2 + pkgs.python3Packages.pytest pkgs.python3Packages.pyyaml pkgs.python3Packages.setuptools ]; + shellHook = '' + export ROS_DOMAIN_ID=42 + export ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST + export VIXEL_ROOT="$PWD" + export PYTHONNOUSERSITE=1 + if [ -f "$VIXEL_ROOT/install/local_setup.bash" ]; then + source "$VIXEL_ROOT/install/local_setup.bash" + fi + ''; + }; + }; + nixConfig = { + extra-substituters = [ "https://ros.cachix.org" "https://attic.iid.ciirc.cvut.cz/ros" ]; + extra-trusted-public-keys = [ + "ros.cachix.org-1:dSyZxI8geDCJrwgvCOHDoAfOm5sV1wCPjBkKL+38Rvo=" + "ros:JR95vUYsShSqfA1VTYoFt1Nz6uXasm5QrcOsGry9f6Q=" + ]; + }; +}