diff --git a/scripts/setup/setup-open3d-slam.sh b/scripts/setup/setup-open3d-slam.sh index b99e9fa..88f6fc2 100755 --- a/scripts/setup/setup-open3d-slam.sh +++ b/scripts/setup/setup-open3d-slam.sh @@ -20,19 +20,35 @@ else exit 1 fi -echo "Installing open3d dependencies for ROS2 $TARGET_ROS_DISTRO..." - -# check cmake version, it should be 3.29.2 -cmake --version -if [ $? -ne 0 ]; then - echo "ERROR: CMake is not installed" +# Determine system architecture +readonly ARCH=$(uname -m) +if [[ "$ARCH" == "x86_64" ]]; then + readonly INSTALL_METHOD="ppa" +elif [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]]; then + readonly INSTALL_METHOD="source" +else + echo "ERROR: Unsupported architecture: $ARCH" + echo "This script supports x86_64 (AMD64) and aarch64 (ARM64)" exit 1 fi -CMAKE_VERSION=$(cmake --version | awk '/cmake version/ {print $3}') -REQUIRED_CMAKE_VERSION="3.29.2" -if [ "$(printf '%s\n' "$REQUIRED_CMAKE_VERSION" "$CMAKE_VERSION" | sort -V | head -n1)" != "$REQUIRED_CMAKE_VERSION" ]; then - echo "ERROR: CMake version must be at least $REQUIRED_CMAKE_VERSION (found $CMAKE_VERSION)" - exit 1 + +echo "Installing open3d dependencies for ROS2 $TARGET_ROS_DISTRO on $ARCH architecture..." + +# Check CMake version only for source builds (ARM64) +if [[ "$INSTALL_METHOD" == "source" ]]; then + echo "Checking CMake version for source build..." + cmake --version + if [ $? -ne 0 ]; then + echo "ERROR: CMake is not installed" + exit 1 + fi + CMAKE_VERSION=$(cmake --version | awk '/cmake version/ {print $3}') + REQUIRED_CMAKE_VERSION="3.29.2" + if [ "$(printf '%s\n' "$REQUIRED_CMAKE_VERSION" "$CMAKE_VERSION" | sort -V | head -n1)" != "$REQUIRED_CMAKE_VERSION" ]; then + echo "ERROR: CMake version must be at least $REQUIRED_CMAKE_VERSION (found $CMAKE_VERSION)" + exit 1 + fi + echo "CMake version $CMAKE_VERSION is sufficient for source build" fi python3 -m pip install --break-system-packages --no-cache-dir "mcap[ros2]" @@ -51,40 +67,41 @@ apt-get update && \ apt-get install -y libc++abi-dev libc++-dev liblua5.4-dev libomp-dev libgoogle-glog-dev libgflags-dev && \ rm -rf /var/lib/apt/lists/* +# Install Open3D based on architecture +if [[ "$INSTALL_METHOD" == "ppa" ]]; then + echo "Installing Open3D from PPA for AMD64 architecture..." + apt-get update && \ + apt-get install -y software-properties-common && \ + add-apt-repository -y ppa:roehling/open3d && \ + apt-get update && \ + apt-get install -y libopen3d-dev && \ + rm -f /etc/apt/sources.list.d/roehling-ubuntu-open3d-*.list && \ + apt-get update && \ + apt-get clean && rm -rf /var/lib/apt/lists/* +elif [[ "$INSTALL_METHOD" == "source" ]]; then + echo "Installing Open3D from source for ARM64 architecture..." + readonly OPEN3D_VERSION="0.19.0" + readonly OPEN3D_INSTALL_DIR="/usr/local" + + echo "Installing Open3D version ${OPEN3D_VERSION}..." + wget -qO- https://github.com/isl-org/Open3D/archive/refs/tags/v${OPEN3D_VERSION}.tar.gz | tar xzv -C /tmp + + cd /tmp/Open3D-${OPEN3D_VERSION} + chmod +x util/install_deps_ubuntu.sh + DEBIAN_FRONTEND=noninteractive SUDO=command ./util/install_deps_ubuntu.sh assume-yes + + mkdir build && cd build + cmake -DCMAKE_INSTALL_PREFIX=${OPEN3D_INSTALL_DIR} \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_EXAMPLES=OFF \ + -DBUILD_PYTHON_MODULE=OFF \ + -DBUILD_GUI=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DDEVELOPER_BUILD=OFF .. + make -j$(nproc) + make install + cd /tmp + rm -rf Open3D-${OPEN3D_VERSION} +fi -# Install Open3D (from ppa) - -# apt-get update && \ -# apt-get install -y software-properties-common && \ -# add-apt-repository -y ppa:roehling/open3d && \ -# apt-get update && \ -# apt-get install -y libopen3d-dev && \ -# rm -f /etc/apt/sources.list.d/roehling-ubuntu-open3d-*.list && \ -# apt-get update && \ -# apt-get clean && rm -rf /var/lib/apt/lists/* - -# Install Open3D (from source) -readonly OPEN3D_VERSION="0.19.0" -readonly OPEN3D_INSTALL_DIR="/usr/local" - -echo "Installing Open3D version ${OPEN3D_VERSION}..." -wget -qO- https://github.com/isl-org/Open3D/archive/refs/tags/v${OPEN3D_VERSION}.tar.gz | tar xzv -C /tmp - -cd /tmp/Open3D-${OPEN3D_VERSION} -chmod +x util/install_deps_ubuntu.sh -DEBIAN_FRONTEND=noninteractive SUDO=command ./util/install_deps_ubuntu.sh assume-yes - -mkdir build && cd build -cmake -DCMAKE_INSTALL_PREFIX=${OPEN3D_INSTALL_DIR} \ - -DBUILD_SHARED_LIBS=ON \ - -DBUILD_EXAMPLES=OFF \ - -DBUILD_PYTHON_MODULE=OFF \ - -DBUILD_GUI=OFF \ - -DCMAKE_BUILD_TYPE=Release \ - -DDEVELOPER_BUILD=OFF .. -make -j$(nproc) -make install -cd /tmp -rm -rf Open3D-${OPEN3D_VERSION} - -echo "Open3d dependencies installed successfully for ROS2 $TARGET_ROS_DISTRO" \ No newline at end of file +echo "Open3D dependencies installed successfully for ROS2 $TARGET_ROS_DISTRO on $ARCH" diff --git a/scripts/setup/setup-robot-host.sh b/scripts/setup/setup-robot-host.sh index 0980d8b..9eeb81d 100755 --- a/scripts/setup/setup-robot-host.sh +++ b/scripts/setup/setup-robot-host.sh @@ -52,11 +52,23 @@ if [ "$EUID" -ne 0 ]; then exit 1 fi +# Determine system architecture +readonly ARCH=$(uname -m) +if [[ "$ARCH" == "x86_64" ]]; then + readonly INSTALL_METHOD="ppa" +elif [[ "$ARCH" == "aarch64" ]] || [[ "$ARCH" == "arm64" ]]; then + readonly INSTALL_METHOD="source" +else + echo "ERROR: Unsupported architecture: $ARCH" + echo "This script supports x86_64 (AMD64) and aarch64/arm64 (ARM64)" + exit 1 +fi + # Set the target user USER="robotx" USER_HOME="/home/${USER}" -echo "Setting up robot host system..." +echo "Setting up robot host system on $ARCH architecture..." # Get the workspace root directory ROOT=$(dirname $(dirname $(dirname $(readlink -f $0)))) @@ -159,8 +171,13 @@ ${ROOT}/scripts/setup/setup-fzf.sh 0.52.1 # Install ROS2 and Graph MSF only if --nuc flag is set if [ "$IS_NUC" = true ]; then - # Install CMake - ${ROOT}/scripts/setup/setup-cmake.sh + # Install CMake only for ARM64 builds (needed for Open3D source build) + if [[ "$INSTALL_METHOD" == "source" ]]; then + echo "Upgrading CMake for ARM64 build..." + ${ROOT}/scripts/setup/setup-cmake.sh + else + echo "Using default CMake for AMD64 build..." + fi # Install Open3d SLAM ${ROOT}/scripts/setup/setup-open3d-slam.sh