Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
result
102 changes: 0 additions & 102 deletions CMakeLists.txt

This file was deleted.

13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ SLAM stack for dimos.

- `cuvslam/` — our cuVSLAM lineage (NVIDIA cuVSLAM v17 + odometry state
serialization). Licensed under the NVIDIA Community License (`cuvslam/LICENSE`).
- `src/`, `CMakeLists.txt` — the dimos native odometry module (`cuvslam_odometry`)
built on top of it.
- `flake.nix` — builds both: `nix build .#<variant>` (variants: `x86_64-cuda12`,
`x86_64-cuda13`, `orin`, `thor`, `metal`; fork-source builds for x86_64-cuda12
and orin, NVIDIA release tarballs for the rest). The dimos header-only native
C++ SDK comes in as the pinned `dimos-src` flake input.
- `rust/` — the `dim_slam` dimos module: cuVSLAM visual odometry (via a small
extern-"C" shim in `shim/`, the only C++) feeding an error-state Kalman fusion
filter in-process. Needs `CUVSLAM_SDK_DIR` (a dir with
`include/cuvslam/cuvslam2.h` and `lib/libcuvslam.*`) to build.
- `flake.nix` — builds everything: `nix build .#<variant>` (variants:
`x86_64-cuda12`, `x86_64-cuda13`, `orin`, `thor`, `metal`; fork-source builds
for x86_64-cuda12 and orin, NVIDIA release tarballs for the rest).

dimos consumes this repo by git tag:
`nix build github:dimensionalOS/dimSLAM/<tag>#<variant>`
80 changes: 1 addition & 79 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

