Skip to content
Open
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
2 changes: 1 addition & 1 deletion elevation_mapping_cupy/docker/.ros-env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ROS_DOMAIN_ID=1
RMW_IMPLEMENTATION=rmw_fastrtps_cpp
RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
30 changes: 18 additions & 12 deletions elevation_mapping_cupy/docker/Dockerfile.Orin
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@ ARG USERNAME=ros
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ARG INSTALL_EMCUPY_ROSDEPS=true
ARG INSTALL_JETSON_ML=false
ARG INSTALL_JETSON_ML=true
ARG SKIP_SEMANTIC_SENSOR=true
ARG PYPI_INDEX_URL=https://pypi.org/simple
ARG JETSON_PIP_EXTRA_INDEX_URL=https://pypi.jetson-ai-lab.dev/jp6/cu126
ARG JETSON_CUPY_VERSION=14.0.0a1

# Change this to the desired RMW implementation
# ARG RMW_NAME=zenoh
# ARG RMW_NAME=fastdds
# ARG RMW_NAME=cyclonedds
ARG RMW_NAME=fastrtps
ARG RMW_NAME=cyclonedds
#ARG RMW_NAME=fastrtps


# BUILD TYPE Debug, Release, RelWithDebInfo, MinSizeRel
ARG BUILD_TYPE=RelWithDebInfo

ENV TURTLEBOT3_MODEL=waffle_realsense_depth
ENV CUDA_PATH=/usr/local/cuda
ENV CUPY_NVCC_GENERATE_CODE="arch=compute_87,code=sm_87"

# Environment variables
ENV DEBIAN_FRONTEND=noninteractive \
Expand Down Expand Up @@ -117,6 +118,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
&& apt update && apt install -y --no-install-recommends \
ros-${ROS_DISTRO}-ros-base \
ros-${ROS_DISTRO}-rmw-fastrtps-cpp \
ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \
python3-argcomplete \
ros-${ROS_DISTRO}-${RMW_IMPLEMENTATION_DASH} \
&& apt clean \
Expand Down Expand Up @@ -182,15 +184,19 @@ RUN /home/${USERNAME}/workspace/.map_env/bin/pip install --no-cache-dir --retrie
ruamel.yaml \
chainer

# Install Jetson-specific GPU wheels from the Jetson index.
# Install environment
RUN if [ "${INSTALL_JETSON_ML}" = "true" ]; then \
PIP_INDEX_URL=${PYPI_INDEX_URL} \
PIP_EXTRA_INDEX_URL=${JETSON_PIP_EXTRA_INDEX_URL} \
/home/${USERNAME}/workspace/.map_env/bin/pip install --no-cache-dir --retries 2 --timeout 120 \
torch torchvision cupy-cuda12x; \
else \
echo "Skipping Jetson ML wheels (torch/torchvision/cupy-cuda12x)."; \
fi
/home/${USERNAME}/workspace/.map_env/bin/pip uninstall -y \
torch torchvision torchaudio cupy cupy-cuda11x cupy-cuda12x cupy-cuda13x numpy || true && \
# /home/${USERNAME}/workspace/.map_env/bin/pip cache purge && \
/home/${USERNAME}/workspace/.map_env/bin/pip install --no-cache-dir \
--index-url https://pypi.jetson-ai-lab.io/jp6/cu126 \
torch==2.8.0 torchvision==0.23.0 && \
/home/${USERNAME}/workspace/.map_env/bin/pip install --no-cache-dir \
"numpy<2" "cupy-cuda12x<14" ; \
else \
echo "Skipping Jetson ML wheels (torch/torchvision/cupy/numpy)."; \
fi

RUN /home/${USERNAME}/workspace/.map_env/bin/pip install --no-cache-dir --retries 2 --timeout 120 \
-r /home/${USERNAME}/workspace/src/elevation_mapping_cupy/requirements.txt
Expand Down
15 changes: 10 additions & 5 deletions elevation_mapping_cupy/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ version: "3"
services:
elevation_mapping:
image: "elevation_mapping_cupy_ros2:latest"
container_name: "elevation_mapping_package"
container_name: "elevation_mapping_package2"
env_file: ".ros-env"
runtime: nvidia
environment:
DISPLAY: $DISPLAY
NVIDIA_DRIVER_CAPABILITIES: all
QT_X11_NO_MITSHM: 1
NVIDIA_VISIBLE_DEVICES: all
DISPLAY: ${DISPLAY}
CUDA_PATH: /usr/local/cuda
CUPY_NVCC_GENERATE_CODE: arch=compute_87,code=sm_87
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
- ~/.Xauthority:/root/.Xauthority
Expand All @@ -23,9 +25,12 @@ services:
network_mode: "host"
privileged: true
tty: true
command: /bin/bash -c " source /home/ros/workspace/.map_env/bin/activate; \
source /home/ros/workspace/install/setup.bash; \
ros2 launch elevation_mapping_cupy elevation_mapping.launch.py"
command: >
bash -lc "
source /home/ros/workspace/.map_env/bin/activate &&
source /home/ros/workspace/install/setup.bash &&
ros2 launch elevation_mapping_cupy elevation_mapping.launch.py
"

