GithubHelp home page GithubHelp logo

gstavrinos / ros-ez Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 0.0 247 KB

Docker hacks for quick and easy access to ROS2 and ROS1 along with their GUI applications like Gazebo and rViz without the need for a local installation

License: Apache License 2.0

Shell 100.00%
docker gazebo rocker ros2 ros2-humble rviz ros-noetic rviz2 ros ros-melodic

ros-ez's Introduction

Docker hacks for quick and easy access to ROS2 (foxy, humble) and ROS1 (melodic, noetic) along with their GUI applications like Gazebo and rViz without the need for a local installation

Requirements

  • docker
  • Linux (not necessarily Debian-based)
  • dialog (optionally for interactive terminal UI)

Instructions

  • Make sure your system satisfies all the requirements. The installer script tries to remain distro-agnostic, thus does not install anything.
  • Run the installer.bash script with a single argument with the rosez version you need to install. e.g. ./installer.bash ros2ez. You can also run it interactively with no arguments. For ros-ez versions < 1.7.0, you must use one of the ros_*installer.bash scripts. There are multiple, one for each supported ROS distribution.
  • Run . ~/.bashrc or open a new terminal.
  • Run ros2ez for ROS2 Humble, ros2ezf for ROS2 Foxy or rosez for ROS1 Noetic and rosezm for ROS1 Melodic followed by the command you want to run else. If no command is provided you will be thrown in a shell inside the image (useful when autocomplete is required).

Examples

ros2ez ros2 run teleop_twist_keyboard teleop_twist_keyboard cmd_vel:=racer_01/cmd_vel

or

rosez rosrun rviz rviz

Tips/Features/Changelog!

  • NVIDIA users should install the nvidia-container-toolkit that massively boosts performance inside docker containers.
  • If you encounter errors regarding your graphics card while trying to run the rosez or ros2ez script, try adding the fi or force-integrated flag, which will force usage of the integrated graphics card of your computer. This is, of course, not optimal, so update your drivers and try running the script again. Make sure that the flag is the first argument of your command. If this fails too, open an issue. For instance, the examples above can be executed with the integrated graphics card by running ros2ez fi ros2 run teleop_twist_keyboard teleop_twist_keyboard cmd_vel:=racer_01/cmd_vel and rosez fi rosrun rviz rviz respectively.
  • You can change or add default workspaces by editing the includes/ros*_ws.txt file. One directory per line.
  • Migrating from v1.0.0 to newer versions will most probably introduce some permission issues, since newer versions try to stay inside the user's permissions instead of root. A chown of your workspace(s) to your user should fix the problem.
  • [For versions >= v1.1.0] User configurable and system files have been separated, so you (most probably) should not mess with the internals folder.
  • [For versions <= v1.1.0] Running multiple ros*ez commands concurrently (in separate terminals) can introduce race conditions, especially in workspace building (colcon (ROS2) or catkin (ROS1)). Refrain from running ros*ez commands concurrently, but wait for build commands to finish.
  • [For versions >= v1.2.0] The new concurrency handling system allows for execution of multiple ros*ez commands concurrently (in separate terminals). The system uses lock files and tries to handle them effectively to avoid dangling ones. In the (rare?) case of a dangling lock file (essentially eternally waiting for a lock file to unlock), you should do one of the following solutions: The first one is to reboot your machine. The next time you boot up, your lock file will be older than your system's uptime, and be automatically removed. The second one is to use the clear-locks or cl flag during ros*ez execution. Keep in mind that if you generally use the force-integrated or fi flag, you willneed it here too. For instance, the next commands will remove ALL locks and then run the specified command ros2ez fi cl ros2 run teleop_twist_keyboard teleop_twist_keyboard cmd_vel:=racer_01/cmd_vel or for ros1 rosez cl fi rosrun rviz rviz. Note that the order of the flags is not important, but have to be placed before the required ros command.
  • [For versions >= v1.2.1] Users are now able to use their local git configuration (ssh keys etc) and bloom release, from within the ros*ez environment.
  • [For versions >= v1.2.2] There was a problem that was introduced in v1.2.1 regarding volumes and permissions for user configuration files in ssh, git and bloom. It is now fixed.
  • [For versions >= v1.2.3] The installer script now checks if the user is in the docker group, and if not adds them and prompts for reboot at the end of the installation.
  • [For versions >= v1.3.0] A ROS Melodic version is now available (with the rosezm command) and a much more robust locking mechanism is now in effect. If you experienced frequent lockouts or race conditions, this version should be more stable.
  • [For versions >= v1.4.0] All supported ROS versions (melodic/noetic/humble) now work on a completely persistent filesystem to save apt, library and other installations + all other user-defined changes on the container. Additionally, this version also supports audio, enabling users to play sounds through the rosez containers.
  • [For versions >= v1.5.0] The sc or skip-compilation flag is now supported, which completely bypasses rosdep and catkin/colcon builds for faster startup.
  • [For versions >= v1.6.0] A ROS2 Foxy version is now available (with the ros2ezf command). Its image comes with built-in ros1_bridge support for ez ROS1-ROS2 integration.
  • [For versions >= v1.6.1] A deletion script has been included inside the internal/deeper/ folder. It takes the version-to-delete as an argument. For example, bash delete_version.bash ros2ezf deletes the Foxy version for rosez.
  • [For versions >= v1.7.0] A new script to easily create systemd services was added. It can be used interactively using dialog or non-interactively by passing it 9 arguments. Running the create_rosez_systemd_service.bash with less than 9 args (but more than 0) will trigger a help message. Additionally the installation scripts have been merged into one, installer.bash. You can now use it interactively, or pass a single argument with the rosez version you need to install. e.g. ./installer.bash ros2ez
  • [For versions >= v2.0.0] Docker devices like sound and graphics are now manually handled. This version is NOT the same as the previous ones. This is a pretty substantial change, thus getting a major release. Externally nothing should change for the end user, but internally a lot has changed. OSRF's rocker is no longer utilized, making docker handling more versatile (but also fragile).
  • [For versions >= v2.0.1] Sound itegration is now working normally. The bug was introduced in v2.0.0.

