Skip to content

Commit

Permalink
fix: missing script ros2 install
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGuyWithoutH committed Aug 3, 2024
1 parent 2d3e684 commit 13e6302
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docker_humble_jetson_torch/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ FROM dustynv/ros:humble-desktop-pytorch-l4t-r35.4.1 AS base

ARG DEBIAN_FRONTEND=noninteractive

# commands will be appended/run by the entrypoint which sources the ROS environment
COPY ros_entrypoint.sh ros2_install.sh /

# Install language
RUN apt-get update && apt-get install -y locales \
&& locale-gen en_US en_US.UTF-8 \
Expand Down
75 changes: 75 additions & 0 deletions docker_humble_jetson_torch/ros2_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env bash
# downloads, builds, and installs ROS2 packages from source in $ROS_WORKSPACE directory
# for example: ros2_install.sh xacro teleop_twist_joy
set -ex

source $ROS_ROOT/install/setup.bash
export ROS_PACKAGE_PATH=${AMENT_PREFIX_PATH}

: "${ROS_WORKSPACE:=${ROS_ROOT}}"
: "${ROSDEP_SKIP_KEYS:=gazebo11 libgazebo11-dev libopencv-dev libopencv-contrib-dev libopencv-imgproc-dev python-opencv python3-opencv}"

echo "ROS2 building packages in $ROS_WORKSPACE => $@"

mkdir -p $ROS_WORKSPACE/src
cd $ROS_WORKSPACE

if [[ $1 == http* ]]; then
SOURCE="git_clone"
cd src
git clone $1
cd ../
else
SOURCE="rosinstall_generator"
rosinstall_generator --deps --exclude RPP --rosdistro ${ROS_DISTRO} $@ > ros2.${ROS_DISTRO}.rosinstall
cat ros2.${ROS_DISTRO}.rosinstall
vcs import src/ < ros2.${ROS_DISTRO}.rosinstall

apt-get update

rosdep install -y \
--ignore-src \
--from-paths src \
--rosdistro ${ROS_DISTRO} \
--skip-keys "${ROSDEP_SKIP_KEYS}"

rm -rf /var/lib/apt/lists/*
apt-get clean
fi

if [ "${ROS_WORKSPACE}" = "${ROS_ROOT}" ]; then
COLCON_FLAGS="--merge-install"
else
COLCON_FLAGS="--symlink-install"
fi

colcon build ${COLCON_FLAGS} --base-paths src --event-handlers console_direct+

#rm -rf ${ROS_WORKSPACE}/src
#rm -rf ${ROS_WORKSPACE}/logs
#rm -rf ${ROS_WORKSPACE}/build

#rm ${ROS_WORKSPACE}/*.rosinstall

if grep $ROS_WORKSPACE /ros_entrypoint.sh; then
echo "workspace $ROS_WORKSPACE was already set to be sourced on startup:"
else
tac /ros_entrypoint.sh | sed -e "3iros_source_env $ROS_WORKSPACE/install/setup.bash" | tac | tee /ros_entrypoint.sh
echo "added $ROS_WORKSPACE to be sourced on startup:"
fi

echo ""
cat /ros_entrypoint.sh

if [ "$SOURCE" = "rosinstall_generator" ]; then
source $ROS_WORKSPACE/install/setup.bash
ros_packages=$(ros2 pkg list)
echo "ROS2 packages installed:"
echo "$ros_packages"
if echo "$ros_packages" | grep "$@"; then
echo "$@ found"
else
echo "$@ not found"
exit 1
fi
fi
30 changes: 30 additions & 0 deletions docker_humble_jetson_torch/ros_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
#set -e

function ros_source_env()
{
if [ -f "$1" ]; then
echo "sourcing $1"
source "$1"
fi
#else
# echo "notfound $1"
#fi
}

if [[ "$ROS_DISTRO" == "melodic" || "$ROS_DISTRO" == "noetic" ]]; then
ros_source_env "/opt/ros/$ROS_DISTRO/setup.bash"
else
ros_source_env "$ROS_ROOT/install/setup.bash"

#echo "ROS_PACKAGE_PATH $ROS_PACKAGE_PATH"
#echo "COLCON_PREFIX_PATH $COLCON_PREFIX_PATH"
#echo "AMENT_PREFIX_PATH $AMENT_PREFIX_PATH"
#echo "CMAKE_PREFIX_PATH $CMAKE_PREFIX_PATH"
fi

echo "ROS_DISTRO $ROS_DISTRO"
echo "ROS_ROOT $ROS_ROOT"

export AMENT_PREFIX_PATH=${AMENT_PREFIX_PATH}:${CMAKE_PREFIX_PATH}
exec "$@"

0 comments on commit 13e6302

Please sign in to comment.