rviz:
image: "elevation_mapping_cupy_ros2:latest"
Expand Down
75 changes: 38 additions & 37 deletions elevation_mapping_cupy/docker/run.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
#!/bin/bash

# The Docker image name
set -euo pipefail

IMAGE_NAME="elevation_mapping_cupy_ros2:latest"
CONTAINER_NAME="elevation_mapping_package"

# Path to your ROS workspace on the host
HOST_WORKSPACE=$(pwd) # Path to your ROS workspace in the container
ROSBAGPATH=${1:-"/rosbag_path"} # Path to the rosbag directory in the container
ROS_DOMAIN=1 # Change ROS DOMAIN ID if needed
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ENV_FILE="${SCRIPT_DIR}/.ros-env"
CONFIG_DIR="$(realpath "${SCRIPT_DIR}/../elevation_mapping_cupy/config")"

echo $HOST_WORKSPACE
RUN_COMMAND=(
docker run
--name "${CONTAINER_NAME}"
--runtime nvidia
--privileged
--network host
--tty
--interactive
--env-file "${ENV_FILE}"
--env "DISPLAY=${DISPLAY:-}"
--env "NVIDIA_DRIVER_CAPABILITIES=all"
--env "NVIDIA_VISIBLE_DEVICES=all"
--env "QT_X11_NO_MITSHM=1"
--volume /tmp/.X11-unix:/tmp/.X11-unix
--volume "${HOME}/.Xauthority:/root/.Xauthority"
--volume /dev/bus/usb:/dev/bus/usb
--volume "${CONFIG_DIR}:/home/ros/workspace/install/share/elevation_mapping_cupy/config"
--device-cgroup-rule 'c 189:* rmw'
--device-cgroup-rule 'c 81:* rmw'
"${IMAGE_NAME}"
# /bin/bash
# -c
# "source /home/ros/workspace/.map_env/bin/activate; source /home/ros/workspace/install/setup.bash;"
)

# Define environment variables for graphical output
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
if [ ! -f $XAUTH ]; then
touch $XAUTH
xauth nlist :0 | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
chmod a+r $XAUTH
if docker ps -a --format '{{.Names}}' | grep -Fxq "${CONTAINER_NAME}"; then
echo "[run.sh] Removing existing container ${CONTAINER_NAME} to match docker compose recreate behavior."
docker rm -f "${CONTAINER_NAME}" >/dev/null
fi

echo "---------------------"
RUN_COMMAND="docker run \
--volume=$XSOCK:$XSOCK:rw \
--volume=$XAUTH:$XAUTH:rw \
--env=\"QT_X11_NO_MITSHM=1\" \
--env=\"XAUTHORITY=$XAUTH\" \
--env=\"DISPLAY=$DISPLAY\" \
--env=\"ROS_DOMAIN_ID=$ROS_DOMAIN\" \
--ulimit rtprio=99 \
--cap-add=sys_nice \
--privileged \
--net=host \
--name=elevation_mapping \
-e HOST_USERNAME=$(whoami) \
-v ${HOST_WORKSPACE}/elevation_mapping_cupy:/home/ros/workspace/src/elevation_mapping_cupy \
-v /media:/media \
-v ${ROSBAGPATH}:/home/ros/rosbags \
--runtime=nvidia \
--user 1000:1000 \
-it $IMAGE_NAME"

echo -e "[run.sh]: \e[1;32mThe final run command is:\n\e[0;35m$RUN_COMMAND\e[0m."
eval $RUN_COMMAND
echo -e "[run.sh]: \e[1;32mDocker terminal closed.\e[0m"
echo "[run.sh] Launching ${CONTAINER_NAME} from ${IMAGE_NAME}."
printf '[run.sh] Command:'
printf ' %q' "${RUN_COMMAND[@]}"
printf '\n'

"${RUN_COMMAND[@]}"
2 changes: 2 additions & 0 deletions elevation_mapping_cupy/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ scikit-image==0.19
matplotlib
catkin-tools
networkx==3.0
cupy-cuda12x
torch
# cupy

###### Requirements with Version Specifiers ######`
Expand Down