Local development setup

Hello,
I love the Construct site and courses. I’ve learnt so much. I’m at a point where I want to try and develop ROS2 applications locally on my machine and run rviz and gazebo. I have a newish MacBook pro.

Just wondering how professional robotics Devs work locally and how they run the tools.

Should I get a Linux machine, run everything in docker etc.?

Hi @phillip.jr.hogan,

I suppose many companies would use a single ROS Distro to run their entire robotics systems. In cases like this, having ROS installed directly on the computer would work.

But there may be cases where many ROS Distros are required. In cases like this, ROS in Docker would be more recommended, because it allows you to run different ROS Distros in the same machine with no conflicts whatsoever.

If you want to run ROS in Docker, in order to see the graphical tools like RViz, Gazebo, etc, you have to mount the /tmp/.X11-unix folder inside the container and set the DISPLAY variable in the container to the same display used on your computer (also known as docker host).

If you check ROS tutorials on dockers, you will always see the DISPLAY variable and the /tmp/.X11-unix directory being referenced:

The two links above use ROS 1 in the examples, but the principles are the same in ROS 2.

I (Ruben) personally don’t have a Mac, and as I see it in the ROS 2 Humble installation guide, if one wants ROS 2 installed directly in a macOS Docker host (your computer), ROS would need to be compiled from source:

If you don’t want to compile it from source, a good alternative is to really use Docker.

In case you want a test of concept on how to see graphical apps from Docker without having to test ROS itself (because ROS is huge), you can do it in these simple steps:

  1. Create a Dockerfile and and the following content to it:
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y x11-apps
CMD ["xeyes"]
  1. Build the image (tag it as my-xeyes):
docker build --tag=my-xeyes .
  1. Grant Access to the X Server
xhost +local:docker
  1. Then run your Docker Image:
docker run --rm -it  --net=host  -e DISPLAY my-xeyes

At this point, if everything went well, you should be able to see two eyes following your mouse position.

You can also launch bash in the container and manually call xeyes interactively. Example:

docker run --rm -it     --net=host     -e DISPLAY my-xeyes bash

Now you should be inside the container.

You can inspect the DISPLAY variable inside the container with:

echo $DISPLAY

which should display something :0.

Then you can simply call xeyes inside the container:

xeyes

Again, you should see the xeyes application with the eyes following your mouse.

Please let us know if we can be of further help on this.

#KeepPushingYourROSLearning

1 Like

Hi @ralves,

Thank you so much for your reply. This has been a great help to me.

1 Like

Hi @ralves, I gave Docker a try last night and did get ROS2 working successfully (with a bit of configuration of XQuartz to allow network clients and enable TCP listening).

Your links above and the below guide was helpful:

However, trying to run Gazebo in my container using a Mac like mine with an Apple M4 Pro chip just doesn’t seem possible right now from what I have read. I could get Gazebo to run, but any simulations which required sensors such as lidars just failed to load (ogre2 warnings).

I don’t want to try and force the setup if it is not optimal, and I plan to take the ROS2 Master class with Construct in September, so I was wondering if there is a recommended setup you could advise on please? Perhaps a remote server I can ssh into or run a remote desktop against so I can run ROS2 and Gazebo etc.

Buying a new computer at the moment isn’t possible for me - but it would be nice to work locally on my own machine, but I feel like a remote setup might be best for now.

Any tips would be greatly appreciated.

Hi @phillip.jr.hogan,

Before giving any advice, it would be nice to see what the error messages are. If you could share a screenshot of the error, that could possibly help too.

I remember I once had problems related to Ogre, and in my case, I had to upgrade the drivers, but I don’t know if your error is the same; that is why I say that with a screenshot and error messages, we may have a better idea of how to proceed.

Hi @ralves,

I reset my local. I am now not getting any errors, just a blank black screen in Gazebo. I can publish to topics and see things coming through, but nothing appears in my simulation.

If I try and also run without the rviz = false, then I get the below errors:

Hi @phillip.jr.hogan,

The black screen suggests that somehow the graphics are not allowed in the container.

Have you executed xhost +localhost on the host to allow the containers to access the X server?

xhost +localhost

Before running the launch file that launches Gazebo, could you try to export these variables first to see if the graphics appear (I’m not expert on those vars, but every now and then we find them on the forums)?

export QT_X11_NO_MITSHM=1
export LIBGL_ALWAYS_SOFTWARE=1

Also, before launching RViz, could you try:

export OGRE_RTT_MODE=Copy

If that doesn’t work, are you mounting the /tmp/.X11-unix folder inside the container? If so, does the value of the DISPLAY variable is the same as outside the container? If not the same and you are mounting that folder inside the container, please make sure the value of DISPLAY inside the container is the same as the variable outside the container.

Please let us know how far you can get.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.