Skip to content

Commit

Permalink
add docker-compose-debug.yaml for run_test debug mode
Browse files Browse the repository at this point in the history
Signed-off-by: Daisuke Sato <[email protected]>
  • Loading branch information
daisukes committed Mar 14, 2024
1 parent a8c48de commit 2f52b2f
Show file tree
Hide file tree
Showing 4 changed files with 209 additions and 3 deletions.
8 changes: 6 additions & 2 deletions cabot_navigation2/test/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ def main():

if not options.module:
parser.print_help()
sys.exit(0)
sys.exit(1)

logger = logging.getLogger()
logger.setLevel(logging.DEBUG if options.debug else logging.INFO)
Expand All @@ -877,7 +877,11 @@ def main():

tester = Tester(node)
tester.set_evaluator(evaluator)
mod = importlib.import_module(options.module)
try:
mod = importlib.import_module(options.module)
except ModuleNotFoundError:
logger.error(f"{options.module} is not found.")
sys.exit(1)
func_pat = None
if options.func:
try:
Expand Down
35 changes: 35 additions & 0 deletions docker-compose-debug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (c) 2024 Carnegie Mellon University
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

version: "2.3"


services:
debug:
extends:
file: docker-compose-common.yaml
service: navigation
build:
context: ./docker/ros2
dockerfile: Dockerfile.debug
environment:
- CABOT_GAZEBO=1
- CABOT_USE_SIM_TIME=1
- CABOT_TOUCH_ENABLED=${CABOT_TOUCH_ENABLED:-false}
167 changes: 167 additions & 0 deletions docker/ros2/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# Copyright (c) 2020, 2023 Carnegie Mellon University
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

ARG PREFIX=cabot
ARG FROM_IMAGE=${PREFIX}__jammy-humble-custom-mesa

# build underlay
FROM ${FROM_IMAGE} as cache

ENV UNDERLAY_WS=/opt/underlay_ws

RUN mkdir -p $UNDERLAY_WS/src
COPY ./tf2_web_republisher $UNDERLAY_WS/src/tf2_web_republisher

WORKDIR $UNDERLAY_WS

# copy package.xml files with parent directories for cache
RUN find . -name "src" -type d \
-mindepth 1 -maxdepth 2 -printf '%P\n' \
| xargs -I % mkdir -p /tmp/opt/% && \
find . -name "package.xml" \
| xargs cp --parents -t /tmp/opt && \
find . -name "COLCON_IGNORE" \
| xargs cp --parents -t /tmp/opt || true

RUN apt update && rosdep update && rosdep install -q -y \
--from-paths src \
--ignore-src

RUN . /opt/custom_ws/install/setup.sh && \
colcon build --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo


FROM ${FROM_IMAGE} as build
ENV ROS_DISTRO=humble
ARG TZ=UTC
ENV TZ=$TZ
RUN sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ | sudo tee /etc/timezone
ENV UNDERLAY_WS=/opt/underlay_ws

WORKDIR $UNDERLAY_WS

COPY --from=cache $UNDERLAY_WS/install $UNDERLAY_WS/install
# copy package.xml files from cache
COPY --from=cache /tmp/opt/src $UNDERLAY_WS/src

RUN apt update && rosdep update && rosdep install -q -y \
--from-paths src \
--ignore-src

ARG ROS_DISTRO

# TODO replace with rosdep install
RUN apt update && \
apt install -y --no-install-recommends \
bc \
libqt5svg5-dev \
libzmq3-dev \
libdw-dev \
libyaml-cpp-dev \
libomp-dev \
libpcl-dev \
python3-pykdl \
python3-sklearn \
python3-venv \
qtbase5-dev \
ros-$ROS_DISTRO-diagnostic-aggregator \
ros-$ROS_DISTRO-gazebo-msgs \
ros-$ROS_DISTRO-joint-state-publisher \
ros-$ROS_DISTRO-joint-state-publisher-gui \
ros-$ROS_DISTRO-navigation2 \
ros-$ROS_DISTRO-rosidl-runtime-cpp \
# pcl-ros is not ported yet
# # ros-$ROS_DISTRO-pcl-msgs \
# # ros-$ROS_DISTRO-pcl-ros \
ros-$ROS_DISTRO-pointcloud-to-laserscan \
ros-$ROS_DISTRO-realsense2-description \
ros-$ROS_DISTRO-robot-localization \
ros-$ROS_DISTRO-geographic-msgs \
libgeographic-dev \
# workaround end
ros-$ROS_DISTRO-rosbridge-server \
ros-$ROS_DISTRO-ros-testing \
ros-$ROS_DISTRO-rqt-robot-monitor \
ros-$ROS_DISTRO-teleop-twist-keyboard \
ros-$ROS_DISTRO-tf-transformations \
ros-$ROS_DISTRO-xacro \
ros-$ROS_DISTRO-rmw-cyclonedds-cpp \
ros-$ROS_DISTRO-rosbag2-storage-mcap \
xterm \
&& \
rm -rf /var/lib/apt/lists/*

RUN pip3 install --no-cache-dir \
# install ipython==8.0.1 to prevent errors while using odrivetool
ipython==8.0.1 \
odrive==0.6.5 \
pyproj \
pyserial \
requests \
transforms3d

# for pedestrian test
RUN pip3 install --no-cache-dir \
'pysocialforce[test,plot]'

# for debug
RUN apt update && \
apt install -y --no-install-recommends \
gdb \
vim \
&& \
rm -rf /var/lib/apt/lists/*

# set up venv for keeping compatibility
RUN mkdir -p /opt/venv
# cabot2 venv (odrive==0.5.2.post0)
RUN python3 -m venv --system-site-packages /opt/venv/cabot2 && \
. /opt/venv/cabot2/bin/activate && \
pip3 install --no-cache-dir odrive==0.5.2.post0 && \
deactivate
# cabot3 venv (odrive==0.6.5)
RUN python3 -m venv --system-site-packages /opt/venv/cabot3

ENV USERNAME developer
# Replace 1000 with your user/group id
ARG UID=1000
RUN useradd -m $USERNAME && \
echo "$USERNAME:$USERNAME" | chpasswd && \
usermod --shell /bin/bash $USERNAME && \
usermod -aG sudo $USERNAME && \
mkdir -p /etc/sudoers.d/ && \
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME && \
usermod --uid $UID $USERNAME && \
groupmod --gid $UID $USERNAME

# install entrypoint
COPY launch.sh /

# change location of ros base
RUN sed -i 's:custom_ws:underlay_ws:' /ros_entrypoint.sh

USER $USERNAME

ENV HOME /home/$USERNAME

WORKDIR $HOME/ros2_ws

CMD [ "/launch.sh" ]
2 changes: 1 addition & 1 deletion launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ blue "All launched: $( echo "$(date +%s.%N) - $start" | bc -l )"
if [[ $run_test -eq 1 ]]; then
blue "Running test $module $test_func"
if [[ $debug -eq 1 ]]; then
docker compose exec navigation /home/developer/ros2_ws/script/run_test.sh -w -d $module $test_func $retryoption # debug
docker compose -f docker-compose-debug.yaml run debug /home/developer/ros2_ws/script/run_test.sh -w -d $module $test_func $retryoption # debug
else
docker compose exec navigation /home/developer/ros2_ws/script/run_test.sh -w $module $test_func $retryoption
fi
Expand Down

0 comments on commit 2f52b2f

Please sign in to comment.