Giter Site home page Giter Site logo

Comments (3)

keenanjohnson avatar keenanjohnson commented on May 23, 2024

Chatting with @nnmm about this, we've made some progress. Documenting here for the record.

Two issues discover with my process above:

  1. I was using the Base version of Ros instead of Desktop, which seemed to be missing some important things like colcon-package-selection. I resolved this by switching to ROS Desktop. I also just decided to switch to the official ROS2 Foxy Docker image.
  2. The colcon build --packages-up-to rclrs_examples command was being run in the / dir instead of the /src/ dir.

I resolved both of these issues and created this Dockerfile:

# Ros2 Foxy runs on ubuntu focal
FROM ros:foxy as base
ARG DEBIAN_FRONTEND=noninteractive

##########################
## Rust Install
##########################
# Install Dependancies
RUN apt-get update && apt-get install -y \
    curl \
    && rm -rf /var/lib/apt/lists/*

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.59.0 -y
ENV PATH=/root/.cargo/bin:$PATH

##########################
## ros2_rust install
##########################
# Install Dependancies
RUN apt-get update && apt-get install -y \
    python3-vcstool \
    libclang-dev \
    clang \
    python3.9 \
    python3.9-dev \
    python3-pip \
    git \
    && rm -rf /var/lib/apt/lists/*

RUN pip install --upgrade pytest colcon-package-selection

# Install the colcon-cargo and colcon-ros-cargo plugins
RUN pip install git+https://github.com/colcon/colcon-cargo.git git+https://github.com/colcon/colcon-ros-cargo.git
# Install the cargo-ament-build plugin
RUN cargo install cargo-ament-build

# Install the ros2_rust package
RUN mkdir src
RUN git clone https://github.com/ros2-rust/ros2_rust.git src/ros2_rust
RUN vcs import src < src/ros
```2_rust/ros2_rust_foxy.repos
RUN . /opt/ros/foxy/setup.sh
WORKDIR /src/
RUN colcon build --packages-up-to rclrs_examples

Building this image results in the following error:

[main]     Step 14/18 : RUN colcon build --packages-up-to rclrs_examples
[main]      ---> Running in 4e6353cdfe09
[main]     Starting >>> rosidl_runtime_rs
[main]     --- stderr: rosidl_runtime_rs
[main]     Traceback (most recent call last):
[main]       File "/usr/lib/python3/dist-packages/colcon_core/executor/__init__.py", line 91, in __call__
[main]         rc = await self.task(*args, **kwargs)
[main]       File "/usr/lib/python3/dist-packages/colcon_core/task/__init__.py", line 93, in __call__
[main]         return await task_method(*args, **kwargs)
[main]       File "/usr/local/lib/python3.8/dist-packages/colcon_ros_cargo/task/ament_cargo/[build.py](http://build.py/)", line 68, in build
[main]         return await super(AmentCargoBuildTask, self).build(
[main]       File "/usr/local/lib/python3.8/dist-packages/colcon_cargo/task/cargo/[build.py](http://build.py/)", line 49, in build
[main]         rc = await self._build(args, env)
[main]       File "/usr/local/lib/python3.8/dist-packages/colcon_ros_cargo/task/ament_cargo/[build.py](http://build.py/)", line 84, in _build
[main]         new_package_paths = find_installed_cargo_packages(env)
[main]       File "/usr/local/lib/python3.8/dist-packages/colcon_ros_cargo/task/ament_cargo/[build.py](http://build.py/)", line 142, in find_installed_cargo_packages
[main]         for prefix in env['AMENT_PREFIX_PATH'].split(os.pathsep):
[main]     KeyError: 'AMENT_PREFIX_PATH'
[main]     ---
[main]     Failed   <<< rosidl_runtime_rs [0.02s, exited with code 1]
[main]     
[main]     Summary: 0 packages finished [0.51s]
[main]       1 package failed: rosidl_runtime_rs
[main]       1 package had stderr output: rosidl_runtime_rs
[main]       9 packages not processed
[main]     'AMENT_PREFIX_PATH'
[main]     
[main]     Removing intermediate container 4e6353cdfe09
[main]     The command '/bin/sh -c colcon build --packages-up-to rclrs_examples' returned a non-zero code: 1

from ros2_rust.

keenanjohnson avatar keenanjohnson commented on May 23, 2024

Had to combine the ROS overlay command with the colcon build command to satisfy Docker, but that has resulted in a new error:

[main]     Starting >>> rclrs_examples
[main]     --- stderr: rclrs_examples
[main]     thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-ament-build-0.1.2/src/main.rs:33:62
[main]     note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[main]     ---
[main]     Failed   <<< rclrs_examples [0.21s, exited with code 101]
[main]     
[main]     Summary: 9 packages finished [1min 28s]
[main]       1 package failed: rclrs_examples
[main]       2 packages had stderr output: rclrs rclrs_examples
[main]     Removing intermediate container 69cf8b900e43
[main]     The command '/bin/sh -c . /opt/ros/foxy/setup.sh && colcon build --packages-up-to rclrs_examples' returned a non-zero code: 101

Complete Dockerfile

# Ros2 Foxy runs on ubuntu focal
FROM ros:foxy as base
ARG DEBIAN_FRONTEND=noninteractive

##########################
## Rust Install
##########################
# Install Dependancies
RUN apt-get update && apt-get install -y \
    curl \
    && rm -rf /var/lib/apt/lists/*

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.59.0 -y
ENV PATH=/root/.cargo/bin:$PATH

##########################
## ros2_rust install
##########################
# Install Dependancies
RUN apt-get update && apt-get install -y \
    python3-vcstool \
    libclang-dev \
    clang \
    python3.9 \
    python3.9-dev \
    python3-pip \
    git \
    && rm -rf /var/lib/apt/lists/*

RUN pip install --upgrade pytest colcon-package-selection

# Install the colcon-cargo and colcon-ros-cargo plugins
RUN pip install git+https://github.com/colcon/colcon-cargo.git git+https://github.com/colcon/colcon-ros-cargo.git
# Install the cargo-ament-build plugin
RUN cargo install cargo-ament-build

# Install the ros2_rust package
RUN mkdir src
RUN git clone https://github.com/ros2-rust/ros2_rust.git src/ros2_rust
RUN vcs import src < src/ros2_rust/ros2_rust_foxy.repos

# Build rclrs
WORKDIR /src/
RUN . /opt/ros/foxy/setup.sh && colcon build --packages-up-to rclrs_examples

from ros2_rust.

keenanjohnson avatar keenanjohnson commented on May 23, 2024

This error was related to a bug in cargo-ament-build 0.1.2.

@nnmm pushed a fix in 0.1.3 https://crates.io/crates/cargo-ament-build/0.1.3 which has allowed me to compile with the dockerfile above!

from ros2_rust.

Related Issues (20)

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.