1
$\begingroup$

Rosanswers logo

Hi everyone! I'm trying to understand the best way to setup my environment for ROS2+Gazebo.

Up until now I was using an Ubuntu 22.04 VM with Virtualbox to get simple exercises up and running in ROS2, with no major problem. Since I have to go up a step and start a more complex system, plus I'll need Gazebo for simulations, I thought about how to improve the environment, given that there is always some kind of performance issue using VMs. It seems my options are:

  • dual boot
  • Docker
  • Git Bash from CMD, as if I was actually on Unix

Since for simplicity of use, budget (can't get another laptop) and resources (my laptop's SDD is not that big) the dual boot is not an option, I moved to Docker. I set up the container (osrf/ros), I installed XLaunch for the GUI and successfully integrated Docker with WSL2. Everything following this guide

However, I can't seem to use my Nvidia graphic card. I've tried launching the turtlesim node + teleop, but it's laggy and slow and Task Manager does not show the process as executing with the Nvidia card.

Has anyone managed to successfully setup a similar environment? Or is there any other option that is actually better than this?

Thanks in advance!


Originally posted by slim71 on ROS Answers with karma: 18 on 2023-04-22

Post score: 0

$\endgroup$

2 Answers 2

1
$\begingroup$

Yes Yes!!!✌
I finally find a solution after two days hard working.

It's all about Containerizing GUI applications with WSLg

Thanks for rr-robot post an issue about WSL2 + Docker + OpenGL + NVIDIA not working (uses llvmpipe) and give the solution.

Now run the container with following command:

 docker run --name test  -v /tmp/.X11-unix:/tmp/.X11-unix \
-v /mnt/wslg:/mnt/wslg \
-e DISPLAY=unix$DISPLAY \
-e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
--device=/dev/dxg \
-v /usr/lib/wsl:/usr/lib/wsl \
-it --gpus all --device /dev/dri:/dev/dri --privileged \
-v /dev:/dev -e NVIDIA_DRIVER_CAPABILITIES=all \
-e LD_LIBRARY_PATH=/usr/lib/wsl/lib \
--net=host osrf/ros:jazzy-desktop-full /bin/bash

The additional part:

-v /mnt/wslg:/mnt/wslg \
-e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
--device=/dev/dxg \
-v /usr/lib/wsl:/usr/lib/wsl \
-e LD_LIBRARY_PATH=/usr/lib/wsl/lib \

In this case: The output from nvidia-smi covers the two processess named "ruby" relates to simulator.

Have a nice day!!! 😁😁😁😁

$\endgroup$
2
  • $\begingroup$ I can't actually test out this, since I'm on a Linux machine now, but it's fair to say this does add more info and is more helpful than my own "give up" answer, so I'll switch to this as the accepted one! :) $\endgroup$
    – slim71
    Commented Jun 10 at 20:24
  • $\begingroup$ Thank you.Using docker is just for convenience. I didn't expect that it can't be opened in wsl and can be used immediately. However, after the configuration is completed, there are still advantages. At least there is no need for dual systems. You can also debug ROS+gazebo in the Windows environment. $\endgroup$ Commented Jun 11 at 10:26
0
$\begingroup$

Rosanswers logo

To anybody interested, I gave up.
Getting everything set up on Windows is such a pain, and gives no benefits.

I've found a SSD drive empty and setup a detachable dual-boot with Ubuntu there.


Originally posted by slim71 with karma: 18 on 2023-05-20

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.