Skip to content

Commit

Permalink
First working building. fix: colcon build because of catkin used in c…
Browse files Browse the repository at this point in the history
…makefiles.
  • Loading branch information
ML1907 committed Dec 19, 2024
1 parent 8fd2f4c commit 50ddd1c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 37 deletions.
52 changes: 27 additions & 25 deletions docker/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Dockerfile for base SVEA image
# Dockerfile for base SVEA image (ROS2 Jazzy Jalisco)
#
# Author: Kaj Munhoz Arfvidsson

# Dynamically set the base image using BUILD_TAG and ROSDISTRO
ARG BUILD_TAG
ARG ROSDISTRO
ARG WORKSPACE
Expand All @@ -12,37 +13,45 @@ ARG WORKSPACE

FROM ${BUILD_TAG:-ros:latest}

# Arguments for dynamic configuration
ARG ROSDISTRO
ARG WORKSPACE
ARG DEBIAN_FRONTEND=noninteractive

## Install dependencies from apt-get

RUN apt-get update -y && \
apt-get upgrade -y && \
# Install core dependencies using apt-get
RUN apt-get update -y && apt-get upgrade -y && \
apt-get install --no-install-recommends -y \
apt-utils lsb-release \
build-essential cmake \
git vim nano curl iputils-ping \
apt \
lsb-release \
build-essential \
cmake \
git \
vim \
nano \
curl \
inetutils-ping \
python3-tk \
python3-pip \
python3-numpy \
python3-matplotlib \
python3-catkin-tools \
&& \
python3 -m pip install -U pip && \
python3-colcon-common-extensions \
python3-rosdep && \
rm -rf /var/lib/apt/lists/*

## Create svea workspace

# Initialize rosdep for resolving dependencies
RUN rosdep init || echo "rosdep already initialized"
RUN rosdep update --rosdistro $ROSDISTRO

# Create the SVEA workspace
WORKDIR $WORKSPACE

# Need to copy src and util separately because docker COPY rules are iffy.
# https://docs.docker.com/engine/reference/builder/#copy
# Copy workspace files and utilities
COPY src ./src
COPY util ./util
COPY entrypoint requirements.txt ./

# Install ROS2 dependencies and Python packages
RUN cp -f entrypoint /ros_entrypoint.sh && \
apt-get update -y && \
rosdep update \
Expand All @@ -54,20 +63,13 @@ RUN cp -f entrypoint /ros_entrypoint.sh && \
--ignore-src \
-qry \
&& \
pip install -r requirements.txt && \
pip install -r requirements.txt --break-system-packages && \
rm -rf /var/lib/apt/lists/*

# Run catkin build on workspace (improves build speeds later on).
RUN catkin config \
--init \
--mkdirs \
--extend /opt/ros/$ROSDISTRO \
> /dev/null \
&& \
catkin build

## Container entrypoint (executes util/entrypoint)
# Build workspace
RUN colcon build --symlink-install

# Container entrypoint (executes util/entrypoint)
ENTRYPOINT ["/ros_entrypoint.sh"]

# bash is run by default when user starts
Expand Down
21 changes: 14 additions & 7 deletions entrypoint
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/bash
#
# This entrypoint script will be called everytime a container is started.
# This entrypoint script will be called every time a container is started.
#
# Author: Kaj Munhoz Arfvidsson

Expand All @@ -9,15 +9,22 @@ set -e
# Get project information
source util/config.sh

# Set ROS_IP etc. for e.g. rviz remote connection
# Set ROS_IP etc. for e.g., RViz remote connection
# https://stackoverflow.com/a/65912397
remote_ros() { source util/remote_ros.sh; }; remote_ros

# To build anything that has been added by volume...
catkin build
# Build the ROS2 workspace if files have been added or modified by volume
if [ -d "$WORKSPACE/src" ]; then
echo "Building the ROS2 workspace..."
. /opt/ros/$ROSDISTRO/setup.bash
colcon build --symlink-install --base-paths "$WORKSPACE"
fi

# https://github.com/osrf/docker_images/issues/114
printf "\nsource '$PWD/devel/setup.bash'" >> $HOME/.bashrc
# Source the ROS2 workspace setup file
if [ -f "$WORKSPACE/install/setup.bash" ]; then
printf "\nsource '$WORKSPACE/install/setup.bash'" >> $HOME/.bashrc
. "$WORKSPACE/install/setup.bash"
fi

# Execute the container's command
exec "$@"

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ pyubx2
geopy
utm
# This is for NMPC
casadi==3.5.5
casadi>=3.6.0,<4.0.0
8 changes: 4 additions & 4 deletions util/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ main() {

withdefault DEBUG "0"

withdefault ROSDISTRO "noetic"
withdefault ROSDISTRO "jazzy"
withdefault WORKSPACE "/svea_ws"
withdefault REPOSITORY_PATH "$(climb entrypoint)"
withdefault REPOSITORY_NAME "$(basename "$REPOSITORY_PATH")"
withdefault BUILD_CONFIG "base"

withdefault BUILD_CONFIG "default"
if [ "$BUILD_CONFIG" = "default" ]; then
# building for host platform
withdefault BUILD_PLATFORM "$(uname -m)"
Expand All @@ -32,8 +32,8 @@ main() {
withdefault BUILD_PLATFORM "$(uname -m)"
withdefault BUILD_CONTEXT "$REPOSITORY_PATH"
withdefault BUILD_FILE "docker/Dockerfile.base"
withdefault BUILD_TAG "ros:$ROSDISTRO"
withdefault IMAGE_TAG "ghcr.io/kth-sml/svea:latest"
withdefault BUILD_TAG "osrf/ros:${ROSDISTRO}-desktop"
withdefault IMAGE_TAG "ghcr.io/kth-sml/svea-base:${ROSDISTRO}"
withdefault IMAGE_PUSH "0"
elif [ "$BUILD_CONFIG" = "base-amd64" ]; then
# building for x86_64
Expand Down

0 comments on commit 50ddd1c

Please sign in to comment.