diff --git a/.docker/jazzy.amd64.dockerfile b/.docker/jazzy.amd64.dockerfile index 9c1b60bc..f2854215 100644 --- a/.docker/jazzy.amd64.dockerfile +++ b/.docker/jazzy.amd64.dockerfile @@ -45,7 +45,7 @@ extras/ros-jazzy-binary-gz-harmonic-source-install.sh install.sh RUN bash install.sh # Install Ardusub -ADD https://raw.githubusercontent.com/IOES-Lab/dave/ardusub_install/\ +ADD https://raw.githubusercontent.com/IOES-Lab/dave/dockertest/\ extras/ardusub-ubuntu-install.sh install.sh RUN bash install.sh diff --git a/.docker/jazzy.arm64v8.dockerfile b/.docker/jazzy.arm64v8.dockerfile index 54648e5c..e958a038 100644 --- a/.docker/jazzy.arm64v8.dockerfile +++ b/.docker/jazzy.arm64v8.dockerfile @@ -101,7 +101,7 @@ extras/ros-jazzy-binary-gz-harmonic-source-install.sh install.sh RUN bash install.sh # Install Ardusub -ADD https://raw.githubusercontent.com/IOES-Lab/dave/ardusub_install/\ +ADD https://raw.githubusercontent.com/IOES-Lab/dave/dockertest/\ extras/ardusub-ubuntu-install.sh install.sh RUN bash install.sh @@ -162,7 +162,7 @@ RUN mkdir -p /home/docker/.config/autostart && \ printf '\033[1;32m\n =====\n\033[0m' >> ~/.hi && \ printf "\\033[1;32m 👋 Hi! This is Docker virtual environment\n\\033[0m" \ >> ~/.hi && \ - printf "\\033[1;33m\tROS2 Jazzy - Gazebo Harmonic\n\n\n\\033[0m" \ + printf "\\033[1;33m\tROS2 Jazzy - Gazebo Harmonic (w ardusub)\n\n\n\\033[0m" \ >> ~/.hi # Remove sudo message diff --git a/extras/ardusub-ubuntu-install.sh b/extras/ardusub-ubuntu-install.sh index 3b33fe2f..6c8f8095 100644 --- a/extras/ardusub-ubuntu-install.sh +++ b/extras/ardusub-ubuntu-install.sh @@ -1,10 +1,22 @@ #!/bin/bash -mkdir -p "/opt/ardupilot_dave" && cd "/opt/ardupilot_dave" || exit +mkdir -p "/opt/ardupilot_dave" 2>/dev/null +if [ $? -ne 0 ]; then + echo "Insufficient privileges to create directory in /opt." + sudo mkdir -p "/opt/ardupilot_dave" && cd "/opt/ardupilot_dave" || exit +else + mkdir -p "/opt/ardupilot_dave" && cd "/opt/ardupilot_dave" || exit +fi + # Really should do version pinning but Sub-4.5 is waaaay behind master # (e.g. it doesn't know about "noble" yet) export ARDUPILOT_RELEASE=master -git clone -b $ARDUPILOT_RELEASE https://github.com/ArduPilot/ardupilot.git --recurse-submodules +mkdir -p "/opt/ardupilot_dave/ardupilot" 2>/dev/null +if [ $? -ne 0 ]; then + sudo git clone -b $ARDUPILOT_RELEASE https://github.com/ArduPilot/ardupilot.git --recurse-submodules +else + git clone -b $ARDUPILOT_RELEASE https://github.com/ArduPilot/ardupilot.git --recurse-submodules +fi # Install ArduSub dependencies cd "/opt/ardupilot_dave/ardupilot" || exit @@ -18,18 +30,36 @@ Tools/environment_install/install-prereqs-ubuntu.sh -y # Build ArduSub cd "/opt/ardupilot_dave/ardupilot" || exit # needs python binary (e.g. sudo apt install python-is-python3) -apt-get install -y python-is-python3 python3-future -modules/waf/waf-light configure --board still \ +mkdir -p "/opt/ardupilot_dave/ardupilot/mktest" 2>/dev/null +if [ $? -ne 0 ]; then + sudo modules/waf/waf-light configure --board still \ + && sudo modules/waf/waf-light build --target bin/ardusub +else + modules/waf/waf-light configure --board still \ && modules/waf/waf-light build --target bin/ardusub +fi # Clone ardupilot_gazebo code cd "/opt/ardupilot_dave" || exit -git clone https://github.com/ArduPilot/ardupilot_gazebo.git +mkdir -p "/opt/ardupilot_dave/ardupilot_gazebo" 2>/dev/null +if [ $? -ne 0 ]; then + sudo git clone https://github.com/ArduPilot/ardupilot_gazebo.git +else + git clone https://github.com/ArduPilot/ardupilot_gazebo.git +fi # Install ardupilot_gazebo plugin -mkdir -p "/opt/ardupilot_dave/ardupilot_gazebo/build" \ -&& cd "/opt/ardupilot_dave/ardupilot_gazebo/build" || exit -cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && make -j2 +# Check if the directory creation was successful +mkdir -p "/opt/ardupilot_dave/ardupilot_gazebo/build" 2>/dev/null +if [ $? -ne 0 ]; then + echo "Insufficient privileges to create directory in /opt. Using sudo for cmake and make." + sudo mkdir -p "/opt/ardupilot_dave/ardupilot_gazebo/build" \ + && cd "/opt/ardupilot_dave/ardupilot_gazebo/build" || exit + sudo cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && sudo make -j2 +else + cd "/opt/ardupilot_dave/ardupilot_gazebo/build" || exit + cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && make -j2 +fi # Add results of ArduSub build export PATH=/opt/ardupilot_dave/ardupilot/build/still/bin:\$PATH