Tested platforms

  • EndeavourOS
  • Fedora 35
  • Ubuntu 22.04
  • MX Linux 19.1

ros-ez's People

Contributors

gstavrinos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ros-ez's Issues

Investigate dangling volumes

It appears that untagged volumes keep getting generated and then left dangling, taking up too much disk space over time.

Migrate away from rocker...

rocker has been a great way to easily manage the execution, but the gpu handling has not been that great in general. I would pretty much prefer handling it manually and have full control of the processes.

Investigate alternative solutions to user assignment

Regarding #1, there are unsafe solutions like mount /etc/passwd after specifying the userid and group id on docker run OR create the user during the docker build command. I need to investigate the most elegant and less intrusive one.

The docker build is the "correct" one, but will need external arguments like $(id -u):$(id -g)

Update system

Notify users for newer versions but never automatically install them

Faster execution of the rosez environment

Investigate the possibility of adding a flag skip-compilation (sc) to skip the whole rosdep update/colcon build part of the entrypoint for faster entry and execution of the rosez commands

Automation feature

Enable users to run ros*ez* on boot.

This can prove quite difficult if it needs to be OS-agnostic, but the most popular solutions should be provided.

(I think all linux distributions support cronjobs for example.)

Error when starting ros2ez

Sometimes when I ran the command ros2ez it returns the following error.

Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/docker/api/client.py", line 268, in _raise_for_status
response.raise_for_status()
File "/usr/local/lib/python3.10/dist-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 409 Client Error: Conflict for url: http+docker://localhost/v1.42/images/rocker:os_detect_ros2_ez_latest?force=False&noprune=False
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/bin/rocker", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.10/dist-packages/rocker/cli.py", line 66, in main
dig = DockerImageGenerator(active_extensions, args_dict, base_image)
File "/usr/local/lib/python3.10/dist-packages/rocker/core.py", line 210, in init
self.dockerfile = generate_dockerfile(active_extensions, self.cliargs, base_image)
File "/usr/local/lib/python3.10/dist-packages/rocker/core.py", line 344, in generate_dockerfile
dockerfile_str += el.get_preamble(args_dict) + '\n'
File "/usr/local/lib/python3.10/dist-packages/rocker/nvidia_extension.py", line 118, in get_preamble
return em.expand(preamble, self.get_environment_subs(cliargs))
File "/usr/local/lib/python3.10/dist-packages/rocker/nvidia_extension.py", line 98, in get_environment_subs
detected_os = detect_os(cliargs['base_image'], print, nocache=cliargs.get('nocache', False))
File "/usr/local/lib/python3.10/dist-packages/rocker/os_detector.py", line 81, in detect_os
client.remove_image(image=tag_name)
File "/usr/local/lib/python3.10/dist-packages/docker/utils/decorators.py", line 19, in wrapped
return f(self, resource_id, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/docker/api/image.py", line 514, in remove_image
return self._result(res, True)
File "/usr/local/lib/python3.10/dist-packages/docker/api/client.py", line 274, in _result
self._raise_for_status(response)
File "/usr/local/lib/python3.10/dist-packages/docker/api/client.py", line 270, in _raise_for_status
raise create_api_error_from_http_exception(e) from e
File "/usr/local/lib/python3.10/dist-packages/docker/errors.py", line 39, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation) from e
docker.errors.APIError: 409 Client Error for http+docker://localhost/v1.42/images/rocker:os_detect_ros2_ez_latest?force=False&noprune=False: Conflict ("conflict: unable to remove repository reference "rocker:os_detect_ros2_ez_latest" (must force) - container b08d20fc871f is using its referenced image e39473376116")
touch: missing file operand
Try 'touch --help' for more information.
xauth: file nmerge does not exist
Using authority file nmerge
xauth: (stdin):1: unknown command "ffff"
xauth: (stdin):2: unknown command "ffff"
Executing:
sudo env /bin/bash

