Skip to content
Merged
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 .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake path:.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

### Note / Tips

- For example on x86_64 Linux, run:
- For example on typical x86_64 Linux, run:
```sh
wget https://github.com/google-deepmind/mujoco/releases/download/3.10.0/mujoco-3.10.0-linux-x86_64.tar.gz
tar -xzf mujoco-3.10.0-linux-x86_64.tar.gz
Expand All @@ -61,11 +61,13 @@
export LD_LIBRARY_PATH="$MUJOCO_LIB:$LD_LIBRARY_PATH"
```

- Or, you can get MuJoCo library through Python toolchain like `uv` or `pip`.
- Or, you can get MuJoCo library through Nix, or Python toolchain like `uv` or `pip`.

- Depending on your setting, be sure to specify `$MUJOCO_LIB` as shared library path
when executing your app (for example `LD_LIBRARY_PATH=$MUJOCO_LIB cargo run` on Linux)

- For Nix user: Refer to [rusty_mujoco repo's flake.nix](https://github.com/rust-control/rusty_mujoco/blob/main/flake.nix) as an example for the Nix-way to setup specific version of MuJoCo, `MUJOCO_LIB`, or `glfw` or other depending packages for executable app.

## Example

```toml
Expand Down
7 changes: 4 additions & 3 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ This example leaves a single object in the scene and visualizes it.

- Of course [`rusty_mujoco` Requirements](https://github.com/rust-control/rusty_mujoco?tab=readme-ov-file#requirements)
- Additionally [`glfw` Prerequisites](https://github.com/PistonDevelopers/glfw-rs?tab=readme-ov-file#prerequisites)
- (NOTE: This is already configured if you setup with `flake.nix`)

### Usage

Pass the path to a MuJoCo model XML file as an argument. For example,
you can use the `humanoid.xml` model provided by MuJoCo:
you may use the `humanoid.xml` model provided by MuJoCo:

```sh
cargo run --example visualize_left_object -- $MUJOCO_LIB/../model/humanoid/humanoid.xml
cargo run --example visualize_left_object -- $MUJOCO_LIB/../share/mujoco/model/humanoid/humanoid.xml
```

*(replace the path to humanoid.xml with yours)*
Expand All @@ -35,5 +36,5 @@ Depending on your setting, you may need to specify:
like:

```sh
LD_LIBRARY_PATH="$MUJOCO_LIB" cargo run --example visualize_left_object -- $MUJOCO_LIB/../model/humanoid.xml
LD_LIBRARY_PATH="$MUJOCO_LIB" cargo run --example visualize_left_object -- $MUJOCO_LIB/../share/mujoco/model/humanoid/humanoid.xml
```
115 changes: 115 additions & 0 deletions flake.lock

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

57 changes: 57 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-pin-mujoco-3_10_0.url = "github:nixos/nixpkgs/775bdd0467f3de2fb5017830d00fa1f573b2ecda";
flake-parts.url = "github:hercules-ci/flake-parts";
systems.url = "github:nix-systems/default";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = inputs@{
flake-parts,
systems,
...
}: flake-parts.lib.mkFlake { inherit inputs; } {
systems = import systems;
perSystem = {
system,
pkgs,
pkgs-pin-mujoco-3_10_0,
...
}: {
_module.args = {
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ (inputs.rust-overlay.overlays.default) ];
};
pkgs-pin-mujoco-3_10_0 = import inputs.nixpkgs-pin-mujoco-3_10_0 {
inherit system;
};
};
devShells.default =
let
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" ];
};
mujoco-3_10_0 = pkgs-pin-mujoco-3_10_0.mujoco;
in
pkgs.mkShell {
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
RUSTFLAGS = pkgs.lib.optionalString pkgs.stdenv.isLinux "-C link-arg=-fuse-ld=bfd";
MUJOCO_LIB = "${mujoco-3_10_0}/lib";
packages = [
rustToolchain
] ++ (with pkgs-pin-mujoco-3_10_0; [
pkg-config
glfw3
]) ++ pkgs.lib.optionals pkgs.stdenv.isLinux (with pkgs-pin-mujoco-3_10_0; [
libx11
wayland
]);
};
};
};
}