Skip to content

Commit

Permalink
Merge branch 'feature/docker-compose' into ros2
Browse files Browse the repository at this point in the history
  • Loading branch information
EirikKolas committed Oct 12, 2023
2 parents 4dbeb82 + 85c40bf commit 15ba5ba
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "ouster-sdk"]
path = ouster-ros/ouster-sdk
url = https://github.com/ouster-lidar/ouster_example.git
ignore = untracked
71 changes: 41 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,58 +1,69 @@
# variable for distro name
ARG ROS_DISTRO=rolling

# import image using distro name
FROM ros:${ROS_DISTRO}-ros-core AS build-env

# assign environment variables
ENV DEBIAN_FRONTEND=noninteractive \
BUILD_HOME=/var/lib/build \
OUSTER_ROS_PATH=/opt/ros2_ws/src/ouster-ros

# install dependant packages
RUN set -xue \
# Turn off installing extra packages globally to slim down rosdep install
&& echo 'APT::Install-Recommends "0";' > /etc/apt/apt.conf.d/01norecommend \
&& apt-get update \
&& apt-get install -y \
build-essential \
cmake \
fakeroot \
dpkg-dev \
debhelper \
python3-rosdep \
python3-rospkg \
python3-bloom \
python3-colcon-common-extensions
# Turn off installing extra packages globally to slim down rosdep install
&& echo 'APT::Install-Recommends "0";' > /etc/apt/apt.conf.d/01norecommend \
&& apt-get update \
&& apt-get install -y \
build-essential \
cmake \
fakeroot \
dpkg-dev \
debhelper \
python3-rosdep \
python3-rospkg \
python3-bloom \
python3-colcon-common-extensions

# Set up non-root build user
ARG BUILD_UID=1000
ARG BUILD_GID=${BUILD_UID}

RUN set -xe \
&& groupadd -o -g ${BUILD_GID} build \
&& useradd -o -u ${BUILD_UID} -d ${BUILD_HOME} -rm -s /bin/bash -g build build
&& groupadd -o -g ${BUILD_GID} build \
&& useradd -o -u ${BUILD_UID} -d ${BUILD_HOME} -rm -s /bin/bash -g build build

# Set up build environment
COPY --chown=build:build . $OUSTER_ROS_PATH

RUN set -xe \
&& apt-get update \
&& rosdep init \
&& rosdep update --rosdistro=$ROS_DISTRO \
&& rosdep install --from-paths $OUSTER_ROS_PATH -y --ignore-src
# rosdep install
RUN set -xe \
&& apt-get update \
&& rosdep init \
&& rosdep update --rosdistro=$ROS_DISTRO \
&& rosdep install --from-paths $OUSTER_ROS_PATH -y --ignore-src


USER build:build
WORKDIR ${BUILD_HOME}

RUN set -xe \
&& mkdir src \
&& cp -R $OUSTER_ROS_PATH ./src
# copy source files to src dir
RUN set -xe \
&& mkdir src \
&& cp -R $OUSTER_ROS_PATH ./src


FROM build-env

SHELL ["/bin/bash", "-c"]

RUN source /opt/ros/$ROS_DISTRO/setup.bash && colcon build \
--symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations"
RUN source /opt/ros/$ROS_DISTRO/setup.bash \
&& colcon build \
--symlink-install \
-executor sequential \
--cmake-args \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations"

RUN source /opt/ros/$ROS_DISTRO/setup.bash && colcon test \
--ctest-args tests ouster_ros --rerun-failed --output-on-failure
Expand All @@ -61,7 +72,7 @@ RUN source /opt/ros/$ROS_DISTRO/setup.bash && colcon test \
#
# Usage: docker run --rm -it ouster-ros [sensor.launch parameters ..]
#
ENTRYPOINT ["bash", "-c", "set -e \
&& source ./install/setup.bash \
&& ros2 launch ouster_ros sensor.launch.xml \"$@\" \
", "ros-entrypoint"]
ENTRYPOINT ["bash", "-c", "set -e \
&& source ./install/setup.bash \
&& ros2 launch ouster_ros sensor.launch.xml \"$@\" \
", "ros-entrypoint"]
33 changes: 33 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3.8'

services:

freya-lidar:
# os1-122007000043
container_name: ouster-lidar-freya
image: ghcr.io/vortexntnu/ouster-lidar-ros2-driver-humble:2023-10-09
ports:
- 7502:7502/udp # lidar output port
entrypoint: ["bash", "-c", "set -e \
&& source ./install/setup.bash \
&& ros2 launch ouster_ros sensor.launch.xml \
sensor_hostname:=169.254.154.82 \
lidar_port:=7502 \
viz:=false
", "ros-entrypoint"]



test-lidar:
# os1-122007000043
container_name: ouster-lidar-test
image: ghcr.io/vortexntnu/ouster-lidar-ros2-driver-humble:2023-10-09
ports:
- 7502:7502/udp # lidar output port
entrypoint: ["bash", "-c", "set -e \
&& source ./install/setup.bash \
&& ros2 launch ouster_ros sensor.launch.xml \
sensor_hostname:=10.0.0.122 \
lidar_port:=7502 \
viz:=false
", "ros-entrypoint"]
2 changes: 1 addition & 1 deletion ouster-ros/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<depend>pcl_ros</depend>
<depend>pcl_conversions</depend>
<depend>std_srvs</depend>
<depend>libglfw3-dev</depend>
<depend>libglfw3-dev</depend> <!-- added, needed -->

<build_depend>libjsoncpp-dev</build_depend>
<build_depend>eigen</build_depend>
Expand Down

0 comments on commit 15ba5ba

Please sign in to comment.