ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

I a smaller ros2.repos options available?

asked 2022-01-06 14:25:35 -0500

variable gravatar image

updated 2022-01-06 20:38:59 -0500

osilva gravatar image

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

Following https://docs.ros.org/en/foxy/Installa...

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/fc0...

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 https://answers.ros.org/question/3252... 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/ros...

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
edit retag flag offensive close merge delete

Comments

1

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.

gvdhoorn gravatar image gvdhoorn  ( 2022-01-07 04:32:37 -0500 )edit

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?

variable gravatar image variable  ( 2022-01-07 10:20:06 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
2

answered 2022-01-11 10:11:56 -0500

jonipol gravatar image

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_...

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

edit flag offensive delete link more
2

answered 2022-01-09 18:27:10 -0500

ruffsl gravatar image

updated 2022-01-09 18:34:07 -0500

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/rele...

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.

edit flag offensive delete link more
1

answered 2022-03-17 19:06:57 -0500

jpace121 gravatar image

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.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2022-01-06 14:25:35 -0500

Seen: 347 times

Last updated: Mar 17 '22