Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ visual odometry to a [BlueRobotics BlueROV2](https://www.bluerobotics.com) runni
* [ardupilot_gazebo](https://github.com/ArduPilot/ardupilot_gazebo/tree/ros2)
* [orb_slam3_ros](https://github.com/clydemcqueen/orb_slam3_ros); this includes ORB_SLAM3

See [orca_bridge](orca_bridge/README.md) for more details.

See the [Dockerfile](docker/Dockerfile) for details.

## Build and Run

Build a docker image, then run it:
~~~
cd docker
./build.sh
./run.sh
./build.sh sim
./run.sh sim nvidia
~~~

This is a dev container, so the orca5 directory will be mounted inside the container.
Expand All @@ -46,7 +44,7 @@ ORB_SLAM3 should initialize and start tracking the seafloor.

Open a second terminal into the container:
~~~
docker exec -it orca5 /bin/bash
docker exec -it orca5_sim /bin/bash
~~~

Launch mavproxy as the GCS:
Expand All @@ -59,15 +57,10 @@ ArduSub will initialize and start sending MAVLink messages to the SLAM bridge no
In response, the bridge node will start sending visual odometry messages to ArduSub.
Wait for these messages from mavproxy:
~~~
AP: EKF3 IMU1 fusing odometry
AP: EKF3 IMU0 fusing odometry
AP: EKF3 IMU1 started relative aiding
AP: EKF3 IMU0 started relative aiding
AP: EKF3 IMU1 is using external nav data
AP: EKF3 IMU0 is using external nav data
~~~

Note: it may take ~30 seconds for the ArduSub EKF to learn the gyro bias before it will accept
the visual odometry messages.

Mavproxy is interactive, so we can execute commands. Arm the motors:
~~~
MANUAL> arm throttle
Expand Down
7 changes: 7 additions & 0 deletions common.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Repositories required by all build targets
repositories:

orb_slam3_ros:
type: git
url: https://github.com/clydemcqueen/orb_slam3_ros.git
version: cda4ae6
188 changes: 132 additions & 56 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
###############################
# base stage, common to all targets
###############################

FROM osrf/ros:jazzy-desktop AS base

ARG USERNAME=orca5
Expand All @@ -7,7 +11,6 @@ ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get upgrade -y

# Install a few handy tools
RUN apt-get update \
&& apt-get -y --quiet --no-install-recommends install \
bash-completion \
Expand All @@ -16,32 +19,98 @@ RUN apt-get update \
gnupg \
iputils-ping \
lsb-release \
libglvnd0 \
libgl1 \
libglx0 \
libegl1 \
libxext6 \
libx11-6 \
python3-venv \
software-properties-common \
sudo \
wget \
vim \
&& rm -rf /var/lib/apt/lists/*

# Create a non-root user
# Required for ardupilot install, but generally a good idea
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& echo "\n# Added by orca5 Dockerfile:" >> /home/$USERNAME/.bashrc \
&& echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc

# Switch to our new user
USER $USERNAME

# install-prereqs-ubuntu.sh looks at $USER
ENV USER=$USERNAME

# Create colcon workspace and the mount point for orca5
WORKDIR /home/$USERNAME
RUN mkdir -p colcon_ws/src/orca5

# Get common repos
WORKDIR /home/$USERNAME/colcon_ws/src
COPY --chown=$USER_UID:$USER_GID common.repos orca5
RUN vcs import --recursive < orca5/common.repos

# Copy orca5 package.xml files
WORKDIR /home/$USERNAME/colcon_ws
COPY --chown=$USER_UID:$USER_GID orca_bridge/package.xml src/orca5/orca_bridge/
COPY --chown=$USER_UID:$USER_GID orca_bringup/package.xml src/orca5/orca_bringup/
COPY --chown=$USER_UID:$USER_GID orca_msgs/package.xml src/orca5/orca_msgs/

# Run rosdep over all repos
# Fun fact: rosdep will automatically elevate permissions, but apt-get will not, so it requires sudo
WORKDIR /home/$USERNAME/colcon_ws
RUN sudo apt-get update \
&& rosdep update \
&& rosdep install -y --from-paths . --ignore-src

# Do not build orca5 yet
WORKDIR /home/$USERNAME/colcon_ws
RUN touch src/orca5/COLCON_IGNORE

# Build everything so far
WORKDIR /home/$USERNAME/colcon_ws
RUN [ "/bin/bash" , "-c" , "\
source /opt/ros/jazzy/setup.bash \
&& colcon build --event-handlers console_direct+" ]

# Copy orca5 requirements.txt file
WORKDIR /home/$USERNAME/colcon_ws
COPY --chown=$USER_UID:$USER_GID requirements.txt src/orca5/

# Set up the Python environment
WORKDIR /home/$USERNAME/colcon_ws
RUN python3 -m venv venv --system-site-packages \
&& touch venv/COLCON_IGNORE \
&& . venv/bin/activate \
&& pip install -r src/orca5/requirements.txt

# Configure the shell environment
RUN echo "source /home/$USERNAME/colcon_ws/install/setup.bash" >> /home/$USERNAME/.bashrc

# Create a mount point for orca5 source, this will shadow the existing orca5 directory
VOLUME /home/$USERNAME/colcon_ws/src/orca5

###############################
# sim target
###############################

FROM base AS sim

# Switch to root to install stuff
USER root

# Install Gazebo Harmonic for use with ROS2 Jazzy
RUN apt-get update \
&& apt-get -y --quiet --no-install-recommends install ros-jazzy-ros-gz \
&& rm -rf /var/lib/apt/lists/*

# Install NVIDIA software
RUN apt-get update \
&& apt-get -y --quiet --no-install-recommends install \
libglvnd0 \
libgl1 \
libglx0 \
libegl1 \
libxext6 \
libx11-6 \
&& rm -rf /var/lib/apt/lists/* \
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=graphics,utility,compute
ENV QT_X11_NO_MITSHM=1

# Install some ardupilot and ardupilot_gazebo prereqs
# Install ardupilot and ardupilot_gazebo prereqs
RUN apt-get update \
&& apt-get -y --quiet --no-install-recommends install \
python3-pip \
Expand All @@ -64,18 +133,8 @@ RUN curl https://packages.osrfoundation.org/gazebo.gpg --output /usr/share/keyri
# Ref https://github.com/ArduPilot/ardupilot_gazebo#Rosdep
RUN wget https://raw.githubusercontent.com/osrf/osrf-rosdep/master/gz/00-gazebo.list -O /etc/ros/rosdep/sources.list.d/00-gazebo.list

# Create a non-root user
# Required for ardupilot install, but generally a good idea
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& echo "\n# Added by orca5 Dockerfile:" >> /home/$USERNAME/.bashrc \
&& echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc

# Switch to our new user
# Switch back to new user
USER $USERNAME
ENV USER=$USERNAME

# Clone ArduSub code
WORKDIR /home/$USERNAME
Expand All @@ -99,17 +158,12 @@ RUN modules/waf/waf-light configure --board sitl \
# Build for Gazebo Harmonic, define this before building ardupilot_gazebo
ENV GZ_VERSION=harmonic

# Create colcon workspace and the mount point for orca5
WORKDIR /home/$USERNAME
RUN mkdir -p colcon_ws/src/orca5

# Get workspace repos
# Get sim repos
WORKDIR /home/$USERNAME/colcon_ws/src
COPY --chown=$USER_UID:$USER_GID workspace.repos orca5
RUN vcs import --recursive < orca5/workspace.repos
COPY --chown=$USER_UID:$USER_GID sim.repos orca5
RUN vcs import --recursive < orca5/sim.repos

# Run rosdep over workspace repos
# Fun fact: rosdep will automatically elevate permissions, but apt-get will not, so it requires sudo
# Run rosdep over sim repos
WORKDIR /home/$USERNAME/colcon_ws
RUN sudo apt-get update \
&& rosdep update \
Expand All @@ -121,32 +175,54 @@ RUN [ "/bin/bash" , "-c" , "\
source /opt/ros/jazzy/setup.bash \
&& colcon build --event-handlers console_direct+" ]

# Copy orca5 package.xml files
COPY --chown=$USER_UID:$USER_GID orca_bridge/package.xml src/orca5/orca_bridge/
COPY --chown=$USER_UID:$USER_GID orca_bringup/package.xml src/orca5/orca_bringup/
COPY --chown=$USER_UID:$USER_GID orca_msgs/package.xml src/orca5/orca_msgs/
# Configure the shell environment
RUN echo "export PATH=\"/home/$USERNAME/ardupilot/build/sitl/bin:\$PATH\"" >> /home/$USERNAME/.bashrc

# Use bash as the default shell
SHELL ["/bin/bash", "-c"]
ENTRYPOINT ["/bin/bash"]

###############################
# hw target (assumes CPU)
###############################

FROM base AS hw

# Switch to root to install stuff
USER root

# Install gscam2 prereqs
RUN apt-get update \
&& apt-get -y --quiet --no-install-recommends install \
libgstreamer1.0-0 \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
gstreamer1.0-tools \
gstreamer1.0-x \
&& rm -rf /var/lib/apt/lists/*

# Switch back to new user
USER $USERNAME

# Get hw repos
WORKDIR /home/$USERNAME/colcon_ws/src
COPY --chown=$USER_UID:$USER_GID hw.repos orca5
RUN vcs import --recursive < orca5/hw.repos

# Run rosdep over orca5 package.xml files
# Run rosdep over hw repos
WORKDIR /home/$USERNAME/colcon_ws
RUN sudo apt-get update \
&& rosdep update \
&& rosdep install -y --from-paths . --ignore-src

# Copy orca5 requirements.txt file
COPY --chown=$USER_UID:$USER_GID requirements.txt src/orca5/

# Set up the Python environment
RUN python3 -m venv venv --system-site-packages \
&& touch venv/COLCON_IGNORE \
&& . venv/bin/activate \
&& pip install -r src/orca5/requirements.txt

# Configure the shell environment
RUN echo "export PATH=\"/home/$USERNAME/ardupilot/build/sitl/bin:\$PATH\"" >> /home/$USERNAME/.bashrc \
&& echo "source /home/$USERNAME/colcon_ws/install/setup.bash" >> /home/$USERNAME/.bashrc

# Create a mount point for orca5 source, this will shadow the files we copied
VOLUME /home/$USERNAME/colcon_ws/src/orca5
# Build everything so far
WORKDIR /home/$USERNAME/colcon_ws
RUN [ "/bin/bash" , "-c" , "\
source /opt/ros/jazzy/setup.bash \
&& colcon build --event-handlers console_direct+" ]

# Use bash as the default shell
SHELL ["/bin/bash", "-c"]
Expand Down
19 changes: 17 additions & 2 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
#!/usr/bin/env bash

# Usage:
# ./build.sh <target>

if [ -z "$1" ]; then
echo "Error: <target> argument required."
echo "Usage: ./build.sh <target>"
echo "where <target> can be:"
echo " sim: includes Gazebo and ArduSub"
echo " hw: minimal install for topside computer"
exit 1
fi

TARGET=$1
TAG="orca5:${TARGET}"

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

cd $DIR
cd $DIR || exit

# --progress-plain will show more output, handy for debugging
docker build --progress=plain -f $DIR/Dockerfile -t orca5:latest ..
docker build --progress=plain --target ${TARGET} -f $DIR/Dockerfile -t ${TAG} ..
Loading