This happens mostly when I try to open multiple terminals and open ros to all of them at once. I ran a docker image list after the error and the images were the following.

koutris@koutris-System:~/Desktop$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
rocker os_detect_ros2_ez_latest 23f7537298cd 12 minutes ago 4.78GB
de3d11a6d367 12 minutes ago 4.78GB
12ee62987052 6 days ago 4.77GB
65080f65361b 6 days ago 4.77GB
845c9330add8 6 days ago 252MB
ros2_ez latest 3368a07606b9 6 days ago 4.77GB
3c2e7ac1272e 6 days ago 4.77GB
b33916cace85 6 days ago 4.77GB
666b34957dac 6 days ago 4.77GB
282ec15ba8f1 6 days ago 4.77GB
91a8896f6b98 6 days ago 4.77GB
snyk/snyk 4db3fcadc7e4 2 months ago 213MB
nvidia/opengl 1.0-glvnd-devel-ubuntu18.04 9d806b36b807 9 months ago 413MB
hello-world latest feb5d9fea6a5 17 months ago 13.3kB
python 3-slim-stretch 7691d3cb6cbc 3 years ago 155MB

after I run a docker image prune only the following remain and the error was fixed.

koutris@koutris-System:~/Desktop$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
rocker os_detect_ros2_ez_latest 23f7537298cd 14 minutes ago 4.78GB
de3d11a6d367 14 minutes ago 4.78GB
65080f65361b 6 days ago 4.77GB
ros2_ez latest 3368a07606b9 6 days ago 4.77GB
nvidia/opengl 1.0-glvnd-devel-ubuntu18.04 9d806b36b807 9 months ago 413MB
hello-world latest feb5d9fea6a5 17 months ago 13.3kB
python 3-slim-stretch 7691d3cb6cbc 3 years ago 155MB

I manage to recreate the error by running the bash ros2_installer.bash command when I was outside the folder.

bash ros-ez/ros2_installer.bash

ROS 2, ros-ez version 1.0.0, Ubuntu LTS 22.04

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.