Skip to content

Commit

Permalink
utilize nvidia gpu while running gazebo on linux and windows (#72)
Browse files Browse the repository at this point in the history
* Bump athackst/mkdocs-simple-plugin from 2.2.0 to 2.3.0 (#41)

Bumps [athackst/mkdocs-simple-plugin](https://github.com/athackst/mkdocs-simple-plugin) from 2.2.0 to 2.3.0.
- [Release notes](https://github.com/athackst/mkdocs-simple-plugin/releases)
- [Commits](athackst/mkdocs-simple-plugin@v2.2.0...v2.3.0)

---
updated-dependencies:
- dependency-name: athackst/mkdocs-simple-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* allow x11 access to host (#44)

* Add debugging option for ROS launch files (#45)

* Add ROS launch files debugging

* Add ROS launch file debugging for isolated install

* Sort alphabetically the extensions

* Update cpp version (#48)

* Add support for intel iGPU (#55)

* remove wayland config, devcontainer handles it (#54)

* Revert "remove wayland config, devcontainer handles it (#54)" (#58)

This reverts commit 24e704d.

* Add script to add submodules to workspace from repos file (#59)

* Update workflow to only trigger when pushing to specific branches (#60)

* Bump athackst/mkdocs-simple-plugin from 2.3.0 to 3.0.0 (#61)

* Bump athackst/mkdocs-simple-plugin from 3.0.0 to 3.1.0 (#62)

* Bump actions/checkout from 3 to 4 (#64)

* Add rosdistro to setup and update purge command (#68)

* Remove eol foxy and add rolling to ros workflow (#69)

* utilize nvidia gpu while running gazebo on linux and windows

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sophia Koffler <[email protected]>
Co-authored-by: DaniGarciaLopez <[email protected]>
Co-authored-by: Shunsuke KIMURA <[email protected]>
Co-authored-by: SubaruArai <[email protected]>
Co-authored-by: Allison Thackston <[email protected]>
  • Loading branch information
7 people authored Jan 12, 2024
1 parent 29af219 commit b4a06bc
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 13 deletions.
16 changes: 16 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
FROM althack/ros2:humble-cuda-dev

### For Windows, uncomment the following lines to install WSLg dependencies and utilize vGPU acceleration
# ENV DEBIAN_FRONTEND=noninteractive
# RUN apt-get update \
# && apt-get -y install \
# vainfo \
# mesa-va-drivers \
# mesa-utils \
# # Clean up
# && apt-get autoremove -y \
# && apt-get clean -y \
# && rm -rf /var/lib/apt/lists/*
# ENV LIBVA_DRIVER_NAME=d3d12
# ENV LD_LIBRARY_PATH=/usr/lib/wsl/lib
# CMD vainfo --display drm --device /dev/dri/card0
# ENV DEBIAN_FRONTEND=dialog

# ** [Optional] Uncomment this section to install additional packages. **
#
# ENV DEBIAN_FRONTEND=noninteractive
Expand Down
17 changes: 14 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@
"--security-opt=apparmor:unconfined",
"--volume=/tmp/.X11-unix:/tmp/.X11-unix",
"--volume=/mnt/wslg:/mnt/wslg",
"--gpus=all"
"--ipc=host"
// uncomment to use intel iGPU
// "--device=/dev/dri"
// uncomment to use Nvidia GPU with Linux, https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html
// "--runtime=nvidia"
// uncomment to use Nvidia GPU with Windows WSL2
// "--volume=/usr/lib/wsl:/usr/lib/wsl",
// "--device=/dev/dxg",
// "--device=/dev/dri/card0",
// "--device=/dev/dri/renderD128",
// "--gpus=all"
],
"containerEnv": {
"DISPLAY": "${localEnv:DISPLAY}", // Needed for GUI try ":0" for windows
Expand All @@ -29,17 +39,18 @@
"vscode": {
"extensions": [
"althack.ament-task-provider",
"betwo.b2-catkin-tools",
"DotJoshJohnson.xml",
"ms-azuretools.vscode-docker",
"ms-iot.vscode-ros",
"ms-python.python",
"ms-vscode.cpptools",
"redhat.vscode-yaml",
"smilerobotics.urdf",
"streetsidesoftware.code-spell-checker",
"twxs.cmake",
"yzhang.markdown-all-in-one",
"zachflower.uncrustify",
"betwo.b2-catkin-tools"
"zachflower.uncrustify"
]
}
}
Expand Down
38 changes: 38 additions & 0 deletions .devcontainer/repos_to_submodules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import glob
import os
import subprocess
import yaml

prefix="src"

def add_git_submodule(repo_name, repo_url, repo_version):
subprocess.call(['git', 'submodule', 'add', '-b', repo_version, repo_url, repo_name])

def is_submodule(repo_name):
try:
subprocess.check_output(['git', 'submodule', 'status', repo_name], stderr=subprocess.DEVNULL)
return True
except subprocess.CalledProcessError:
return False

def parse_repos_file(file_path):
with open(file_path, 'r') as file:
repos_data = yaml.safe_load(file)
repositories = repos_data['repositories']

for repo_name, repo_info in repositories.items():
if 'type' in repo_info and repo_info['type'] == 'git':
repo_url = repo_info['url']
repo_version = repo_info['version']
submodule_name = os.path.join(prefix, repo_name)

if not is_submodule(submodule_name):
add_git_submodule(submodule_name, repo_url, repo_version)
print(f"Added {repo_name} as a submodule.")

# Find .repos files within the src directory
repos_files = glob.glob('src/**/*.repos', recursive=True)

# Process each .repos file
for repos_file in repos_files:
parse_repos_file(repos_file)
4 changes: 2 additions & 2 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Build and push docs
uses: athackst/mkdocs-simple-plugin@v2.2.0
uses: athackst/mkdocs-simple-plugin@v3.1.0
18 changes: 16 additions & 2 deletions .github/workflows/ros.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: ROS
on:
pull_request:
push:
branches:
- humble*
- iron*
- rolling*
workflow_dispatch:

jobs:
Expand All @@ -12,7 +16,7 @@ jobs:
steps:
-
name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Test
uses: ./.github/actions/test/
Expand All @@ -27,9 +31,19 @@ jobs:
steps:
-
name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Run linter
uses: ./.github/actions/lint/
env:
LINTER: ${{ matrix.linter }}

complete:
name: Tests passed
needs:
- lint
- test
runs-on: ubuntu-latest
steps:
- name: Check
run: echo "Completed successfully!"
2 changes: 1 addition & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"compilerPath": "/usr/bin/gcc",
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"cStandard": "c99",
"cppStandard": "c++14",
"cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
Expand Down
23 changes: 22 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,22 @@
"ignoreFailures": true
}
]
}
},
//Example of a ROS Launch file
{
"name": "ROS: Launch File (merge-install)",
"type": "ros",
"request": "launch",
"preLaunchTask": "build",
"target": "${workspaceFolder}/install/share/${input:package}/launch/${input:ros_launch}",
},
{
"name": "ROS: Launch File (isolated-install)",
"type": "ros",
"request": "launch",
"preLaunchTask": "build",
"target": "${workspaceFolder}/install/${input:package}/share/${input:package}/launch/${input:ros_launch}",
},
],
"inputs": [
{
Expand All @@ -64,6 +79,12 @@
"type": "promptString",
"description": "Program name",
"default": "publisher_member_function"
},
{
"id": "ros_launch",
"type": "promptString",
"description": "ROS launch name",
"default": "file_name_launch.py"
}
]
}
9 changes: 8 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"label": "purge",
"detail": "Purge workspace by deleting all generated files.",
"type": "shell",
"command": "rm -fr build install log; py3clean .",
"command": "sudo rm -fr build install log; sudo py3clean .",
"problemMatcher": []
},
// Linting and static code analysis tasks
Expand Down Expand Up @@ -228,6 +228,13 @@
"type": "shell",
"command": "./setup.sh",
"problemMatcher": []
},
{
"label": "add submodules from .repos",
"detail": "Create a git submodule for all repositories in your .repos file",
"type": "shell",
"command": "python3 .devcontainer/repos_to_submodules.py",
"problemMatcher": []
}
],
"inputs": [
Expand Down
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Take a look at [how I develop using tasks](https://www.allisonthackston.com/arti

### Debugging

This template sets up debugging for python files and gdb for cpp programs. See [`.vscode/launch.json`](.vscode/launch.json) for configuration details.
This template sets up debugging for python files, gdb for cpp programs and ROS launch files. See [`.vscode/launch.json`](.vscode/launch.json) for configuration details.

### Continuous Integration

Expand Down Expand Up @@ -184,3 +184,26 @@ If you want to access the vGPU through WSL2, you'll need to add additional compo
"LIBGL_ALWAYS_SOFTWARE": "1" // Needed for software rendering of opengl
},
```

### Repos are not showing up in VS Code source control

This is likely because vscode doesn't necessarily know about other repositories unless you've added them directly.

```
File->Add Folder To Workspace
```

![Screenshot-26](https://github.com/athackst/vscode_ros2_workspace/assets/6098197/d8711320-2c16-463b-9d67-5bd9314acc7f)


Or you've added them as a git submodule.

![Screenshot-27](https://github.com/athackst/vscode_ros2_workspace/assets/6098197/8ebc9aac-9d70-4b53-aa52-9b5b108dc935)

To add all of the repos in your *.repos file, run the script

```bash
python3 .devcontainer/repos_to_submodules.py
```

or run the task titled `add submodules from .repos`
4 changes: 2 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ set -e

vcs import < src/ros2.repos src
sudo apt-get update
rosdep update
rosdep install --from-paths src --ignore-src -y
rosdep update --rosdistro=$ROS_DISTRO
rosdep install --from-paths src --ignore-src -y --rosdistro=$ROS_DISTRO

0 comments on commit b4a06bc

Please sign in to comment.