1

Rosanswers logo

I am attempting to build ros2 Foxy on Ubuntu (in a docker container).

Following https://docs.ros.org/en/foxy/Installation/Ubuntu-Development-Setup.html#

wget https://raw.githubusercontent.com/ros2/ros2/foxy/ros2.repos

vcs import src < ros2.repos

I see this has quite a lot of repos https://github.com/ros2/ros2/blob/fc010c9a297eceaedb398213dea14d5ad5d67844/ros2.repos

My resulting docker image was over 2GB (starting from a base 500GB image.

Are there any collections of ros2.repos that just include the basics to run beginner tutorials?

I've seen the question Minimal ROS2 Installation but the answers aren't really clear on how this would be done in the build tutorial, what would be installed, or how to "use the tarballs option". The file generated by rosins tall_generator for ros_base is the same as https://raw.githubusercontent.com/ros2/ros2/foxy/ros2.repos

The following is a segment of my Dockerfile:

RUN mkdir -p ${ROS_ROOT}/src
ARG ROS_PKG=ros_base

RUN cd ${ROS_ROOT} &&
rosinstall_generator --deps --rosdistro $
{ROS_DISTRO} ${ROS_PKG}
> ros2.$
{ROS_DISTRO}.${ROS_PKG}.rosinstall &&
cat ros2.$
{ROS_DISTRO}.${ROS_PKG}.rosinstall &&
vcs import src < ros2.$
{ROS_DISTRO}.${ROS_PKG}.rosinstall

# install dependencies using rosdep

RUN apt-get update &&
cd ${ROS_ROOT} &&
rosdep init &&
rosdep update &&
rosdep install -y
--ignore-src
--from-paths src
--rosdistro $
{ROS_DISTRO} &&
rm -rf /var/lib/apt/lists/* &&
apt-get clean

# build it!

RUN colcon build --merge-install &&
rm -rf ${ROS_ROOT}/src &&
rm -rf $
{ROS_ROOT}/logs &&
rm -rf ${ROS_ROOT}/build &&
rm $
{ROS_ROOT}/*.rosinstall


Originally posted by variable on ROS Answers with karma: 21 on 2022-01-06

Post score: 2


Original comments

Comment by gvdhoorn on 2022-01-07:
I would suggest to clarify why you are building ROS 2 from source on a Debian/Ubuntu based OS where there are binary packages available.

Comment by variable on 2022-01-07:
The main reason is that I am stuck on Ubuntu 18.04 because of driver issues (Nvidia jetson). I am at the beginning of a project and would prefer to not use Eloquent since it is already EOL. I also do not need other DDS frameworks for now - only Fast-RTPS. Is there binary package solution that would work for me?

Lucas Walter
  • 3,337
  • 1
  • 14
  • 19

3 Answers3

0

Rosanswers logo

As for building a minimal version of ros2 from source, you could curtail the number of packages by using colcon's package selection to filter out the prerequisite dependencies specific to your application.

https://colcon.readthedocs.io/en/released/reference/package-selection-arguments.html

For example, you can checkout this Dockerfile in the nav2 repo that builds the project, including ros2 from source:


    # list the packages we what to build
    RUN colcon list --names-only | cat >> /opt/packages.txt
    ...
# remove the packages we don't need
RUN ...
    colcon list --paths-only \
      --packages-skip-up-to  \
        $(cat packages.txt | xargs) \
      | xargs rm -rf

This is made practical to build by removing all skippable packages from the workspace; packages that are irrelevant i.e. non-transient dependencies to the top-level nav2 overlay. This also ensures tools like rosdep only install system dependencies for the fewer number packages that remain. This helps save build time, as well as what you care about, reducing the eventual image size. This could also be achieved via COLCON_IGNORE marker files, but the approach above simply deletes the source folders for irrelevant packages to reduce opportunities for busting the docker build cache.

Just be sure to know what your minimal dependency footprint will be before embarking on this approach, as it's a fairly lengthy rebuild if you find out are missing some ros2 core package, and need to add it your top most package.xml file, potentially breaking the existing build cache for earlier layers/stages in your docker image.


Originally posted by ruffsl with karma: 1094 on 2022-01-09

This answer was NOT ACCEPTED on the original site

Post score: 2

ruffsl
  • 321
  • 1
  • 2
  • 1
0

Rosanswers logo

I have not done the building from source, so I cannot comment about that nor how to build just the absolute necessary things. But here I will present an alternative way to get started pretty quickly.

From comments I picked up that you are working on Jetson. For Jetson there are existing docker images that have ros pre-built. You can find some info from https://nvidia-ai-iot.github.io/ros2_jetson/ros2-jetson-dockers/

For example you can use the following image as a base for your jetson container. It has some extras like pytorch but I think that they also offer images that don't have the machine learning packages pre-installed.

FROM dustynv/ros:foxy-pytorch-l4t-r32.5.0

Note: if you use this image as base, it has cyclonedds as default rmw, so you have to change it if you want fastrtps. Adding following line to your Dockerfile should be enough. ENV RMW_IMPLEMENTATION=rmw_fastrtps_cpp


Originally posted by jonipol with karma: 21 on 2022-01-11

This answer was NOT ACCEPTED on the original site

Post score: 2

0

Rosanswers logo

I would use rosinstall_generator to generate a minimal .repos file to use instead.

For example, running

rosinstall_generator ros_base --format repos --rosdistro foxy --deps > base.repos

will generate the .repos file base.repos with only the source for the packages in the ros_base variant (as defined here) for Foxy.


Originally posted by jpace121 with karma: 56 on 2022-03-17

This answer was NOT ACCEPTED on the original site

Post score: 1