🚧 Welcome to mc-rtc's nixpkgs flake
🚧 This repository is an ongoing effort of packaging the mc-rtc ecosystem under Nix
🚧 Flake API and overlay structure may change without notice
Current status:
- Default devShell:
mc-rtc-superbuildAllows to build mc-rtc and configure its runtime dependencies (robots,controllers,observers,plugins) - Run
MCFrankaControlwith real Panda robots -
mc-rtc-magnumsupport (with olderglfw/imgui/implotas submodules, as done inmc-rtc-superbuild) - Robots
- JVRC1
- HRP-2Kai
- HRP-4
- Panda*
- PandaLIRMM*
- RHPS1
- Controllers
- Rolkneematics
panda-prosthesis - WIP: Hugo's polytopeController
- Rolkneematics
-
mc-mujoco: building and running but some HiDPI scaling issues on Wayland with glfw 3.4 - magnum packaging (external): in progress
- magnum
- SDL2Application: works
- GlfwApplication: HiDPI scaling issue on Wayland with GlfW 3.4, works otherwise
- magnum-plugins (only those needed by
mc-rtc-magnum/mc-mujoco - magnum-integration
- magnum
- Install Nix on your system
- Install cachix
- Enable the cachix cache (some user configuration)
- Clone this repository
- Navigate to the cloned folder
- Run
nix develop
Options are provided through env variables
MC_RTC_WITH_ROS="1": buildmc-rtcand depencencies (e.g robots) with ros support (ros2 humble) [default=1]MC_RTC_USE_LOCAL="1": for derivations inoverlay.nixthat are called withuseLocal = true(usingcallWithLocal ...), use a cloned folder inlocalWorkspacefolder. This is not intended to be kept long-term, mostly a convenient debugging option until this repo is stable.
To override the default shell environment to use your own local version of a controller, you can do
mkdir -p nix-workspace/install nix-workspace/develnow create a .direnv file with the following content
# Do not auto-update the flake, do so manually through nix-direnv-reload
# This avoids triggering potentially long compilations upon entering a shell
nix_direnv_manual_reload
# Use this flake
use flake https://github.com/mc-rtc/nixpkgs
# or use a local copy for development
# export MC_RTC_WITH_ROS=1
# export MC_RTC_USE_LOCAL=1
# use flake nixpkgs --impure # if you cloned it locally in ./nixpkgs
# Override LD_LIBRARY_PATH and PATH to use the local install folder for your custom controller
export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$PWD/install/lib64:$LD_LIBRARY_PATH
export PATH=$PWD/install/bin:$PATH
# convenient cmake alias to ensure that the controller is installed in the expected local path
alias cmake_local="cmake -DCMAKE_PREFIX_PATH=$PWD/install -DMC_RTC_HONOR_INSTALL_PREFIX=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja"Then run direnv allow. Upon entering the nix-workspace folder, this will setup the environment for you.
Now if you wish to install a custom controller/...
cd nix-workspace/devel
git clone <your_controller>
cd <your_controller>Create a .envrc file here
source_up
export MC_RTC_CONTROLLER_CONFIG="$PWD/../install/lib64/mc_controller/etc/mc_rtc.yaml:MC_RTC_CONTROLLER_CONFIG"Then run direnv allow again. This will add your controller to the MC_RTC_CONTROLLER_CONFIG variable. To build:
mkdir build
cd build
cmake_local ..This is still a WIP, but the gist of it is:
-
define a derivation in your overlay containing all the derivations you wish to have available to mc-rtc. Runtime dependencies are passed to the
robots/controllers/observers/pluginslist and a correspondingmc_rtc.yamlcontaining the required library paths is auto-generated and added toMC_RTC_CONTROLLER_CONFIGenv variable.mc-rtc-superbuild-rolkneematics = final.mc-rtc-superbuild.overrideAttrs (old: { robots = [ # note that panda-prosthesis is not strictly-speaking a robot, but it builds a robot module so we need it here as well to populate the robots runtime paths panda-prosthesis mc-panda-lirmm mc-panda ]; controllers = [ panda-prosthesis ]; # extra mc_rtc.yaml configs = [ "${panda-prosthesis}/lib/mc_controller/etc/mc_rtc.yaml" ]; observers = []; plugins = [ panda-prosthesis mc-force-shoe-plugin ]; apps = [ mc-rtc-magnum mc-franka mc-rtc-ticker sch-visualization ]; });
Full doc coming soon...
# if cachix is setup correctly this should just pull binary dependencies. Otherwise
# it will build everything specified in the `mc-rtc-superbuild` derivation (and their depencencies)
nix develop
# or nix develop .#mc-rtc-superbuild-rolkneematics # if you want to use your own derivation
mc-rtc-magnum &
# By default mc_rtc_ticker will use the configuration provided by `MC_RTC_CONTROLLER_CONFIG` env variable
# This is set by the mc-rtc-superbuild derivation and devShell to contain all needed runtime depencencies
# and optionally a default controller's configuration
mc_rtc_ticker