94 changes: 35 additions & 59 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,41 +1,19 @@
{
description = "dimSLAM: cuVSLAM (in cuvslam/) plus the dimos odometry module built on it";
description = "dimSLAM: cuVSLAM (in cuvslam/) plus the Rust dim_slam module built on it";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
lcm-extended = {
url = "github:jeff-hykin/lcm_extended";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
# Generated LCM message headers, via a FetchContent source override.
dimos-lcm = {
url = "github:dimensionalOS/dimos-lcm/main";
flake = false;
};
# Standalone Boost.PFR, the same way.
pfr = {
url = "github:apolukhin/pfr_non_boost/2.3.2";
flake = false;
};
# The dimos header-only native C++ SDK (module/transport/config headers).
# Pinned to a dimos main revision; bump when native/cpp changes.
dimos-src = {
url = "github:dimensionalOS/dimos/bc5605aa5de303b557d40215e4e608a204713fa5";
flake = false;
};
};

outputs = { self, nixpkgs, flake-utils, lcm-extended, dimos-lcm, pfr, dimos-src, ... }:
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
isDarwin = nixpkgs.lib.hasSuffix "-darwin" system;
pkgs = import nixpkgs {
inherit system;
config = { allowUnfree = true; cudaSupport = !isDarwin; };
};
lcm = lcm-extended.packages.${system}.lcm;

# Every C++ build NVIDIA ships for this release. The ubuntu flavor does not
# matter under autoPatchelf. `cuda` is the matching nixpkgs set: a runtime
Expand Down Expand Up @@ -264,42 +242,39 @@
# the module's runtime libs.
sdkPackageFor = name: sdk:
if forkBuilds ? ${name} then forkSdkFor name forkBuilds.${name} else sdkFor name sdk;
runtimeCudaFor = name: sdk:
if forkBuilds ? ${name} then { cuda = forkBuilds.${name}.cuda; } else sdk;

moduleFor = name: sdk: let sdkPackage = sdkPackageFor name sdk; in pkgs.stdenv.mkDerivation {
pname = "dimos-cuvslam-native";
version = "0.1.0";
# cmake inputs only. Editing cuvslam.py must not rebuild the C++.
src = pkgs.lib.fileset.toSource {
root = ./.;
fileset = pkgs.lib.fileset.unions [ ./CMakeLists.txt ./src ];
};

nativeBuildInputs = [ pkgs.cmake pkgs.pkg-config ]
++ pkgs.lib.optionals isDarwin [ pkgs.makeWrapper ]
++ pkgs.lib.optionals (!isDarwin) [ pkgs.autoPatchelfHook ];
buildInputs = [ lcm pkgs.glib pkgs.nlohmann_json pkgs.eigen sdkPackage ]
++ cudaLibs (runtimeCudaFor name sdk);

cmakeFlags = [
# cmake otherwise defaults to no optimisation at all.
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_POLICY_VERSION_MINIMUM=3.5"
"-DFETCHCONTENT_SOURCE_DIR_DIMOS_LCM=${dimos-lcm}"
"-DFETCHCONTENT_SOURCE_DIR_PFR=${pfr}"
"-DDIMOS_NATIVE_CPP_DIR=${dimos-src}/native/cpp"
"-DCUVSLAM_SDK_DIR=${sdkPackage}"
];

# The archive ships every kernel already compiled, but its store path is
# read-only so CuMetal cannot use it as the normal cache; this is the read-only
# lookup it consults first.
postInstall = pkgs.lib.optionalString isDarwin ''
wrapProgram $out/bin/cuvslam_odometry \
--set-default CUMETAL_PREBUILT_CACHE_DIR ${sdkPackage}/share/cumetal-cache
'';
# The crates' git dependencies, pre-fetched so the sandboxed cargo build
# needs no network. Both dimos-module crates come from the same dimos
# checkout, so they share a hash. Bump alongside Cargo.lock.
rustGitDepHashes = {
"dimos-module-0.1.0" = "sha256-nMnCk9RbDKhOUZRCQUCjZVVPeQY8HrwFLItaZ64Q1KY=";
"dimos-module-macros-0.1.0" = "sha256-nMnCk9RbDKhOUZRCQUCjZVVPeQY8HrwFLItaZ64Q1KY=";
"lcm-msgs-0.1.0" = "sha256-GGkx4Mn6NYP6KZecmoRLKGWIih/+y8OgNn12DeXX6n8=";
};

moduleFor = name: sdk: let sdkPackage = sdkPackageFor name sdk; in
pkgs.rustPlatform.buildRustPackage {
pname = "dim_slam";
version = "0.1.0";
src = ./rust;
cargoLock = {
lockFile = ./rust/Cargo.lock;
outputHashes = rustGitDepHashes;
};
# build.rs compiles the shim against this SDK and embeds lib/ as an rpath.
env.CUVSLAM_SDK_DIR = sdkPackage;
nativeBuildInputs = pkgs.lib.optionals isDarwin [ pkgs.makeWrapper ];
# The test binary links libcuvslam, whose CUDA runtime wants a GPU
# driver the build sandbox lacks; unit tests run via plain cargo test.
doCheck = false;
# The archive ships every kernel already compiled, but its store path is
# read-only so CuMetal cannot use it as the normal cache; this is the
# read-only lookup it consults first.
postInstall = pkgs.lib.optionalString isDarwin ''
wrapProgram $out/bin/dim_slam \
--set-default CUMETAL_PREBUILT_CACHE_DIR ${sdkPackage}/share/cumetal-cache
'';
};
in {
# One package per build NVIDIA ships for this arch.
packages = pkgs.lib.mapAttrs moduleFor forThisSystem
Expand All @@ -310,7 +285,8 @@
// { default = moduleFor defaultVariant forThisSystem.${defaultVariant}; };

devShells.default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.default ];
packages = [ pkgs.cargo pkgs.rustc pkgs.clippy pkgs.rustfmt ];
CUVSLAM_SDK_DIR = sdkPackageFor defaultVariant forThisSystem.${defaultVariant};
};
});
}
1 change: 0 additions & 1 deletion result

This file was deleted.

3 changes: 3 additions & 0 deletions rust/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# dimos is a private repo: fetch with the system git so its credentials apply.
[net]
git-fetch-with-cli = true
1 change: 1 addition & 0 deletions rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
Loading